Documentation ¶
Overview ¶
Package logrus provides a Logur adapter for Logrus.
Index ¶
- type Logger
- func (l *Logger) Debug(msg string, fields ...map[string]interface{})
- func (l *Logger) DebugContext(_ context.Context, msg string, fields ...map[string]interface{})
- func (l *Logger) Error(msg string, fields ...map[string]interface{})
- func (l *Logger) ErrorContext(_ context.Context, msg string, fields ...map[string]interface{})
- func (l *Logger) Info(msg string, fields ...map[string]interface{})
- func (l *Logger) InfoContext(_ context.Context, msg string, fields ...map[string]interface{})
- func (l *Logger) LevelEnabled(level logur.Level) bool
- func (l *Logger) Trace(msg string, fields ...map[string]interface{})
- func (l *Logger) TraceContext(_ context.Context, msg string, fields ...map[string]interface{})
- func (l *Logger) Warn(msg string, fields ...map[string]interface{})
- func (l *Logger) WarnContext(_ context.Context, msg string, fields ...map[string]interface{})
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a Logur adapter for Logrus.
func New ¶
New returns a new Logur logger. If logger is nil, a default instance is created.
Example ¶
package main import ( "github.com/sirupsen/logrus" logrusadapter "logur.dev/adapter/logrus" ) func main() { logger := logrusadapter.New(logrus.New()) _ = logger }
Output:
Example (Default) ¶
If logger is nil, a default instance is created.
package main import ( logrusadapter "logur.dev/adapter/logrus" ) func main() { logger := logrusadapter.New(nil) _ = logger }
Output:
func NewFromEntry ¶
NewFromEntry returns a new Logur logger from a Logrus entry. If entry is nil, a default instance is created.
Example ¶
The logger can be instantiated with a Logrus entry. It's useful if you want to create a logger from an already populated Logrus instance.
package main import ( "github.com/sirupsen/logrus" logrusadapter "logur.dev/adapter/logrus" ) func main() { entry := logrus.New().WithField("key", "value") logger := logrusadapter.NewFromEntry(entry) _ = logger }
Output:
Example (Default) ¶
If entry is nil, a default instance is created.
package main import ( logrusadapter "logur.dev/adapter/logrus" ) func main() { logger := logrusadapter.NewFromEntry(nil) _ = logger }
Output:
func (*Logger) DebugContext ¶ added in v0.4.0
func (*Logger) ErrorContext ¶ added in v0.4.0
func (*Logger) InfoContext ¶ added in v0.4.0
func (*Logger) LevelEnabled ¶
LevelEnabled implements the Logur LevelEnabler interface.
func (*Logger) TraceContext ¶ added in v0.4.0
Click to show internal directories.
Click to hide internal directories.