Documentation ¶
Overview ¶
Pulled from the github.com/oxtoacart/bpool
Index ¶
- Constants
- Variables
- func AddGlobalFields(fields ...Field)
- func Debug(message string, fields ...Field)
- func Error(message string, fields ...Field)
- func Fatal(message string, fields ...Field)
- func Info(message string, fields ...Field)
- func Panic(message string, fields ...Field)
- func Requestify(next http.Handler) http.Handler
- func SetTraceErrSeverity(s string)
- func TraceErr(err error, fields ...Field) error
- func Warning(message string, fields ...Field)
- type Field
- func Bool(key string, val bool) Field
- func Duration(key string, val time.Duration) Field
- func Err(err error) Field
- func Float64(key string, val float64) Field
- func Int(key string, val int) Field
- func Int64(key string, val int64) Field
- func JsonString(key string, val string) Field
- func Jsonify(key string, val interface{}) Field
- func NullableString(key string, val string) Field
- func Raw(key string, val interface{}) Field
- func RawJSON(key string, val []byte) Field
- func Request(r *http.Request) Field
- func Skip() Field
- func String(key string, val string) Field
- func Time(key string, val time.Time) Field
- func Uint(key string, val uint) Field
- func Uint64(key string, val uint64) Field
- func Uintptr(key string, val uintptr) Field
- type LockedSyslogWriteSyncer
- type LogFunc
- type Token
- type WriteSyncer
Constants ¶
View Source
const ( SeverityDebug = "debug" SeverityInfo = "info" SeverityWarn = "warn" SeverityError = "error" SeverityPanic = "panic" SeverityFatal = "fatal" )
Variables ¶
View Source
var ( // Writer is the writer interface which the logs will be written too. Writer = NewLockedWriteSyncer(os.Stdout) // TimeStampKey is the json key for the timestamp output. TimeStampKey = "ts" // TimeFormat will set the `slog.Time` output format if supplied. Defaults to `time.Unix()`. TimeFormat = "" // SeverityKey is the json key for the initial log type (info, warn, error, etc etc). SeverityKey = []byte("level") // TitleKey is the json key for the name of the log message. TitleKey = []byte("msg") // EnableDebug will print debug logs if true. EnableDebug = false // RequestToken is the token generator for the request middleware. RequestToken Token = &genericToken{} )
View Source
var ( // RequestHeaderKey is the key used when adding the header token. RequestHeaderKey = "___slog_request_token___" // RequestFieldKey is the key used in the Field output. RequestFieldKey = "reqID" // ResponseHeaderKey will send the token on the response as well (if set). ResponseHeaderKey = "" )
View Source
var DiscardWrapper = &noSyncWrapper{ioutil.Discard}
DiscardWrapper is used for testing.
Functions ¶
func AddGlobalFields ¶ added in v1.0.6
func AddGlobalFields(fields ...Field)
AddGlobalFields allows you to set fields that will automatically be appended to all messages.
func Requestify ¶
Requestify adds a unique key to the request (header) and uses it for logging.
func SetTraceErrSeverity ¶ added in v1.1.0
func SetTraceErrSeverity(s string)
SetTraceErrSeverity allows you to change the severity type for trace errors (default is "error").
Types ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func JsonString ¶ added in v1.0.5
func NullableString ¶
type LockedSyslogWriteSyncer ¶
LockedSyslogWriteSyncer logs to syslog as well as stdout.
func (*LockedSyslogWriteSyncer) Sync ¶
func (l *LockedSyslogWriteSyncer) Sync() error
type Token ¶
type Token interface {
Generate() string
}
Token is an interface for generating tokens for the middleware.
type WriteSyncer ¶
A WriteSyncer is an io.Writer that can also flush any buffered data. Note that *os.File (and thus, os.Stderr and os.Stdout) implement WriteSyncer.
func NewLockedSyslogWriteSyncer ¶
func NewLockedSyslogWriteSyncer(network, address, tag string) WriteSyncer
NewLockedSyslogWriteSyncer creates a new write syncer for syslog.
func NewLockedWriteSyncer ¶
func NewLockedWriteSyncer(ws WriteSyncer) WriteSyncer
Click to show internal directories.
Click to hide internal directories.