Documentation ¶
Index ¶
- Constants
- func GetPackageLogger(ctx context.Context, emptyStruct interface{}) zerolog.Logger
- func Initialize(parent *zerolog.Logger, emptyStruct interface{}) (log zerolog.Logger)
- func Registrate(ctx context.Context) context.Context
- func RegistrateAndInitilize(ctx context.Context, cfg *Config) context.Context
- type Config
- type Field
- type Logger
- type TracingHook
Constants ¶
const ( LoggerLevelDebug = "DEBUG" LoggerLevelInfo = "INFO" LoggerLevelWarn = "WARN" LoggerLevelError = "ERROR" LoggerLevelFatal = "FATAL" LoggerLevelPanic = "PANIC" LoggerLevelTrace = "TRACE" LoggerLevelDisabled = "DISABLED" ProvidersName = "loggers" )
Variables ¶
This section is empty.
Functions ¶
func GetPackageLogger ¶
GetPackageLogger return logger for package
func Initialize ¶
Initialize initilizes fields for domains and packages
Types ¶
type Config ¶
type Config struct { // HumanFriendly enable writes log in human-friendly format to Out HumanFriendly bool `envconfig:"optional"` // NoColoredOutput forces logger to output things without // shell colorcodes. NoColoredOutput bool `envconfig:"optional"` // Show trace information (file name, line number, function name)? WithTrace bool `envconfig:"optional"` // Level is a logger's loglevel. Possible values: "DEBUG", // "INFO", "WARN", "ERROR", "FATAL", "TRACE". Setting this variable // to any other value will force INFO level. // Case-insensitive value. Level string `envconfig:"optional"` }
func DefaultConfig ¶
func DefaultConfig() *Config
func (*Config) SetDefault ¶ added in v0.3.0
func (c *Config) SetDefault()
type Field ¶
type Field struct { // Name is a field name. Name string Value interface{} }
Field represents field information that should be passed to context.Logger.GetLogger function.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a controlling structure for application's logger.
func (*Logger) GetLogger ¶
GetLogger creates new logger if not exists and fills it with defined fields. If requested logger already exists - it'll be returned.
func (*Logger) Initialize ¶
func (*Logger) InitializeDefault ¶
func (l *Logger) InitializeDefault()
func (*Logger) IsInitialized ¶
IsInitialized returns true if logger was initialized and configured.
type TracingHook ¶
type TracingHook struct {
WithTrace bool
}
This adds tracing ability to zerolog. By default it will add package name to every log line. If package version specified in package name (e.g. "domains/name/v1", note "v1" ending) - it will parse version and add it as separate field. Currently only one-digit-version is supported. Note that fully enabled tracing (context.Configuration.Gowork.Logger.WithTrace set to true) might eat your performance!