Documentation ¶
Index ¶
- Variables
- func Alert(v ...interface{})
- func Alertf(s string, v ...interface{})
- func Debug(v ...interface{})
- func Debugf(s string, v ...interface{})
- func Error(v ...interface{})
- func Errorf(s string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(s string, v ...interface{})
- func Info(v ...interface{})
- func Infof(s string, v ...interface{})
- func Notice(v ...interface{})
- func Noticef(s string, v ...interface{})
- func Panic(v ...interface{})
- func Panicf(s string, v ...interface{})
- func SetContext(ctx context.Context, e Logger) context.Context
- func SetDefaultFields(fields Map)
- func SetExitFunc(fn ExitFunc)
- func SetHandler(handler Handler)
- func SetLevel(level Level)
- func Warn(v ...interface{})
- func Warnf(s string, v ...interface{})
- type CompositeHandler
- type Config
- type DefaultHandler
- type Entry
- type ExitFunc
- type Handler
- type Level
- type LevelHandler
- type Logger
- type Map
Constants ¶
This section is empty.
Variables ¶
var (
// LoggerCtxKey is the context.Context key to store the request log entry.
LoggerCtxKey = &contextKey{"logger"}
)
Functions ¶
func Alertf ¶
func Alertf(s string, v ...interface{})
Alertf logs an alert log entry with formatting
func Errorf ¶
func Errorf(s string, v ...interface{})
Errorf logs an error log entry with formatting
func Infof ¶
func Infof(s string, v ...interface{})
Infof logs a normal. information, entry with formatting
func Noticef ¶
func Noticef(s string, v ...interface{})
Noticef logs a notice log entry with formatting
func SetContext ¶
SetContext sets a log entry into the provided context
func SetExitFunc ¶
func SetExitFunc(fn ExitFunc)
SetExitFunc sets the exit function. default: os.Exit
Types ¶
type CompositeHandler ¶
type CompositeHandler []Handler
CompositeHandler is a slice of handler
func (CompositeHandler) Handle ¶
func (handlers CompositeHandler) Handle(e *Entry)
Handle handles the entry
type Entry ¶
type Entry struct { Message string `json:"message"` Timestamp time.Time `json:"timestamp"` Fields Map `json:"fields,omitempty"` Level Level `json:"level"` }
Entry defines a single log entry
type Level ¶
type Level uint8
Level of the log
const ( DebugLevel Level = iota InfoLevel NoticeLevel WarnLevel ErrorLevel PanicLevel AlertLevel FatalLevel )
Log levels.
func (*Level) UnmarshalJSON ¶
UnmarshalJSON implementation.
type LevelHandler ¶
LevelHandler handles entries for given level
type Logger ¶
type Logger interface { // WithField returns a new log entry with the supplied field. WithField(key string, value interface{}) Logger // WithFields returns a new log entry with the supplied fields appended WithFields(fields Map) Logger // WithError add a minimal stack trace to the log Entry WithError(err error) Logger // Debug logs a debug entry Debug(v ...interface{}) // Debugf logs a debug entry with formatting Debugf(s string, v ...interface{}) // Info logs a normal. information, entry Info(v ...interface{}) // Infof logs a normal. information, entry with formatting Infof(s string, v ...interface{}) // Notice logs a notice log entry Notice(v ...interface{}) // Noticef logs a notice log entry with formatting Noticef(s string, v ...interface{}) // Warn logs a warn log entry Warn(v ...interface{}) // Warnf logs a warn log entry with formatting Warnf(s string, v ...interface{}) // Panic logs a panic log entry Panic(v ...interface{}) // Panicf logs a panic log entry with formatting Panicf(s string, v ...interface{}) // Alert logs an alert log entry Alert(v ...interface{}) // Alertf logs an alert log entry with formatting Alertf(s string, v ...interface{}) // Fatal logs a fatal log entry Fatal(v ...interface{}) // Fatalf logs a fatal log entry with formatting Fatalf(s string, v ...interface{}) // Error logs an error log entry Error(v ...interface{}) // Errorf logs an error log entry with formatting Errorf(s string, v ...interface{}) // Fields returns the fields Fields() Map }
Logger of the log
func GetContext ¶
GetContext returns the log Entry found in the context, or a new Default log Entry if none is found
func WithFields ¶
WithFields returns a new log entry with the supplied fields appended