Documentation ¶
Index ¶
- Constants
- func AddHandlerFactory(typ string, factory HandlerFactory)
- func AddHandlerIoWriterFactory(typ string, factory IoWriterWriterFactory)
- func AppendLoggerContextField(ctx context.Context, fields map[string]interface{}) context.Context
- func ContextLoggerFieldsResolver(ctx context.Context) map[string]interface{}
- func FormatterConsole(timestamp string, level int, format string, args []interface{}, err error, ...) ([]byte, error)
- func FormatterJson(timestamp string, level int, format string, args []interface{}, err error, ...) ([]byte, error)
- func GetMockedStackTrace(depthSkip int) string
- func GetStackTrace(depthSkip int) string
- func LevelName(level int) string
- func LevelPriority(level string) int
- func MainLoggerConfigPostProcessor(config cfg.GosoConf) (bool, error)
- func NewHandlerIoWriter(level string, channels []string, formatter Formatter, timestampFormat string, ...) *handlerIoWriter
- func NewIoWriterFile(path string) (io.Writer, error)
- func NewLogger() *gosoLogger
- func NewLoggerContext(ctx context.Context, fields map[string]interface{}) context.Context
- func NewLoggerWithInterfaces(clock clock.Clock, handlers []Handler) *gosoLogger
- func SentryContextConfigProvider(config ConfigProvider, handler *HandlerSentry) error
- func SentryContextEcsMetadataProvider(_ ConfigProvider, handler *HandlerSentry) error
- func UnmarshalHandlerSettingsFromConfig(config cfg.Config, name string, settings interface{})
- type ConfigProvider
- type ContextEnforcingLogger
- func (l *ContextEnforcingLogger) Debug(msg string, args ...interface{})
- func (l *ContextEnforcingLogger) Enable()
- func (l *ContextEnforcingLogger) Error(msg string, args ...interface{})
- func (l *ContextEnforcingLogger) Info(msg string, args ...interface{})
- func (l *ContextEnforcingLogger) Warn(msg string, args ...interface{})
- func (l *ContextEnforcingLogger) WithChannel(channel string) Logger
- func (l *ContextEnforcingLogger) WithContext(ctx context.Context) Logger
- func (l *ContextEnforcingLogger) WithFields(fields Fields) Logger
- type ContextFieldsResolver
- type Data
- type EcsMetadata
- type Fields
- type Formatter
- type GosoLogger
- type Handler
- type HandlerFactory
- type HandlerIoWriterSettings
- type HandlerSentry
- type HandlerSettings
- type IoWriterWriterFactory
- type Logger
- type LoggerSettings
- type MessageWithLoggingFieldsEncoder
- func (m MessageWithLoggingFieldsEncoder) Decode(ctx context.Context, _ interface{}, attributes map[string]interface{}) (context.Context, map[string]interface{}, error)
- func (m MessageWithLoggingFieldsEncoder) Encode(ctx context.Context, _ interface{}, attributes map[string]interface{}) (context.Context, map[string]interface{}, error)
- type Option
- type SamplingLogger
- func (l *SamplingLogger) Debug(msg string, args ...interface{})
- func (l *SamplingLogger) Error(msg string, args ...interface{})
- func (l *SamplingLogger) Info(msg string, args ...interface{})
- func (l *SamplingLogger) Warn(msg string, args ...interface{})
- func (l *SamplingLogger) WithChannel(channel string) Logger
- func (l *SamplingLogger) WithContext(ctx context.Context) Logger
- func (l *SamplingLogger) WithFields(fields Fields) Logger
- type SentryContextProvider
- type SentryHub
- type SentryHubSettings
- type StackTraceProvider
Constants ¶
View Source
const ( LevelTrace = "trace" LevelDebug = "debug" LevelInfo = "info" LevelWarn = "warn" LevelError = "error" PriorityTrace = 0 PriorityDebug = 1 PriorityInfo = 2 PriorityWarn = 3 PriorityError = 4 )
View Source
const MessageAttributeLoggerContext = "logger:context"
Variables ¶
This section is empty.
Functions ¶
func AddHandlerFactory ¶
func AddHandlerFactory(typ string, factory HandlerFactory)
func AddHandlerIoWriterFactory ¶
func AddHandlerIoWriterFactory(typ string, factory IoWriterWriterFactory)
func AppendLoggerContextField ¶
AppendLoggerContextField appends the fields to the existing context fields, if there are no contextFields in the context then the value is initialized with the given fields. If there is a duplicate key then the newest value is the one that will be used.
func ContextLoggerFieldsResolver ¶
ContextLoggerFieldsResolver extracts the ContextFields from ctx, if not present returns empty ContextFields
func FormatterConsole ¶
func FormatterJson ¶
func GetMockedStackTrace ¶
func GetStackTrace ¶
GetStackTrace constructs the current stacktrace. depthSkip defines how many steps of the stacktrace should be skipped. This is useful to not clutter the stacktrace with logging function calls.
func LevelPriority ¶
func NewHandlerIoWriter ¶
func NewLoggerContext ¶
NewLoggerContext returns a new Context carrying fields
func NewLoggerWithInterfaces ¶
func SentryContextConfigProvider ¶
func SentryContextConfigProvider(config ConfigProvider, handler *HandlerSentry) error
func SentryContextEcsMetadataProvider ¶
func SentryContextEcsMetadataProvider(_ ConfigProvider, handler *HandlerSentry) error
Types ¶
type ConfigProvider ¶
type ConfigProvider interface {
AllSettings() map[string]interface{}
}
type ContextEnforcingLogger ¶
type ContextEnforcingLogger struct {
// contains filtered or unexported fields
}
func NewContextEnforcingLogger ¶
func NewContextEnforcingLogger(logger Logger) *ContextEnforcingLogger
func NewContextEnforcingLoggerWithInterfaces ¶
func NewContextEnforcingLoggerWithInterfaces(logger Logger, stacktraceProvider StackTraceProvider, notifier Logger) *ContextEnforcingLogger
func (*ContextEnforcingLogger) Debug ¶
func (l *ContextEnforcingLogger) Debug(msg string, args ...interface{})
func (*ContextEnforcingLogger) Enable ¶
func (l *ContextEnforcingLogger) Enable()
func (*ContextEnforcingLogger) Error ¶
func (l *ContextEnforcingLogger) Error(msg string, args ...interface{})
func (*ContextEnforcingLogger) Info ¶
func (l *ContextEnforcingLogger) Info(msg string, args ...interface{})
func (*ContextEnforcingLogger) Warn ¶
func (l *ContextEnforcingLogger) Warn(msg string, args ...interface{})
func (*ContextEnforcingLogger) WithChannel ¶
func (l *ContextEnforcingLogger) WithChannel(channel string) Logger
func (*ContextEnforcingLogger) WithContext ¶
func (l *ContextEnforcingLogger) WithContext(ctx context.Context) Logger
func (*ContextEnforcingLogger) WithFields ¶
func (l *ContextEnforcingLogger) WithFields(fields Fields) Logger
type ContextFieldsResolver ¶
type EcsMetadata ¶
type EcsMetadata map[string]interface{}
func ReadEcsMetadata ¶
func ReadEcsMetadata() (EcsMetadata, error)
type GosoLogger ¶
type Handler ¶
type Handler interface { Channels() []string Level() int Log(timestamp time.Time, level int, msg string, args []interface{}, err error, data Data) error }
func NewCliHandler ¶
func NewCliHandler() Handler
type HandlerIoWriterSettings ¶
type HandlerSentry ¶
type HandlerSentry struct {
// contains filtered or unexported fields
}
func NewHandlerSentry ¶
func NewHandlerSentry(config cfg.Config) (*HandlerSentry, error)
func (*HandlerSentry) Channels ¶
func (h *HandlerSentry) Channels() []string
func (*HandlerSentry) Level ¶
func (h *HandlerSentry) Level() int
func (*HandlerSentry) WithContext ¶
func (h *HandlerSentry) WithContext(name string, context map[string]interface{})
type HandlerSettings ¶
type HandlerSettings struct {
Type string `cfg:"type"`
}
type IoWriterWriterFactory ¶
type Logger ¶
type Logger interface { Debug(format string, args ...interface{}) Info(format string, args ...interface{}) Warn(format string, args ...interface{}) Error(format string, args ...interface{}) WithChannel(channel string) Logger WithContext(ctx context.Context) Logger WithFields(Fields) Logger }
func NewCliLogger ¶
func NewCliLogger() Logger
type LoggerSettings ¶
type LoggerSettings struct {
Handlers map[string]HandlerSettings `cfg:"handlers"`
}
type MessageWithLoggingFieldsEncoder ¶
type MessageWithLoggingFieldsEncoder struct {
// contains filtered or unexported fields
}
func NewMessageWithLoggingFieldsEncoder ¶
func NewMessageWithLoggingFieldsEncoder(_ cfg.Config, logger Logger) *MessageWithLoggingFieldsEncoder
func NewMessageWithLoggingFieldsEncoderWithInterfaces ¶
func NewMessageWithLoggingFieldsEncoderWithInterfaces(logger Logger) *MessageWithLoggingFieldsEncoder
type Option ¶
type Option func(logger *gosoLogger) error
func WithContextFieldsResolver ¶
func WithContextFieldsResolver(resolvers ...ContextFieldsResolver) Option
func WithFields ¶
func WithHandlers ¶
type SamplingLogger ¶
type SamplingLogger struct { Logger // contains filtered or unexported fields }
func (*SamplingLogger) Debug ¶
func (l *SamplingLogger) Debug(msg string, args ...interface{})
func (*SamplingLogger) Error ¶
func (l *SamplingLogger) Error(msg string, args ...interface{})
func (*SamplingLogger) Info ¶
func (l *SamplingLogger) Info(msg string, args ...interface{})
func (*SamplingLogger) Warn ¶
func (l *SamplingLogger) Warn(msg string, args ...interface{})
func (*SamplingLogger) WithChannel ¶
func (l *SamplingLogger) WithChannel(channel string) Logger
func (*SamplingLogger) WithContext ¶
func (l *SamplingLogger) WithContext(ctx context.Context) Logger
func (*SamplingLogger) WithFields ¶
func (l *SamplingLogger) WithFields(fields Fields) Logger
type SentryContextProvider ¶
type SentryContextProvider func(config ConfigProvider, sentryHook *HandlerSentry) error
type SentryHub ¶
type SentryHub interface { ConfigureScope(f func(scope *sentry.Scope)) WithScope(f func(scope *sentry.Scope)) CaptureException(exception error) *sentry.EventID Flush(timeout time.Duration) bool }
func NewSentryHubWithSettings ¶
func NewSentryHubWithSettings(settings *SentryHubSettings) (SentryHub, error)
type SentryHubSettings ¶
type StackTraceProvider ¶
Source Files ¶
- builtin.go
- config_postprocessor_main_logger.go
- context.go
- ecs_metadata.go
- fields.go
- formatter.go
- handler.go
- handler_iowriter.go
- handler_iowriter_writer.go
- handler_iowriter_writer_file.go
- handler_sentry.go
- handler_sentry_context.go
- logger.go
- logger_context_enforce.go
- logger_message_encode_handler.go
- logger_sampling.go
- options.go
- sentry.go
- stacktrace.go
Click to show internal directories.
Click to hide internal directories.