Golog是简单的golang日志,基于golang内置log封装.
特征
实现各种日志level:DEBUG,INFO,WARN,ERROR
实现各种日志handlers:ConsoleHander,FileHandler,RotatingHandler
代码实例
// rotating hander, max log files is 4, max file size is 4MrotatingHandler := logger.NewRotatingHandler("./", "test.log", 4, 4*1024*1024)// logger set handlers: console, rotatinglogger.SetHandlers(logger.Console, rotatingHandler)defer logger.Close()// logger set flagslogger.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)// logger set log levellogger.SetLevel(logger.INFO)logger.Debug("something", "debug")logger.Info("something")logger.Warn("something")logger.Error("something")
评论