Documentation ¶
Index ¶
- Constants
- Variables
- func ParseLevel(level Level) zapcore.Level
- type Level
- type Option
- func WithColor(color bool) Option
- func WithFilename(logpath string) Option
- func WithIsStdOut(isstdout bool) Option
- func WithLogFormat(logformat string) Option
- func WithLogLevel(loglevel Level) Option
- func WithMaxAge(maxage int) Option
- func WithMaxSize(maxsize int) Option
- func WithProjectName(projectname string) Option
- func WithStacktrace(stacktrace Level) Option
- type Options
Constants ¶
View Source
const ( JsonFormat = "json" PlainFormat = "plain" )
log format
View Source
const ( LogLevel Level = DebugLevel //日志记录级别 LogFormat string = PlainFormat Filename string = "" //日志保存路径 //需要设置程序当前运行路径 MaxSize int = 100 //日志分割的尺寸 MB MaxAge int = 30 //分割日志保存的时间 day Stacktrace Level = PanicLevel //记录堆栈的级别 IsStdOut bool = true //是否标准输出console输出 ProjectName string = "" //项目名称 ProjectKey string = "service" // Color bool = true ConfigFile string = "" )
默认参数
Variables ¶
View Source
var AllLevels = []Level{ PanicLevel, FatalLevel, ErrorLevel, WarnLevel, InfoLevel, DebugLevel, }
Functions ¶
func ParseLevel ¶
Types ¶
type Option ¶
type Option func(*Options)
func WithFilename ¶
func WithIsStdOut ¶
func WithLogFormat ¶
func WithLogLevel ¶
func WithMaxAge ¶
func WithMaxSize ¶
func WithProjectName ¶
func WithStacktrace ¶
type Options ¶
type Options struct { LogLevel Level `json:"level" mapstructure:"level"` //日志记录级别 ok LogFormat string `json:"format" mapstructure:"format"` //日志类型,普通 或 json Filename string `json:"filename" mapstructure:"filename"` //日志保存路径 ok MaxSize int `json:"max-size" mapstructure:"max-size"` //日志分割的尺寸 MB //ok MaxAge int `json:"max-age" mapstructure:"max-age"` //分割日志保存的时间 day Stacktrace Level `json:"stacktrace" mapstructure:"stacktrace"` //记录堆栈的级别 IsStdOut bool `json:"is-stdout" mapstructure:"is-stdout"` //是否标准输出console输出 ProjectName string `json:"project-name" mapstructure:"project-name"` //项目名称 Color bool `json:"enable-color" mapstructure:"enable-color"` }
func NewOptions ¶
func NewOptions() *Options
Click to show internal directories.
Click to hide internal directories.