简单 golang 日志:Golog

jopen 9年前

Golog 是简单的golang日志,基于golang内置log封装.

特性

  • log 级别支持: DEBUG, INFO, WARN, ERROR
  • deferent log handlers: ConsoleHander, FileHandler, RotatingHandler
  • basic on golang inner pkg - log

安装

go get github.com/jander/golog/logger

示例

// rotating hander, max log files is 4, max file size is 4M  rotatingHandler := logger.NewRotatingHandler("./", "test.log", 4, 4*1024*1024)     // logger set handlers: console, rotating  logger.SetHandlers([]logger.Handler{logger.Console, rotatingHandler})     defer logger.Close()     // logger set flags  logger.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)     // logger set log level  logger.SetLevel(logger.INFO)     logger.Debug("something", "debug")  logger.Info("something")  logger.Warn("something")  logger.Error("something")

项目主页:http://www.open-open.com/lib/view/home/1442543129915