Documentation
¶
Index ¶
- Constants
- Variables
- func ContextWithField(ctx context.Context, k string, v interface{}) context.Context
- func ContextWithFields(ctx context.Context, fs map[string]interface{}) context.Context
- type Configuration
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) DebugC(ctx context.Context, v ...interface{})
- func (l *Logger) DebugCf(ctx context.Context, format string, v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) ErrorC(ctx context.Context, v ...interface{})
- func (l *Logger) ErrorCf(ctx context.Context, format string, v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) FatalC(ctx context.Context, v ...interface{})
- func (l *Logger) FatalCf(ctx context.Context, format string, v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) InfoC(ctx context.Context, v ...interface{})
- func (l *Logger) InfoCf(ctx context.Context, format string, v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, v ...interface{})
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) WarnC(ctx context.Context, v ...interface{})
- func (l *Logger) WarnCf(ctx context.Context, format string, v ...interface{})
- func (l *Logger) Warnf(format string, v ...interface{})
- func (l *Logger) WithField(k string, v interface{})
- func (l *Logger) WithFields(fs map[string]interface{})
Constants ¶
View Source
const ( FormatJSON = "json" FormatText = "text" )
Formats
View Source
const ( LevelDebug = "debug" LevelError = "error" LevelFatal = "fatal" LevelInfo = "info" LevelWarn = "warn" )
Levels
View Source
const ( OutStderr = "stderr" OutStdout = "stdout" OutSyslog = "syslog" )
Outs
Variables ¶
View Source
var ( AppName = flag.String("logger-app-name", "", "the logger app name") Filename = flag.String("logger-filename", "", "the logger filename") Format = flag.String("logger-format", "", "the logger format") Level = flag.String("logger-level", "", "the logger level") MessageKey = flag.String("logger-message-key", "", "the logger message key") Out = flag.String("logger-out", "", "the logger out") Source = flag.Bool("logger-source", false, "if true, then source is added to fields") TimestampFormat = flag.String("logger-timestamp-format", "", "the logger timestamp format") Verbose = flag.Bool("v", false, "if true, then log level is debug") )
Flags
Functions ¶
func ContextWithField ¶ added in v1.1.0
Types ¶
type Configuration ¶
type Configuration struct { AppName string `toml:"app_name"` Filename string `toml:"filename"` Format string `toml:"format"` Level string `toml:"level"` MessageKey string `toml:"message_key"` Out string `toml:"out"` Source bool `toml:"source"` TimestampFormat string `toml:"timestamp_format"` }
Configuration represents the configuration of the logger
func FlagConfig ¶
func FlagConfig() (c Configuration)
FlagConfig generates a Configuration based on flags
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents an object that can log stuff
func NewFromFlags ¶ added in v1.5.0
func NewFromFlags() (l *Logger)
NewFromFlags creates a new Logger based on flags
func (*Logger) WithFields ¶ added in v1.1.0
WithFields adds fields to the logger
Click to show internal directories.
Click to hide internal directories.