modulepackage
1.1.0
Repository: https://github.com/weaveworks/policy-agent.git
Documentation: pkg.go.dev
# README
Logger
- a wrapper over
uber/zap
logger - There are 4 levels that can be used; info, error, debug, and warning.
Usage
It's usually not ideal to pass logger
instance across you application, this can be seen as unnecessary pollution. That's why global logger is provided by default with Info
as its default log level.
import "github.com/weaveworks/policy-agent/pkg/logger"
logger.Info("this is a log")
Change log level
To change the log level of the global logger you can simply use the Config
function
import "github.com/weaveworks/policy-agent/pkg/logger"
logger.Config(logger.DebugLevel)
logger.Debug("this is a debug log")
Create Custom logger
sometimes a custom logger is ideal. For example creating a logger that have request-id
on all the logs. you can create custom logger by using With
or New
function
import "github.com/weaveworks/policy-agent/pkg/logger"
// using with will have the global logger log level
customLogger := logger.With("requestId", reqID)
customLogger.Info("this is a debug log")
l := logger.New(logger.DebugLevel)
l.Debug("this is a debug log")
# Functions
Config sets configurations for global logger.
ConfigWriterSync sets configurations for global logger.
Debug uses fmt.Sprint to construct and log a message.
Debugf uses fmt.Sprintf to log a templated message.
Debugw logs a message with some additional context.
DPanic uses fmt.Sprint to construct and log a message.
DPanicf uses fmt.Sprintf to log a templated message.
DPanicw logs a message with some additional context.
Error uses fmt.Sprint to construct and log a message.
Errorf uses fmt.Sprintf to log a templated message.
Errorw logs a message with some additional context.
Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.
Fatalw logs a message with some additional context, then calls os.Exit.
Info uses fmt.Sprint to construct and log a message.
Infof uses fmt.Sprintf to log a templated message.
Infow logs a message with some additional context.
No description provided by the author
No description provided by the author
Panic uses fmt.Sprint to construct and log a message, then panics.
Panicf uses fmt.Sprintf to log a templated message, then panics.
Panicw logs a message with some additional context, then panics.
Print uses fmt.Sprint to construct and log a message.
Infof uses fmt.Sprintf to log a templated message.
Println uses fmt.Sprint to construct and log a message.
Sync flushes any buffered log entries.
Warn uses fmt.Sprint to construct and log a message.
Warnf uses fmt.Sprintf to log a templated message.
Warnw logs a message with some additional context.
With adds a variadic number of fields to the logging context.
WithGlobal adds a variadic number of fields to the logging context.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author