Documentation ¶
Index ¶
- Variables
- type Entry
- func (e *Entry) AddHook(hook Hook)
- func (e *Entry) AddLogrusHook(hook logrus.Hook)
- func (e *Entry) Debug(args ...interface{})
- func (e *Entry) Debugf(format string, args ...interface{})
- func (e *Entry) Error(args ...interface{})
- func (e *Entry) Errorf(format string, args ...interface{})
- func (e *Entry) Fatal(args ...interface{})
- func (e *Entry) Fatalf(format string, args ...interface{})
- func (e *Entry) Formatter(formatter Formatter) *Entry
- func (e *Entry) Info(args ...interface{})
- func (e *Entry) Infof(format string, args ...interface{})
- func (e *Entry) Level(level Level) *Entry
- func (e *Entry) Log(level uint32, fields map[string]interface{}, err error, withStack bool, ...)
- func (e *Entry) Out(writer io.Writer) *Entry
- func (e *Entry) Panic(args ...interface{})
- func (e *Entry) Panicf(format string, args ...interface{})
- func (e *Entry) Warn(args ...interface{})
- func (e *Entry) Warnf(format string, args ...interface{})
- func (e *Entry) WithError(err error) *Entry
- func (e *Entry) WithField(key string, value interface{}) *Entry
- func (e *Entry) WithFields(f F) *Entry
- func (e *Entry) WithRecover(recoverData interface{}) *Entry
- func (e *Entry) WithStack(err error) *Entry
- type F
- type Formatter
- type Hook
- type Level
Constants ¶
This section is empty.
Variables ¶
var ( ErrorKey = logrus.ErrorKey StackKey = "stack" )
var AllLevels = []Level{ PanicLevel, FatalLevel, ErrorLevel, WarnLevel, InfoLevel, DebugLevel, }
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
func (*Entry) AddLogrusHook ¶
func (*Entry) Debug ¶
func (e *Entry) Debug(args ...interface{})
Debug logs a message at the debug severity.
func (*Entry) Error ¶
func (e *Entry) Error(args ...interface{})
Error logs a message at the Error severity.
func (*Entry) Fatal ¶
func (e *Entry) Fatal(args ...interface{})
Fatal logs a message at the Error severity.
func (*Entry) Info ¶
func (e *Entry) Info(args ...interface{})
Info logs a message at the Info severity.
func (*Entry) Log ¶
func (e *Entry) Log(level uint32, fields map[string]interface{}, err error, withStack bool, args ...interface{})
Log logs message with the provided severity(level), fields and error.
This Method is basically implemented to abstract packages which need logging with fields and errors from logan, so that users without logan could use such packages providing some other arbitrary implementation of Log method.
func (*Entry) Panic ¶
func (e *Entry) Panic(args ...interface{})
Panic logs a message at the Panic severity.
func (*Entry) Warn ¶
func (e *Entry) Warn(args ...interface{})
Warn logs a message at the Warn severity.
func (*Entry) WithFields ¶
func (*Entry) WithRecover ¶
WithRecover creates error from the `recoverData` if it isn't actually an error already and returns Entry with this error and its stack.
type F ¶
type F map[string]interface{}
F type is for fields, connected to `withFields` error.
func Field ¶
WithField creates new `F` fields map and add provided key-value pair into it using Add method.
DEPRECATED: Use F{key: value} directly instead. Fields expanding is now happening on adding to log Entry.
func (F) Add ¶
Add tries to extract fields from `value`, if `value` implements fields.Provider interface:
type Provider interface { GetLoganFields() map[string]interface{} }
And adds these fields using AddFields. If `value` does not implement Provider - a single key-value pair is added.
Add doesn't change any of maps - only creates a new one.
DEPRECATED: Use `fields[key] = value` instead. Fields expanding is now happening on adding to log Entry.
func (F) AddFields ¶
AddFields returns `F` map, which contains key-values from both maps. If both maps has some key - the value from the `newF` will be used.
AddFields doesn't change any of maps - only creates a new one.
DEPRECATED: Use Merge method instead (it's same, but more obvious that it doesn't mutate the instance).
type Formatter ¶
The Formatter interface is used to implement a custom Formatter. It takes an Entry. It exposes all the fields, including the default ones:
* `entry.Data["msg"]`. The message passed from Info, Warn, Error .. * `entry.Data["time"]`. The timestamp. * `entry.Data["level"]. The level the entry was logged at.
Any additional fields added with `WithField` or `WithFields` are also in `entry.Data`. Format is expected to return an array of bytes which are then logged to `logger.Out`.
var JSONFormatter Formatter = &logrus.JSONFormatter{}