Simple logger library for golang.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 2337f70 Aug 11, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis.yml travis yml added Jan 20, 2016
LICENSE License added Jan 17, 2016
README.md Godoc reference added Jan 20, 2016
logger-example_test.go Add formatted commands Aug 9, 2017
logger.go Add formatted commands Aug 9, 2017
out.png Docs added Jan 17, 2016

README.md

go-logger

Build Status GoDoc

Simple logger library for golang. Colorizing, timestamping and on Debug output vars with additional info

Installation

    go get -u github.com/ivahaev/go-logger

Usage

    import "github.com/ivahaev/go-logger"

Example

    package main

    import "github.com/ivahaev/go-logger"

    func main() {
        logger.SetLevel("DEBUG")

        logger.Debug("Some string for debug", 123, map[string]interface{}{"prop1": "val1", "prop2": 321})
        logger.Info("Some string for info", 123, map[string]interface{}{"prop1": "val1", "prop2": 321})
        logger.Notice("Some string for debug", 123, map[string]interface{}{"prop1": "val1", "prop2": 321})
        logger.Warn("Some string for warning", 123, map[string]interface{}{"prop1": "val1", "prop2": 321})
        logger.Error("Some string for error", 123, map[string]interface{}{"prop1": "val1", "prop2": 321})
        logger.Crit("Some string for critical", 123, map[string]interface{}{"prop1": "val1", "prop2": 321})
    }

Output will be:

output

func Crit

func Crit(v ...interface{})

Crit logs provided arguments to console when level is CRIT, ERROR, WARN, NOTICE, INFO or DEBUG.

func Debug

func Debug(v ...interface{})

Debug logs provided arguments to console with extra info. Works only when level sets to DEBUG (default)

func Error

func Error(v ...interface{})

Error logs provided arguments to console when level is ERROR, WARN, NOTICE, INFO or DEBUG.

func Info

func Info(v ...interface{})

Info logs provided arguments to console when level is INFO or DEBUG.

func Notice

func Notice(v ...interface{})

Notice logs provided arguments to console when level is NOTICE, INFO or DEBUG.

func Warn

func Warn(v ...interface{})

Warn logs provided arguments to console when level is WARN, NOTICE, INFO or DEBUG.

func SetLevel

func SetLevel(level string) error

SetLevel sets level of logging. level can be "CRIT", 'ERROR', 'WARN', "NOTICE", "INFO" or "DEBUG"

func SetTimeFormat

func SetTimeFormat(format string) error

SetTimeFormat sets string format for time.Time.Format() method Default is "2006/01/02 - 15:04:05"