micrologger: github.com/giantswarm/micrologger Index | Files | Directories

package micrologger

import "github.com/giantswarm/micrologger"

Package logger implements a logging interface used to log messages.


Package Files

activation_logger.go default.go error.go logger.go spec.go


const (
    KeyLevel     = "level"
    KeyVerbosity = "verbosity"


var DefaultCaller = func() interface{} {
    return fmt.Sprintf("%+v", stack.Caller(4))
var DefaultIOWriter = os.Stdout
var DefaultTimestampFormatter = func() interface{} {
    return time.Now().UTC().Format("2006-01-02T15:04:05.999999-07:00")

func IsInvalidConfig Uses

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

type ActivationLoggerConfig Uses

type ActivationLoggerConfig struct {
    Underlying Logger

    Activations map[string]interface{}

type Config Uses

type Config struct {
    Caller             kitlog.Valuer
    IOWriter           io.Writer
    TimestampFormatter kitlog.Valuer

type Logger Uses

type Logger interface {
    // Log takes a sequence of alternating key/value pairs which are used
    // to create the log message structure.
    Log(keyVals ...interface{})
    // LogCtx is the same as Log but additionally taking a context which
    // may contain additional key-value pairs that are added to the log
    // issuance, if any.
    LogCtx(ctx context.Context, keyVals ...interface{})
    // With returns a new contextual logger with keyVals appended to those
    // passed to calls to Log. If logger is also a contextual logger
    // created by With, keyVals is appended to the existing context.
    With(keyVals ...interface{}) Logger

Logger is a simple interface describing services that emit messages to gather certain runtime information.

func NewActivation Uses

func NewActivation(config ActivationLoggerConfig) (Logger, error)

NewActivation creates a new activation key logger. This logger kind can be used on command line tools to improve situations in which log filtering using other command line tools like grep is not sufficient. Due to certain filter mechanisms this Logger implementation should not be used in performance critical applications. The idea of the activation key logger is to have a multi dimensional log filter mechanism. This logger here provides three different features which can be combined and used simultaneously at will.

Filtering arbitrary key-value pairs. The structured nature of the Logger
interface expects key-value pairs to be logged. The activation key logger
can be configured with any kind of activation key-pairs which, when
configured, all have to match against an emitted logging call, in order
to be dispatched. In case none, or not all activation keys match, the
emitted logging call is going to be ignored.

Filtering log levels works using the special log levels debug, info,
warning and error. The level based nature of this activation mechanism is
that lower log levels match just like exact log levels match. When the
Logger is configured to activate on info log levels, the Logger will
activate on debug related logs, as well as info related logs, but not on
warning or error related logs.

Filtering log verbosity works similar like the log level mechanism, but
on arbitrary verbosity levels, which are represented as numbers. As long
as the configured verbosity is higher or equal to the perceived verbosity
obtained by the emitted logging call, the log will be dispatched.

type MicroLogger Uses

type MicroLogger struct {
    // contains filtered or unexported fields

func New Uses

func New(config Config) (*MicroLogger, error)

func (*MicroLogger) Log Uses

func (l *MicroLogger) Log(keyVals ...interface{})

func (*MicroLogger) LogCtx Uses

func (l *MicroLogger) LogCtx(ctx context.Context, keyVals ...interface{})

func (*MicroLogger) With Uses

func (l *MicroLogger) With(keyVals ...interface{}) Logger


loggermetaPackage loggermeta stores and accesses the container struct in context.Context.

Package micrologger imports 11 packages (graph) and is imported by 382 packages. Updated 2020-05-25. Refresh now. Tools for package owners.