options

package
v0.0.0-...-e77fd90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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

Functions

func ParseLevel

func ParseLevel(level Level) zapcore.Level

Types

type Level

type Level int8

日志级别

const (
	DebugLevel Level = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
	FatalLevel
)

func (Level) String

func (level Level) String() string

type Option

type Option func(*Options)

func WithColor

func WithColor(color bool) Option

func WithFilename

func WithFilename(logpath string) Option

func WithIsStdOut

func WithIsStdOut(isstdout bool) Option

func WithLogFormat

func WithLogFormat(logformat string) Option

func WithLogLevel

func WithLogLevel(loglevel Level) Option

func WithMaxAge

func WithMaxAge(maxage int) Option

func WithMaxSize

func WithMaxSize(maxsize int) Option

func WithProjectName

func WithProjectName(projectname string) Option

func WithStacktrace

func WithStacktrace(stacktrace Level) Option

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

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) String

func (s *Options) String() string

func (*Options) Validate

func (o *Options) Validate() []error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL