Documentation
¶
Index ¶
- Variables
- func ContextWithFields(ctx context.Context, fields Fields)
- func DataContext(ctx context.Context, opts ...DataContextOptions) context.Context
- func IsDebugEnabled() bool
- func Log() *logrus.Logger
- func New() *logrus.Logger
- func NewRequestID() string
- func Output(filename string, options *OutputOptions) io.Writer
- func RequestIDFromContext(ctx context.Context) (string, time.Time)
- func SetFormatter(f string, pretty bool)
- func SetLevel(l string)
- func SetOutput(filename string, options *OutputOptions)
- type DataContextOptions
- type Fields
- type Logger
- type OutputOptions
- type Report
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Debug = log.Debug Debugf = log.Debugf Error = log.Error Errorf = log.Errorf Fatal = log.Fatal Fatalf = log.Fatalf Info = log.Info Infof = log.Infof Print = log.Print Printf = log.Printf Println = log.Println Trace = log.Trace Tracef = log.Tracef Warn = log.Warn Warnf = log.Warnf WithContext = log.WithContext WithError = log.WithError WithField = log.WithField WithFields = log.WithFields RegisterExitHandler = logrus.RegisterExitHandler )
define aliases to logrus.
View Source
var ( // JSONLogFormatter formats logs into parsable json. JSONLogFormatter = &logrus.JSONFormatter{TimestampFormat: "2006-01-02T15:04:05.000-07:00", CallerPrettyfier: callerPretty, DisableHTMLEscape: true} // TextLogFormatter formats logs into text. TextLogFormatter = &logrus.TextFormatter{TimestampFormat: "2006-01-02T15:04:05.000-07:00", FullTimestamp: true, CallerPrettyfier: callerPretty} )
Functions ¶
func ContextWithFields ¶ added in v0.2.1
ContextWithFields persist fields into context if the context contains dataContextHook.
func DataContext ¶ added in v0.2.1
func DataContext(ctx context.Context, opts ...DataContextOptions) context.Context
DataContext set data to context. The dataContextHook will read it. If an empty requestID is passed in, a random one will be generated.
func IsDebugEnabled ¶
func IsDebugEnabled() bool
IsDebugEnabled checks if the log level is greater than the debug level.
func NewRequestID ¶ added in v0.2.1
func NewRequestID() string
NewRequestID returns a random request id.
func Output ¶ added in v0.3.0
func Output(filename string, options *OutputOptions) io.Writer
Output get an io.Writer according to the filename and options.
func RequestIDFromContext ¶ added in v0.3.0
RequestIDFromContext returns the requestID in context.
func SetFormatter ¶
SetFormatter sets the standard logger formatter.
func SetOutput ¶
func SetOutput(filename string, options *OutputOptions)
SetOutput sets the logger output.
Types ¶
type DataContextOptions ¶ added in v0.2.1
DataContextOptions is the options to DataContext.
type OutputOptions ¶ added in v0.3.0
type OutputOptions struct { Rotate string // options: d or day, h or hour MaxSizeInMB int MaxAgeInDay int MaxBackups int }
OutputOptions set the options to the log output files.
Click to show internal directories.
Click to hide internal directories.