Skip to content

A simple, powerful, and extensible Go logging framework suitable for stylized command line utilities and multi-writer logging

License

Notifications You must be signed in to change notification settings

jpmcb/gopherlogs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gopherlogs

go report card test status Apache-2.0 license Go.Dev reference

A simple, powerful, and extensible Go logging framework with batteries included 🔋.

gopherlogs is ideal for command line applications, combined logging to system files alongside terminal output, and much more.

Features:

  • Animated logging compatible with concurrent Go routines
  • Support for "emoji" style logs
  • Dynamic log line replacement
  • No external dependencies; what you see is what you get.

Usage

Install as a dependency in your Go module:

module example.com

go 1.19

require github.com/jpmcb/gopherlogs v0.1.0

And tidy up your modules and go.sum with:

$ go mod tidy

In your go code, you can now import gopherlogs:

package main

import (
        "github.com/jpmcb/gopherlogs"
)

func main() {
        // Creates a new logger with options
        l, err := gopherlogs.NewLogger(
            WithLogVerbosity(5),
        )

        // Handle errors from creating a new logger
        if err != nil {
            panic("Could not create new logger")
        }

        // Start logging!
        l.Info("Hello world")
}

When you run your Go program, it will look something like this:

$ go run main.go
Hello world

Why another Go logging framework?

This library is heavily inspired by the original logging library from Tanzu Community Edition's unmanaged-cluster CLI (which is no longer being maintained and is effectively abandoned).

I worked on that project for a few years, and we created the first iterations of this logging framework because we couldn't find anything suitable enough that was still very delightful to experience.

That experience is at the heart of this library; an amazing user experience for both the end user and the developer. In some ways, this logging library is a fork of some of the best pieces of Go code that came out of that project. And in the end, I believed it deserved to see abit more lite of day.

Shout out and huge kudos to the original authors: @stmcginnis, @joshrosso, and @jpmcb (me). Your work has inspired me and continues to bring me joy!

About

A simple, powerful, and extensible Go logging framework suitable for stylized command line utilities and multi-writer logging

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages