Documentation
¶
Index ¶
- Variables
- type Config
- type ConfigModifier
- type Log
- func (l *Log) Alert() *LogLine
- func (l *Log) Boring()
- func (l *Log) Config() Config
- func (l *Log) Debug() *LogLine
- func (l *Log) Done()
- func (l *Log) Error() *LogLine
- func (l *Log) Flush()
- func (l *Log) Fork(msg string, mods ...SeedModifier) *Log
- func (l *Log) Info() *LogLine
- func (l *Log) IntoContext(ctx context.Context) context.Context
- func (l *Log) LogLine(level xopconst.Level) *LogLine
- func (l *Log) Request() *Span
- func (l *Log) Span() *Span
- func (l *Log) Step(msg string, mods ...SeedModifier) *Log
- func (l *Log) Trace() *LogLine
- func (l *Log) Wait() *Log
- func (l *Log) Warn() *LogLine
- type LogLine
- func (ll *LogLine) Any(k string, v interface{}) *LogLine
- func (ll *LogLine) AnyImmutable(k string, v interface{}) *LogLine
- func (ll *LogLine) Bool(k string, v bool) *LogLine
- func (ll *LogLine) Duration(k string, v time.Duration) *LogLine
- func (ll *LogLine) EmbeddedEnum(k xopconst.EmbeddedEnum) *LogLine
- func (ll *LogLine) Enum(k *xopconst.EnumAttribute, v xopconst.Enum) *LogLine
- func (ll *LogLine) Error(k string, v error) *LogLine
- func (ll *LogLine) Int(k string, v int) *LogLine
- func (ll *LogLine) Int8(k string, v int8) *LogLine
- func (ll *LogLine) Int16(k string, v int16) *LogLine
- func (ll *LogLine) Int32(k string, v int32) *LogLine
- func (ll *LogLine) Int64(k string, v int64) *LogLine
- func (ll *LogLine) Link(k string, v trace.Trace) *LogLine
- func (ll *LogLine) Msg(msg string)
- func (ll *LogLine) Msgf(msg string, v ...interface{})
- func (ll *LogLine) Msgs(v ...interface{})
- func (ll *LogLine) Str(k string, v string) *LogLine
- func (ll *LogLine) Template(template string)
- func (ll *LogLine) Time(k string, v time.Time) *LogLine
- func (ll *LogLine) Uint(k string, v uint) *LogLine
- func (ll *LogLine) Uint8(k string, v uint8) *LogLine
- func (ll *LogLine) Uint16(k string, v uint16) *LogLine
- func (ll *LogLine) Uint32(k string, v uint32) *LogLine
- func (ll *LogLine) Uint64(k string, v uint64) *LogLine
- type Seed
- type SeedModifier
- func WithAnyPrefill(k string, v interface{}) SeedModifier
- func WithB3(b bool) SeedModifier
- func WithBaseLogger(name string, logger xopbase.Logger) SeedModifier
- func WithBoolPrefill(k string, v bool) SeedModifier
- func WithBundle(bundle trace.Bundle) SeedModifier
- func WithConfig(config Config) SeedModifier
- func WithConfigChanges(mods ...ConfigModifier) SeedModifier
- func WithDurationPrefill(k string, v time.Duration) SeedModifier
- func WithErrorPrefill(k string, v error) SeedModifier
- func WithFlushDelay(d time.Duration) SeedModifier
- func WithIntPrefill(k string, v int64) SeedModifier
- func WithLinkPrefill(k string, v trace.Trace) SeedModifier
- func WithNoPrefill() SeedModifier
- func WithPrefillText(m string) SeedModifier
- func WithStrPrefill(k string, v string) SeedModifier
- func WithTimePrefill(k string, v time.Time) SeedModifier
- func WithTrace(trace trace.Trace) SeedModifier
- func WithUintPrefill(k string, v uint64) SeedModifier
- func WithoutBaseLogger(name string) SeedModifier
- type Span
- func (s *Span) Any(k *xopconst.AnyAttribute, v interface{}) *Span
- func (s *Span) AnyImmutable(k *xopconst.AnyAttribute, v interface{}) *Span
- func (s *Span) Bool(k *xopconst.BoolAttribute, v bool) *Span
- func (s *Span) Bundle() trace.Bundle
- func (s *Span) Duration(k *xopconst.DurationAttribute, v time.Duration) *Span
- func (s *Span) EmbeddedEnum(kv xopconst.EmbeddedEnum) *Span
- func (s *Span) Enum(k *xopconst.EnumAttribute, v xopconst.Enum) *Span
- func (s *Span) Int(k *xopconst.IntAttribute, v int) *Span
- func (s *Span) Int8(k *xopconst.Int8Attribute, v int8) *Span
- func (s *Span) Int16(k *xopconst.Int16Attribute, v int16) *Span
- func (s *Span) Int32(k *xopconst.Int32Attribute, v int32) *Span
- func (s *Span) Int64(k *xopconst.Int64Attribute, v int64) *Span
- func (s *Span) Link(k *xopconst.LinkAttribute, v trace.Trace) *Span
- func (s *Span) Number(k *xopconst.NumberAttribute, v float64) *Span
- func (s *Span) Seed(mods ...SeedModifier) Seed
- func (s *Span) Str(k *xopconst.StrAttribute, v string) *Span
- func (s *Span) Time(k *xopconst.TimeAttribute, v time.Time) *Span
- func (s *Span) Trace() trace.Trace
- func (s *Span) TraceBaggage() trace.Baggage
- func (s *Span) TraceParent() trace.Trace
- func (s *Span) TraceState() trace.State
Constants ¶
This section is empty.
Variables ¶
var Default = NewSeed().Request("discard")
TODO: have a default log that prints
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
UseB3 bool // Zipkin
FlushDelay time.Duration
// ErrorReporter provides a way to choose the behavior
// for when underlying log functions throw an error.
// Generally speaking, needing to check errors when
// generating logs is a non-starter because the cost is
// too high. It would discourage logging. That said,
// there is a an error, we don't want to completely
// ignore it.
//
// TODO: If ErrorReporter is called too frequently,
// it will automatically be throttled
ErrorReporter func(error)
}
type ConfigModifier ¶
type ConfigModifier func(*Config)
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
func FromContextOrDefault ¶
func FromContextOrPanic ¶
func (*Log) Boring ¶
func (l *Log) Boring()
Marks this request as boring. Any log at the Alert or Error level will mark this request as not boring.
func (*Log) Done ¶
func (l *Log) Done()
Done is used to indicate that a seed.Reqeust(), log.Fork().Wait(), or log.Step().Wait() is done. When all of the parts of a request are finished, the log is automatically flushed.
func (*Log) Fork ¶
func (l *Log) Fork(msg string, mods ...SeedModifier) *Log
Fork creates a new Log that does not need to be terminated because it is assumed to be done with the current log is finished.
func (*Log) Request ¶
Request provides access to the span that describes the overall request. Metadata may be added at the request level.
func (*Log) Span ¶
Request provides access to the current span Metadata may be added at the span level.
func (*Log) Step ¶
func (l *Log) Step(msg string, mods ...SeedModifier) *Log
Step creates a new log that does not need to be terminated -- it represents the continued execution of the current log bug doing something that is different and should be in a fresh span. The expectation is that there is a parent log that is creating various sub-logs using Step over and over as it does different things.
type LogLine ¶
type LogLine struct {
// contains filtered or unexported fields
}
func (*LogLine) Any ¶
Any can be used to log something that might be modified after this call. If any base logger does not immediately serialize, then the object will be copied using https://github.com/mohae/deepcopy 's Copy().
func (*LogLine) AnyImmutable ¶
AnyImmutable can be used to log something that is not going to be further modified after this call.
func (*LogLine) EmbeddedEnum ¶
func (ll *LogLine) EmbeddedEnum(k xopconst.EmbeddedEnum) *LogLine
func (*LogLine) Template ¶
Template is an alternative to Msg() sends a log line. Template is a string that uses "{name}" substitutions from the data already sent with the line to format that data for human consumption. Template is expected to be more expensive than Msg so it should be used somewhat sparingly. Data elements do not have to be consumed by the template.
The names used for "{name}" substitutions are restricted: they may not include any characters that would be escapsed in a JSON string. No double quote. No linefeed. No backslash. Etc.
type Seed ¶
type Seed struct {
// contains filtered or unexported fields
}
Seed is used to create a Log.
func NewSeed ¶
func NewSeed(mods ...SeedModifier) Seed
type SeedModifier ¶
type SeedModifier func(*Seed)
func WithAnyPrefill ¶
func WithAnyPrefill(k string, v interface{}) SeedModifier
WithAnyPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Any() to add a span-level key/value pair that is logged once (with the span).
func WithB3 ¶
func WithB3(b bool) SeedModifier
func WithBaseLogger ¶
func WithBaseLogger(name string, logger xopbase.Logger) SeedModifier
func WithBoolPrefill ¶
func WithBoolPrefill(k string, v bool) SeedModifier
WithBoolPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Bool() to add a span-level key/value pair that is logged once (with the span).
func WithBundle ¶
func WithBundle(bundle trace.Bundle) SeedModifier
func WithConfig ¶
func WithConfig(config Config) SeedModifier
func WithConfigChanges ¶
func WithConfigChanges(mods ...ConfigModifier) SeedModifier
func WithDurationPrefill ¶
func WithDurationPrefill(k string, v time.Duration) SeedModifier
WithDurationPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Duration() to add a span-level key/value pair that is logged once (with the span).
func WithErrorPrefill ¶
func WithErrorPrefill(k string, v error) SeedModifier
WithErrorPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Error() to add a span-level key/value pair that is logged once (with the span).
func WithFlushDelay ¶
func WithFlushDelay(d time.Duration) SeedModifier
func WithIntPrefill ¶
func WithIntPrefill(k string, v int64) SeedModifier
WithIntPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Int() to add a span-level key/value pair that is logged once (with the span).
func WithLinkPrefill ¶
func WithLinkPrefill(k string, v trace.Trace) SeedModifier
WithLinkPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Link() to add a span-level key/value pair that is logged once (with the span).
func WithNoPrefill ¶
func WithNoPrefill() SeedModifier
func WithPrefillText ¶
func WithPrefillText(m string) SeedModifier
func WithStrPrefill ¶
func WithStrPrefill(k string, v string) SeedModifier
WithStrPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Str() to add a span-level key/value pair that is logged once (with the span).
func WithTimePrefill ¶
func WithTimePrefill(k string, v time.Time) SeedModifier
WithTimePrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Time() to add a span-level key/value pair that is logged once (with the span).
func WithTrace ¶
func WithTrace(trace trace.Trace) SeedModifier
func WithUintPrefill ¶
func WithUintPrefill(k string, v uint64) SeedModifier
WithUintPrefill adds a key/value pair that will be included as part of every log line in this span. If there are no log lines in the span then this data will not be logged at all. Use Span.Uint() to add a span-level key/value pair that is logged once (with the span).
func WithoutBaseLogger ¶
func WithoutBaseLogger(name string) SeedModifier
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
func (*Span) Any ¶
func (s *Span) Any(k *xopconst.AnyAttribute, v interface{}) *Span
Any adds a key/value attribute to the current Span. The provided value may be copied using github.com/mohae/deepcopy if any of the base loggers hold the value instead of immediately serializing it. While the AnyAttribute has an expectation for the type of the value, that type may or may not be checked depending on the base logger being used.
func (*Span) AnyImmutable ¶
func (s *Span) AnyImmutable(k *xopconst.AnyAttribute, v interface{}) *Span
AnyImmutable adds a key/value attribute to the current Span. The provided value must be immutable. If it is not, then there could be race conditions or the value that ends up logged could be different from the value at the time when AnyImmutible was called.
While the AnyAttribute has an expectation for the type of the value, that type may or may not be checked depending on the base logger being used.
func (*Span) Bool ¶
func (s *Span) Bool(k *xopconst.BoolAttribute, v bool) *Span
Bool adds a bool key/value attribute to the current Span
func (*Span) Duration ¶
should skip Int64 Duration adds a time.Duration key/value attribute to the current Span
func (*Span) EmbeddedEnum ¶
func (s *Span) EmbeddedEnum(kv xopconst.EmbeddedEnum) *Span
EmbeddedEnum adds a kev/value attribute to the Span. The key and the value are bundled together: the key is derrived from the type of the Enum. Alternatively, use xopconst.KeyedEnumAttribute() to create functions to add enum key/value pairs where the key and value are specified separately.
func (*Span) Int ¶
func (s *Span) Int(k *xopconst.IntAttribute, v int) *Span
Int adds a int key/value attribute to the current Span
func (*Span) Int8 ¶
func (s *Span) Int8(k *xopconst.Int8Attribute, v int8) *Span
Int8 adds a int8 key/value attribute to the current Span
func (*Span) Int16 ¶
func (s *Span) Int16(k *xopconst.Int16Attribute, v int16) *Span
Int16 adds a int16 key/value attribute to the current Span
func (*Span) Int32 ¶
func (s *Span) Int32(k *xopconst.Int32Attribute, v int32) *Span
Int32 adds a int32 key/value attribute to the current Span
func (*Span) Number ¶
func (s *Span) Number(k *xopconst.NumberAttribute, v float64) *Span
Number adds a float64 key/value attribute to the current Span
func (*Span) Seed ¶
func (s *Span) Seed(mods ...SeedModifier) Seed
func (*Span) Str ¶
func (s *Span) Str(k *xopconst.StrAttribute, v string) *Span
Str adds a string key/value attribute to the current Span
