Skip to content

zhouruisong/go-level-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

go-level-logger

Features

  • Dynamically config log level
  • Output debug/info/notice messages to stdout, and output warn/error mssages to stdout/stderr
  • Customize log output

Examples

Basic

package main

import (
    "github.com/zhouruisong/go-level-logger"
)

func main() {
    logger.InitLogger(logger.LogLevelDebug)

    logger.Debugf("debug message")
    logger.Infof("info message")
    logger.Noticef("notice message")
    logger.Warnf("warn message")
    logger.Errorf("error message")
}

Customize log output

package main

import (
    "github.com/zhouruisong/go-level-logger"
)

func main() {
    logger.Init(logger.LogLevelDebug, "example", "/tmp", 100, 3, 365)

    logger.Debugf("debug message")
    logger.Infof("info message")
    logger.Noticef("notice message")
    logger.Warnf("warn message")
    logger.Errorf("error message")
}