Documentation
¶
Index ¶
- func AddSentryHook(dsn string)
- func DefaultForRequest(r *http.Request) *logrus.Entry
- func Get() *logrus.Entry
- func GetLogEntry(r *http.Request) logrus.FieldLogger
- func IncludeRequest(log *logrus.Entry, r *http.Request) *logrus.Entry
- func Init(config Config) (*logrus.Entry, error)
- func LogEntrySetField(r *http.Request, key string, value interface{})
- func LogEntrySetFields(r *http.Request, fields map[string]interface{})
- func NewRequestLogger(logger *logrus.Logger) func(next http.Handler) http.Handler
- type Config
- type NConfig
- type RequestLogger
- type RequestLoggerEntry
- type SentryHook
- func (hook *SentryHook) AddTag(key, value string)
- func (hook *SentryHook) Fire(entry *logrus.Entry) error
- func (hook *SentryHook) Flush()
- func (hook *SentryHook) Levels() []logrus.Level
- func (hook *SentryHook) SetEnvironment(environment string)
- func (hook *SentryHook) SetFlushTimeout(timeout time.Duration)
- func (hook *SentryHook) SetPrefix(prefix string)
- func (hook *SentryHook) SetRelease(release string)
- func (hook *SentryHook) SetTags(tags map[string]string)
- type SentryOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSentryHook ¶
func AddSentryHook(dsn string)
AddSentryHook adds hook that sends all error, fatal and panic log lines to the sentry service.
func DefaultForRequest ¶
DefaultForRequest returns default logger with included http.Request details.
func GetLogEntry ¶
func GetLogEntry(r *http.Request) logrus.FieldLogger
func IncludeRequest ¶
IncludeRequest includes http.Request details into the log.Entry.
func LogEntrySetField ¶
LogEntrySetField add field to logger in request context.
func LogEntrySetFields ¶
LogEntrySetFields add fields to logger in request context.
Types ¶
type Config ¶
type Config struct {
// AppName identifier of the app.
AppName string `json:"app_name" yaml:"app_name"`
// Level is a string representation of the `lorgus.Level`.
Level string `json:"level" yaml:"level"`
// Sentry is a DSN string for sentry hook.
Sentry string `json:"sentry" yaml:"sentry"`
// AddTrace enable adding of the filename field into log.
// DEPRECATED
AddTrace bool `json:"add_trace" yaml:"add_trace"`
// JSON enable json formatted output.
JSON bool `json:"json" yaml:"json"`
}
Config is an options for the initialization of the default logrus.Entry.
type NConfig ¶ added in v1.9.0
type NConfig struct {
// AppName identifier of the app.
AppName string `yaml:"app_name"`
// Level is a string representation of the `lorgus.Level`.
Level noble.Secret `yaml:"level"`
// Sentry is a DSN string for sentry hook.
Sentry noble.Secret `yaml:"sentry"`
// AddTrace enable adding of the filename field into log.
AddTrace bool `yaml:"add_trace"`
// JSON enable json formatted output.
JSON bool `yaml:"json"`
}
NConfig is an options for the initialization of the default logrus.Entry. N stands for Noble.
type RequestLogger ¶
RequestLogger is a simple, but powerful implementation of a custom structured logger backed on logrus. I encourage users to copy it, adapt it and make it their own. Also take a look at https://github.com/pressly/lg for a dedicated pkg based on this work, designed for context-based http routers.
func (*RequestLogger) NewLogEntry ¶
func (l *RequestLogger) NewLogEntry(r *http.Request) middleware.LogEntry
NewLogEntry sets log fields for http.Request.
type RequestLoggerEntry ¶
type RequestLoggerEntry struct {
Logger logrus.FieldLogger
}
RequestLoggerEntry is an implementation http.Request logger baked with logrus.
func (*RequestLoggerEntry) Panic ¶
func (l *RequestLoggerEntry) Panic(v interface{}, stack []byte)
type SentryHook ¶ added in v1.10.0
type SentryHook struct {
// contains filtered or unexported fields
}
func NewSentryHook ¶ added in v1.10.0
func NewSentryHook(options SentryOptions, levels ...logrus.Level) (*SentryHook, error)
func (*SentryHook) AddTag ¶ added in v1.10.0
func (hook *SentryHook) AddTag(key, value string)
func (*SentryHook) Flush ¶ added in v1.10.0
func (hook *SentryHook) Flush()
func (*SentryHook) Levels ¶ added in v1.10.0
func (hook *SentryHook) Levels() []logrus.Level
func (*SentryHook) SetEnvironment ¶ added in v1.10.0
func (hook *SentryHook) SetEnvironment(environment string)
func (*SentryHook) SetFlushTimeout ¶ added in v1.10.0
func (hook *SentryHook) SetFlushTimeout(timeout time.Duration)
func (*SentryHook) SetPrefix ¶ added in v1.10.0
func (hook *SentryHook) SetPrefix(prefix string)
func (*SentryHook) SetRelease ¶ added in v1.10.0
func (hook *SentryHook) SetRelease(release string)
func (*SentryHook) SetTags ¶ added in v1.10.0
func (hook *SentryHook) SetTags(tags map[string]string)
type SentryOptions ¶ added in v1.10.0
type SentryOptions sentry.ClientOptions
