Documentation ¶
Index ¶
- func Initializer(ctx context.Context) (injectz.Injector, injectz.Releaser)
- func NewConfigSingletonInjector(cfg *Config) injectz.Injector
- func NewSingletonInjector(l Logs) injectz.Injector
- type Args
- type BeforeSendFunc
- type Config
- type ContextLogs
- type Level
- type Logs
- type Metadata
- type Option
- type OptionFunc
- type OutputFormat
- type User
- type UserExtractor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initializer ¶
Initializer is a Logs initializer which provides a default implementation using Logrus and Sentry.
func NewConfigSingletonInjector ¶
NewConfigSingletonInjector always inject the given *Config.
func NewSingletonInjector ¶
NewSingletonInjector always injects the given Logs.
Types ¶
type Args ¶
type Args []interface{}
Args describes a list of args used for formatting an entry message.
type BeforeSendFunc ¶ added in v1.0.0
type BeforeSendFunc func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event
BeforeSendFunc describes a function called before sending out an event.
type Config ¶ added in v1.1.0
type Config struct { SentryLevel Level `json:"sentryLevel" validate:"required,oneof=debug info warning error"` OutputLevel Level `json:"outputLevel" validate:"required,oneof=debug info warning error"` OutputFormat OutputFormat `json:"format" validate:"required,oneof=text json"` SentryDSN string `json:"sentryDsn"` SentrySampleRate float64 `json:"sentrySampleRate" validate:"required"` SentryTracesSampleRate float64 `json:"sentryTracesSampleRate" validate:"required"` SentryTransport sentry.Transport `json:"-"` ReleaseTimeoutSeconds int `json:"releaseTimeoutSeconds"` Environment string `json:"environment"` Release string `json:"release"` ServerName string `json:"serverName"` }
Config describes the configuration for Logs.
type ContextLogs ¶
type ContextLogs interface { Debug(format string, options ...Option) Info(format string, options ...Option) Warning(err error) Error(err error) TraceHTTPRequestServer(req *http.Request, reqBody []byte) (context.Context, func()) TraceHTTPRequestServerSimple(req *sentry.Request) (context.Context, func()) TraceSpan(op, desc string) (context.Context, func()) SetUser(user *User) AddMetadata(k string, v interface{}) }
ContextLogs describes a Logs with a cached context.
func Get ¶
func Get(ctx context.Context) ContextLogs
Get extracts the Logs from context and wraps it as ContextLogs, returns a no-op Logs if not found.
type Logs ¶
type Logs interface { Debug(ctx context.Context, skipCallers int, format string, options ...Option) Info(ctx context.Context, skipCallers int, format string, options ...Option) Warning(ctx context.Context, err error) Error(ctx context.Context, err error) TraceHTTPRequestServer(ctx context.Context, req *http.Request, reqBody []byte) (context.Context, func()) TraceHTTPRequestServerSimple(ctx context.Context, req *sentry.Request) (context.Context, func()) TraceSpan(ctx context.Context, op, desc string) (context.Context, func()) SetUser(ctx context.Context, user *User) AddMetadata(ctx context.Context, k string, v interface{}) }
Logs describes the logs module.
type Metadata ¶
type Metadata map[string]interface{}
Metadata describes metadata which can be attached to an entry.
type Option ¶
type Option interface {
Apply(e *entry)
}
Option describes an option which can be applied to an entry.
type OptionFunc ¶
type OptionFunc func(e *entry)
OptionFunc describes an option which can be applied to an entry.
func M ¶
func M(k string, v interface{}) OptionFunc
M is a shorthand for providing metadata to an entry.
func (OptionFunc) Apply ¶
func (f OptionFunc) Apply(e *entry)
Apply implements the Option interface.
type OutputFormat ¶
type OutputFormat string
OutputFormat describes the format for output logs.
const ( Text OutputFormat = "text" JSON OutputFormat = "json" )
Known formats.
type UserExtractor ¶
type UserExtractor interface {
ExtractUser() *User
}
UserExtractor describes the ability to provide a user.