Documentation ¶
Index ¶
- Constants
- Variables
- func AddHandler(h Handler, levels ...Level)
- 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 HandleEntry(e Entry)
- 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 Entry) context.Context
- func SetExitFunc(fn func(code int))
- func SetWithErrorFn(fn func(Entry, error) Entry)
- func Warn(v ...interface{})
- func Warnf(s string, v ...interface{})
- func WithDefaultFields(fields ...Field)
- type Entry
- func (e Entry) Alert(v ...interface{})
- func (e Entry) Alertf(s string, v ...interface{})
- func (e Entry) Debug(v ...interface{})
- func (e Entry) Debugf(s string, v ...interface{})
- func (e Entry) Error(v ...interface{})
- func (e Entry) Errorf(s string, v ...interface{})
- func (e Entry) Fatal(v ...interface{})
- func (e Entry) Fatalf(s string, v ...interface{})
- func (e Entry) Info(v ...interface{})
- func (e Entry) Infof(s string, v ...interface{})
- func (e Entry) Notice(v ...interface{})
- func (e Entry) Noticef(s string, v ...interface{})
- func (e Entry) Panic(v ...interface{})
- func (e Entry) Panicf(s string, v ...interface{})
- func (e Entry) Warn(v ...interface{})
- func (e Entry) Warnf(s string, v ...interface{})
- func (e Entry) WithError(err error) Entry
- func (e Entry) WithField(key string, value interface{}) Entry
- func (e Entry) WithFields(fields ...Field) Entry
- func (e Entry) WithTrace() Entry
- type Field
- type Fields
- type Handler
- type Level
Constants ¶
const ( // DefaultTimeFormat is the default time format when parsing Time values. // it is exposed to allow handlers to use and not have to redefine DefaultTimeFormat = "2006-01-02T15:04:05.000000000Z07:00" )
Variables ¶
var AllLevels = []Level{ DebugLevel, InfoLevel, NoticeLevel, WarnLevel, ErrorLevel, PanicLevel, AlertLevel, FatalLevel, }
AllLevels is an array of all log levels, for easier registering of all levels to a handler
Functions ¶
func AddHandler ¶
AddHandler adds a new log handler and accepts which log levels that handler will be triggered for
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 HandleEntry ¶
func HandleEntry(e Entry)
HandleEntry handles the log entry and fans out to all handlers with the proper log level This is exposed to allow for centralized logging whereby the log entry is marshalled, passed to a central logging server, unmarshalled and finally fanned out from there.
func Infof ¶
func Infof(s string, v ...interface{})
Infof logs a normal. information, entry with formatiing
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 func(code int))
SetExitFunc sets the provided function as the exit function used in Fatal(), Fatalf(), Panic() and Panicf(). This is primarily used when wrapping this library, you can set this to to enable testing (with coverage) of your Fatal() and Fatalf() methods.
func SetWithErrorFn ¶
SetWithErrorFn sets a custom WithError function handlers
func WithDefaultFields ¶
func WithDefaultFields(fields ...Field)
WithDefaultFields adds fields to the underlying logger instance
Types ¶
type Entry ¶
type Entry struct { Message string `json:"message"` Timestamp time.Time `json:"timestamp"` Fields []Field `json:"fields"` Level Level `json:"level"` // contains filtered or unexported fields }
Entry defines a single log entry
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
func WithTrace ¶
func WithTrace() Entry
WithTrace withh add duration of how long the between this function call and the susequent log
func (Entry) WithFields ¶
WithFields returns a new log entry with the supplied fields appended
type Field ¶
type Field struct { Key string `json:"key"` Value interface{} `json:"value"` }
Field is a single Field key and value
type Handler ¶
type Handler interface {
Log(Entry)
}
Handler is an interface that log handlers need to comply with
Directories ¶
Path | Synopsis |
---|---|
_examples
|
|
errors
|
|
handlers
|
|
console
Package console allows for log messages to be sent to a any writer, default os.Stderr.
|
Package console allows for log messages to be sent to a any writer, default os.Stderr. |
email
Package email allows for log messages to be sent via email.
|
Package email allows for log messages to be sent via email. |
http
Package http allows for log messages to be sent via http.
|
Package http allows for log messages to be sent via http. |
http/hipchat
Package hipchat allows for log messages to be sent to a hipchat room.
|
Package hipchat allows for log messages to be sent to a hipchat room. |
json
Package json implements a JSON handler.
|
Package json implements a JSON handler. |
syslog
Package syslog allows for log messages to be sent via syslog.
|
Package syslog allows for log messages to be sent via syslog. |