Documentation ¶
Index ¶
- Constants
- Variables
- func CustomPII(key, value string, resolveFunc CustomResolveFunc) *customPIIField
- func Debug(v ...any)
- func Debugf(format string, v ...any)
- func Debugw(msg string, keyValuePairs ...any)
- func Error(v ...any)
- func Errorf(format string, v ...any)
- func Errorw(msg string, keyValuePairs ...any)
- func Fatal(v ...any)
- func Fatalf(format string, v ...any)
- func Fatalw(msg string, keyValuePairs ...any)
- func Info(v ...any)
- func Infof(format string, v ...any)
- func Infow(msg string, keyValuePairs ...any)
- func PII(key, value string) *field
- func Sync() error
- func Warn(v ...any)
- func Warnf(format string, v ...any)
- func Warnw(msg string, keyValuePairs ...any)
- type Configuration
- type CustomResolveFunc
- type ILogger
- type KeyNames
- type Level
- type Logger
- func (l *Logger) Debug(v ...any)
- func (l *Logger) Debugf(format string, v ...any)
- func (l *Logger) Debugw(msg string, keyValuePairs ...any)
- func (l *Logger) Error(v ...any)
- func (l *Logger) Errorf(format string, v ...any)
- func (l *Logger) Errorw(msg string, keyValuePairs ...any)
- func (l *Logger) Fatal(v ...any)
- func (l *Logger) Fatalf(format string, v ...any)
- func (l *Logger) Fatalw(msg string, keyValuePairs ...any)
- func (l *Logger) Info(v ...any)
- func (l *Logger) Infof(format string, v ...any)
- func (l *Logger) Infow(msg string, keyValuePairs ...any)
- func (l *Logger) Sync() error
- func (l *Logger) Warn(v ...any)
- func (l *Logger) Warnf(format string, v ...any)
- func (l *Logger) Warnw(msg string, keyValuePairs ...any)
- func (l *Logger) With(keyValuePairs ...any) *Logger
- type OutputMode
- type PIIMode
- type PIIResolver
- type ResolvedPIIField
Constants ¶
const ( DebugLevel = Level(zapcore.DebugLevel) InfoLevel = Level(zapcore.InfoLevel) WarnLevel = Level(zapcore.WarnLevel) ErrorLevel = Level(zapcore.ErrorLevel) PanicLevel = Level(zapcore.PanicLevel) FatalLevel = Level(zapcore.FatalLevel) )
Variables ¶
var ( // MaskFunc gets called on PII resolvers, when PII mode "mask" is chosen. // The function shall be thread-safe. When no function is provided, but // the mask PII mode is chosen, any PII fields will be omitted. MaskFunc func(key, value string) ResolvedPIIField )
Functions ¶
func CustomPII ¶
func CustomPII(key, value string, resolveFunc CustomResolveFunc) *customPIIField
CustomPII is used to create a PII field with a custom resolve function of type CustomResolveFunc. When the field gets logged the actual PII shall be handled appropriately by the custom function based on the given PII mode from the logger. The custom resolve function shall be thread-safe.
func Fatal ¶
func Fatal(v ...any)
Fatal logs all inputs on the fatal level and runs os.exit(1) at the end.
func PII ¶
func PII(key, value string) *field
PII is used to create standard PII field. When the field gets logged the actual PII is handled based on the current PII mode of the logger.
Types ¶
type Configuration ¶
type Configuration struct { // ApplicationName holds the value for the "app" field in log // statements indicating the name of the current application. // If the value is set to "", the field will be omitted. ApplicationName string // Version holds the value for the "version" field in log // statements indicating the version of the current application. // If the value is set to "", the field will be omitted. Version string // MinimumLogLevel sets the minim level of logs that will get // logged by the respective logger. The DebugLevel is the lowest // while the FatalLevel is the highest. If set to Debug, everything // will be logged, while when set to Fatal, only Fatal statements // will be logged. MinimumLogLevel Level // PIIMode indicates how to the logger resolves PII fields in log // statements. PIIMode PIIMode // OutputMode indicates where the logs will be written. Logs can // either be published to stdout, stderr or split between the two. OutputMode OutputMode // KeyNames lets you overwrite the standard key names for common // log fields. KeyNames KeyNames }
Configuration represents a Configuration object for a logger.
type CustomResolveFunc ¶
type CustomResolveFunc func(mode PIIMode, key, value string) ResolvedPIIField
The CustomResolveFunc is passed to the CustomPII function of this package to handle the PII resolution in a customised way before a specific field gets logged.
type ILogger ¶ added in v1.1.0
type ILogger interface { Debug(v ...any) Debugf(format string, v ...any) Debugw(msg string, keyValuePairs ...any) Error(v ...any) Errorf(format string, v ...any) Errorw(msg string, keyValuePairs ...any) Fatal(v ...any) Fatalf(format string, v ...any) Fatalw(msg string, keyValuePairs ...any) Info(v ...any) Infof(format string, v ...any) Infow(msg string, keyValuePairs ...any) Sync() error Warn(v ...any) Warnf(format string, v ...any) Warnw(msg string, keyValuePairs ...any) With(keyValuePairs ...any) *Logger }
type Level ¶
Level specifies a log level. Usually it is used to indicate the minimum log level for a logger.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
The Logger struct resembles the actual loggers.
func MustNewLogger ¶
func MustNewLogger(c Configuration) *Logger
MustNewLogger wraps NewLogger and panics, when an error is encountered.
func NewLogger ¶
func NewLogger(conf Configuration) (*Logger, error)
NewLogger creates a new logger based on the configuration inputs and returns a pointer to it. If the validation of the input configuration fails an error will be issued.
func NewNOPLogger ¶
func NewNOPLogger() *Logger
NewNOPLogger creates a new no-operation logger that does not write any log statements anywhere and is therefore tremendously helpful, when you need to fulfill the Interface, but you don't want to actually log anything.
func (*Logger) Fatalf ¶
Fatalf formats and logs all inputs on the fatal level and runs os.exit(1) at the end.
func (*Logger) Fatalw ¶
Fatalw logs all inputs and fields on the fatal level and runs os.exit(1) at the end.
type OutputMode ¶ added in v1.2.0
type OutputMode uint8
const ( OutputStdOut OutputMode = 0 OutputStdOutAndStdErr OutputMode = 1 OutputStdErr OutputMode = 2 )
type PIIMode ¶
type PIIMode uint8
PIIMode indicates how to resolve PII fields in log statements.
const ( // PIIModeNone indicates that PII fields shall be left as is. PIIModeNone PIIMode = 0 // PIIModeHash indicates that the value part of a PII field shall // be hashed (SHA256). The key of the field stays untouched. PIIModeHash PIIMode = 1 // PIIModeMask indicates that the value part of a PII field shall // be masked. If this mode is selected a mask function needs to be // provided under the MaskFunc property of this package. If no // MaskFunc is provided, PII fields will be omitted in the logs // using this mode. PIIModeMask PIIMode = 2 // PIIModeRemove indicates that PII fields shall be omitted // completely from the final logs. PIIModeRemove PIIMode = 3 )
type PIIResolver ¶
type PIIResolver interface {
// contains filtered or unexported methods
}
The PIIResolver interface is what the logger checks against, when trying to resolve PII fields in log statements before writing the logs.