Categorygithub.com/edwarnicke/log
modulepackage
1.0.0
Repository: https://github.com/edwarnicke/log.git
Documentation: pkg.go.dev

# README

log is a simple logrus helper to allow attaching a logrus.Entry to a context.Context.

// Create a ctx that carries a logrus.Entry with field "cmd" indicating the executable being run
ctx := log.WithField(ctx, "cmd", os.Args[0])
ctx = log.WithFields(ctx,WithFields(parent, 
            logrus.Fields{
                "pid": os.Getpid(),
                "uid": os.Getuid(),
            },
       )
// Log with the Entry from the ctx
log.Entry(ctx).Info("Informational log")

# Functions

Entry
Entry - returns *logrus.Entry for context.
WithField - return new context with {key:value} added to Context's logrus.Entry.
WithFields - return new context with fields added to Context's logrus.Entry.