logging/README.md

43 lines
825 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# logging
日志组件
## 使用说明
日志组件封装了uber/zap使用基本一致
```
package main
import(
"git.hpds.cc/Component/logging"
"go.uber.org/zap/zap"
)
func main(){
logger := LoadLoggerConfig()
logger.Info("this is a test log")
//也可以这样直接使用
logging.L().Info("this is a test log")
}
// LoadLoggerConfig 加载日志配置
func LoadLoggerConfig() *logging.Logger {
return logging.NewLogger(
logging.SetPath("./log/"),
logging.SetPrefix(""),
logging.SetDevelopment(true),
logging.SetDebugFileSuffix(""),
logging.SetWarnFileSuffix(""),
logging.SetErrorFileSuffix(""),
logging.SetInfoFileSuffix(""),
logging.SetMaxAge(30),
logging.SetMaxBackups(100),
logging.SetMaxSize(100),
logging.SetLevel(logging.LogLevel["debug"]),
)
}
```