Documentation ¶
Index ¶
- func AddLoggerToContext(ctx context.Context) context.Context
- func Default(opts ...Opt) logrus.FieldLogger
- func Get(ctx context.Context) logrus.FieldLogger
- func NewContextWithLogger() context.Context
- func ToCtx(ctx context.Context, logger logrus.FieldLogger) context.Context
- type Opt
- type Plugin
- type PluginManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLoggerToContext ¶
AddLoggerToContext add the Default() logger on top of the current context
func Default ¶
func Default(opts ...Opt) logrus.FieldLogger
Default generate a logrus logger with the configuration defined in the environment and the hooks used in the plugins
func Get ¶
func Get(ctx context.Context) logrus.FieldLogger
Get return the logger stored in the context or create a new one if the logger is not set
func NewContextWithLogger ¶
NewContextWithLogger generate a new context (based on context.Background()) and add a Default() logger on top of it
Types ¶
type Opt ¶
Opt is a function-option type for the Default() method.
func WithLogFormatter ¶
func WithLogLevel ¶
WithLogLevel let us define the level of verbosity of the logger
type Plugin ¶
type Plugin interface { Name() string // Return the name of the plugin. This name must be unique for each plugin Hook() (bool, logrus.Hook) // Return a boolean and a hook. If the boolean is set to true, the hook will be added to the logger, otherwise the hook will be ignored }
Plugin is the interface that a Plugin need to implement to be compatible with the logger library
type PluginManager ¶
type PluginManager struct {
// contains filtered or unexported fields
}
func (*PluginManager) Hooks ¶
func (m *PluginManager) Hooks() []logrus.Hook
Hooks return all the hooks generated by the plugins
func (*PluginManager) RegisterPlugin ¶
func (m *PluginManager) RegisterPlugin(plugin Plugin)
RegisterPlugin add a plugin to the current plugin list, if the plugin is already in memory, he will skip the add part