Documentation ¶
Index ¶
- Constants
- func Debug(args ...interface{})
- func DebugEnabled() bool
- func Debugf(template string, args ...interface{})
- func Error(args ...interface{})
- func ErrorEnabled() bool
- func Errorf(template string, args ...interface{})
- func Fatal(args ...interface{})
- func FatalEnabled() bool
- func Fatalf(template string, args ...interface{})
- func Info(args ...interface{})
- func InfoEnabled() bool
- func Infof(template string, args ...interface{})
- func Scopes() map[string]*Scope
- func Warn(args ...interface{})
- func WarnEnabled() bool
- func Warnf(template string, args ...interface{})
- type Entry
- type Level
- type Options
- type Scope
- func (s *Scope) CopyByCallerSkip(callerSkip int) *Scope
- func (s *Scope) Debug(args ...interface{})
- func (s *Scope) DebugEnabled() bool
- func (s *Scope) Debugf(template string, args ...interface{})
- func (s *Scope) Error(args ...interface{})
- func (s *Scope) ErrorEnabled() bool
- func (s *Scope) Errorf(template string, args ...interface{})
- func (s *Scope) Fatal(args ...interface{})
- func (s *Scope) FatalEnabled() bool
- func (s *Scope) Fatalf(template string, args ...interface{})
- func (s *Scope) Info(args ...interface{})
- func (s *Scope) InfoEnabled() bool
- func (s *Scope) Infof(template string, args ...interface{})
- func (s *Scope) Name() string
- func (s *Scope) Warn(args ...interface{})
- func (s *Scope) WarnEnabled() bool
- func (s *Scope) Warnf(template string, args ...interface{})
Constants ¶
const ( // NoneLevel disables logging NoneLevel Level = 0 // FatalLevel enables fatal level logging FatalLevel = 1 << iota // ErrorLevel enables error level logging ErrorLevel // WarnLevel enables warn level logging WarnLevel // InfoLevel enables info level logging InfoLevel // DebugLevel enables debug level logging DebugLevel )
const (
// DefaultScopeName defines the name of the default scope.
DefaultScopeName = "default"
)
Variables ¶
This section is empty.
Functions ¶
func DebugEnabled ¶
func DebugEnabled() bool
DebugEnabled returns whether output of messages using this scope is currently enabled for debug-level output.
func Debugf ¶
func Debugf(template string, args ...interface{})
Debugf uses fmt.Sprintf to construct and log a message at debug level.
func Error ¶
func Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message at error level.
func ErrorEnabled ¶
func ErrorEnabled() bool
ErrorEnabled returns whether output of messages using this scope is currently enabled for error-level output.
func Errorf ¶
func Errorf(template string, args ...interface{})
Errorf uses fmt.Sprintf to construct and log a message at error level.
func FatalEnabled ¶
func FatalEnabled() bool
FatalEnabled returns whether output of messages using this scope is currently enabled for fatal-level output.
func Fatalf ¶
func Fatalf(template string, args ...interface{})
Fatalf uses fmt.Sprintf to construct and log a message at fatal level.
func InfoEnabled ¶
func InfoEnabled() bool
InfoEnabled returns whether output of messages using this scope is currently enabled for info-level output.
func Infof ¶
func Infof(template string, args ...interface{})
Infof uses fmt.Sprintf to construct and log a message at info level.
func Warn ¶
func Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message at warn level.
func WarnEnabled ¶
func WarnEnabled() bool
WarnEnabled returns whether output of messages using this scope is currently enabled for warn-level output.
Types ¶
type Entry ¶
type Entry struct { //以下是配套的格式 LogID string `json:"log_id"` Project string `json:"project"` Method string `json:"method"` RemoteRervice string `json:"remote_service"` CostTime float64 `json:"cost_time"` Status string `json:"status"` URLPath string `json:"url_path"` UserAgent string `json:"user_agent"` Code string `json:"code"` Extra string `json:"extra"` MerchantCode string `json:"merchant_code"` }
Entry 是配套的格式
type Options ¶
type Options struct { LoggerName string // OutputPaths is a list of file system paths to write the log data to. // The special values stdout and stderr can be used to output to the // standard I/O streams. This defaults to stdout. OutputPaths []string // ErrorOutputPaths is a list of file system paths to write logger errors to. // The special values stdout and stderr can be used to output to the // standard I/O streams. This defaults to stderr. ErrorOutputPaths []string // RotateOutputPath is the path to a rotating log file. This file should // be automatically rotated over time, based on the rotation parameters such // as RotationMaxSize and RotationMaxAge. The default is to not rotate. // // This path is used as a foundational path. This is where log output is normally // saved. When a rotation needs to take place because the file got too big or too // old, then the file is renamed by appending a timestamp to the name. Such renamed // files are called backups. Once a backup has been created, // output resumes to this path. RotateOutputPath string // RotationMaxSize is the maximum size in megabytes of a log file before it gets // rotated. It defaults to 100 megabytes. RotationMaxSize int // RotationMaxAge is the maximum number of days to retain old log files based on the // timestamp encoded in their filename. Note that a day is defined as 24 // hours and may not exactly correspond to calendar days due to daylight // savings, leap seconds, etc. The default is to remove log files // older than 30 days. RotationMaxAge int // RotationMaxBackups is the maximum number of old log files to retain. The default // is to retain at most 1000 logs. RotationMaxBackups int // JSONEncoding controls whether the log is formatted as JSON. JSONEncoding bool OutputLevels Level LogCallerLevels Level StackTraceLevels Level ////for test; If not nil, called instead of os.Exit. ExitFunc func() }
Options Config
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns a new set of options, initialized to the defaults
type Scope ¶
type Scope struct { Entry // contains filtered or unexported fields }
func GetScope ¶
GetScope returns a previously registered scope, or nil if the named scope wasn't previously registered
func RegisterScope ¶
RegisterScope registers a new logging scope. If the same name is used multiple times for a single process, the same Scope struct is returned.
Scope names cannot include colons, commas, or periods.
func (*Scope) CopyByCallerSkip ¶
func (*Scope) Debug ¶
func (s *Scope) Debug(args ...interface{})
Debug uses fmt.Sprint to construct and log a message at debug level.
func (*Scope) DebugEnabled ¶
DebugEnabled returns whether output of messages using this scope is currently enabled for debug-level output.
func (*Scope) Error ¶
func (s *Scope) Error(args ...interface{})
Error uses fmt.Sprint to construct and log a message at error level.
func (*Scope) ErrorEnabled ¶
ErrorEnabled returns whether output of messages using this scope is currently enabled for error-level output.
func (*Scope) Fatal ¶
func (s *Scope) Fatal(args ...interface{})
Fatal outputs a message at fatal level.
func (*Scope) FatalEnabled ¶
FatalEnabled returns whether output of messages using this scope is currently enabled for fatal-level output.
func (*Scope) Info ¶
func (s *Scope) Info(args ...interface{})
Info uses fmt.Sprint to construct and log a message at info level.
func (*Scope) InfoEnabled ¶
InfoEnabled returns whether output of messages using this scope is currently enabled for info-level output.
func (*Scope) Warn ¶
func (s *Scope) Warn(args ...interface{})
Warn uses fmt.Sprint to construct and log a message at warn level.
func (*Scope) WarnEnabled ¶
WarnEnabled returns whether output of messages using this scope is currently enabled for warn-level output.