Skip to content

creativeprojects/clog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Godoc reference Build Go Report Card codecov

clog (console-log)

All the fashionable loggers for Go tend to focus on structured logging, and that's perfectly fine: until you simply need a logger for a console application...

So here's yet another logger for Go:

  • unstructured logging
  • console logging in colour
  • file logging
  • simple to use
  • filter your logs from 5 levels of severity (Trace, Debug, Info, Warn, Error)
  • redirect your logs to an io.Writer
  • get logs coming from an io.Writer
  • using the logger from the standard library under the hood
  • extensible (via handlers and middleware)
  • unit test coverage of more than 90%
  • drop-in replacement for the standard library logger

Have a look at the examples if you like the look of it

Here's a very simple one:

package main

import (
	"fmt"
	"github.com/creativeprojects/clog"
)

func main() {
	log := clog.NewFilteredConsoleLogger(clog.LevelInfo)

	log.Info("will be displayed")
	log.Debug("will be discarded")
	log.Trace("will be discarded")
	log.Trace(func() string { return "will not be called" })

	log.Info(fmt.Sprintf, "generated and displayed(%d)", 1)
	log.Infof("generated and displayed(%d)", 2)
}

example

Documentation available on GoDoc