Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseLogError ¶
func CloseLogError(closer io.Closer, logger commontypes.Logger, msg string)
Closes closer. If an error occurs, it is logged at WARN level together with msg
func MergeOverwrite ¶
func MergeOverwrite(upserts ...commontypes.LogFields) commontypes.LogFields
MergeOverwrite will create a new LogFields and add all the properties from upserts on it. Key conflicts are resolved by preferring the upserted value.
func MergePreserve ¶
func MergePreserve(extras ...commontypes.LogFields) commontypes.LogFields
MergePreserve will create a new LogFields and add all the properties from extras on it. Key conflicts are resolved by prefixing the key for the new value with underscores until there's no conflict.
Types ¶
type IfNotStopped ¶
type IfNotStopped struct {
// contains filtered or unexported fields
}
func NewIfNotStopped ¶
func NewIfNotStopped(d time.Duration, f func()) *IfNotStopped
If Stop is called prior to expiry of d, f won't be executed. Otherwise, f will be executed and Stop will block until f returns. That makes it different from the standard library's time.AfterFunc() whose Stop() function will return while f is still running.
func (*IfNotStopped) Stop ¶
func (ins *IfNotStopped) Stop()
type LogarithmicTaper ¶
type LogarithmicTaper struct {
// contains filtered or unexported fields
}
LogarithmicTaper provides logarithmic tapering of an event sequence. For example, if the taper is Triggered 50 times with a function that simply prints the provided count, the output would be 1,2,4,8,16,32.
func (*LogarithmicTaper) Count ¶
func (tap *LogarithmicTaper) Count() uint64
Count returns the internal count of the taper
func (*LogarithmicTaper) Reset ¶
func (tap *LogarithmicTaper) Reset(f func(oldCount uint64))
Reset resets the count to 0 and then calls f with the previous count iff it wasn't already 0
func (*LogarithmicTaper) Trigger ¶
func (tap *LogarithmicTaper) Trigger(f func(newCount uint64))
Trigger increments a count and calls f iff the new count is a power of two
type LoggerWithContext ¶
type LoggerWithContext interface { commontypes.Logger MakeChild(extraContext commontypes.LogFields) LoggerWithContext MakeUpdated(updatedContext commontypes.LogFields) LoggerWithContext ErrorIfNotCanceled(msg string, ctx context.Context, fields commontypes.LogFields) }
func MakeRootLoggerWithContext ¶
func MakeRootLoggerWithContext(logger commontypes.Logger) LoggerWithContext
MakeRootLoggerWithContext creates a base logger by wrapping a commontypes.Logger. NOTE! Most loggers should extend an existing LoggerWithContext using MakeChild!