Documentation ¶
Overview ¶
Package logger provides structured logging abstraction or facade, to be used by code which is not aware what logging library is used by end user.
Each message logged has a level, which was modeled after http://tools.ietf.org/html/rfc5424 severity levels:
- Debug - Information useful to developers for debugging the application.
- Info - Normal operational messages that require no action.
- Warn - May indicate that an error will occur if action is not taken.
- Error - Non-urgent failures - these should be relayed to developers or admins; each item must be resolved within a given time.
Index ¶
- type Adapter
- type Entry
- type Field
- type Global
- func (g *Global) Debug(ctx context.Context, msg string)
- func (g *Global) Error(ctx context.Context, msg string)
- func (g *Global) Info(ctx context.Context, msg string)
- func (g *Global) SetAdapter(adapter Adapter)
- func (g *Global) Warn(ctx context.Context, msg string)
- func (g *Global) With(ctx context.Context, key string, value interface{}) Logger
- func (g *Global) WithError(ctx context.Context, err error) Logger
- type Level
- type Local
- func (l Local) Debug(ctx context.Context, msg string)
- func (l Local) Error(ctx context.Context, msg string)
- func (l Local) Info(ctx context.Context, msg string)
- func (l Local) Warn(ctx context.Context, msg string)
- func (l Local) With(ctx context.Context, key string, value interface{}) Logger
- func (l Local) WithError(ctx context.Context, err error) Logger
- func (l Local) WithSkippedCallerFrame(ctx context.Context) Logger
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Global ¶
type Global struct {
// contains filtered or unexported fields
}
Global is a logger shared globally. You can use it to define global logger for your package:
package yourpackage import "github.com/elgopher/yala/logger" var Logger logger.Global // define global logger, no need to initialize (by default nothing is logged)
It is safe to use it concurrently.
func (*Global) SetAdapter ¶
SetAdapter updates adapter implementation. By default, nothing is logged.
It can be run anytime. Please note though that this method is meant to be used by end user, configuring logging from the central place (such as main.go or any other package setting up the entire application).
type Local ¶
type Local struct {
Adapter Adapter
}
Local is an immutable struct to log messages or create new loggers with fields or error.
It is safe to use it concurrently.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an immutable struct to log messages or create new loggers with fields or error.
It is safe to use it concurrently.