logger

package
v0.8.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHCLogger added in v0.0.4

func NewHCLogger(log *zerolog.Logger) hclog.Logger

NewHCLogger creates a HCLogger

func NewLogger

func NewLogger(logOutput Writer, errorOutput ErrWriter, cfg *Config) (*zerolog.Logger, error)

NewLogger returns a new logger

func NewSTDLogger

func NewSTDLogger(logger *zerolog.Logger) *log.Logger

NewSTDLogger creates a standard logger that writes to a zerolog logger

func TestLogger

func TestLogger(logOutput io.Writer) *zerolog.Logger

TestLogger creates a logger useful for unit tests it has a trace level

Types

type Config

type Config struct {
	Prod           bool          `json:"prod"`
	LogLevelParsed zerolog.Level `json:"-"`
	LogLevel       string        `json:"log_level"`
}

Config represents logging configuration

func (*Config) ParseLogLevel

func (c *Config) ParseLogLevel(defaultLevel zerolog.Level) error

ParseLogLevel parses the log level in the config and sets the appropriate value for `LogLevelParsed`.

type ErrWriter added in v0.2.5

type ErrWriter io.Writer

type GRPCZeroLogger

type GRPCZeroLogger struct {
	// contains filtered or unexported fields
}

GRPCZeroLogger is a GRPC logger that uses zerolog

func NewGRPCZeroLogger

func NewGRPCZeroLogger(log *zerolog.Logger) GRPCZeroLogger

NewGRPCZeroLogger creates a GRPCZeroLogger

func (GRPCZeroLogger) Error

func (l GRPCZeroLogger) Error(args ...interface{})

Error logs an error message

func (GRPCZeroLogger) Errorf

func (l GRPCZeroLogger) Errorf(format string, args ...interface{})

Errorf formats and logs an error message

func (GRPCZeroLogger) Errorln

func (l GRPCZeroLogger) Errorln(args ...interface{})

Errorln logs an error message and a newline

func (GRPCZeroLogger) Fatal

func (l GRPCZeroLogger) Fatal(args ...interface{})

Fatal logs a fatal message

func (GRPCZeroLogger) Fatalf

func (l GRPCZeroLogger) Fatalf(format string, args ...interface{})

Fatalf formats and logs a fatal message

func (GRPCZeroLogger) Fatalln

func (l GRPCZeroLogger) Fatalln(args ...interface{})

Fatalln logs a fatal message and a newline

func (GRPCZeroLogger) Info

func (l GRPCZeroLogger) Info(args ...interface{})

Info logs an info message

func (GRPCZeroLogger) Infof

func (l GRPCZeroLogger) Infof(format string, args ...interface{})

Infof formats and logs an info message

func (GRPCZeroLogger) Infoln

func (l GRPCZeroLogger) Infoln(args ...interface{})

Infoln formats and logs an info message and a newline

func (GRPCZeroLogger) Print

func (l GRPCZeroLogger) Print(args ...interface{})

Print prints a message

func (GRPCZeroLogger) Printf

func (l GRPCZeroLogger) Printf(format string, args ...interface{})

Printf formats and prints a message

func (GRPCZeroLogger) Println

func (l GRPCZeroLogger) Println(args ...interface{})

Println prints a message and a newline

func (GRPCZeroLogger) V

func (l GRPCZeroLogger) V(level int) bool

V always returns true

func (GRPCZeroLogger) Warning

func (l GRPCZeroLogger) Warning(args ...interface{})

Warning logs a warning message

func (GRPCZeroLogger) Warningf

func (l GRPCZeroLogger) Warningf(format string, args ...interface{})

Warningf formats and logs a warning message

func (GRPCZeroLogger) Warningln

func (l GRPCZeroLogger) Warningln(args ...interface{})

Warningln formats and logs a warning message and a newline

type HCLogger added in v0.0.4

type HCLogger struct {
	// contains filtered or unexported fields
}

HCLogger is a HC logger that uses zerolog

func (*HCLogger) Debug added in v0.0.4

func (l *HCLogger) Debug(msg string, args ...interface{})

Emit a message and key/value pairs at the DEBUG level

func (*HCLogger) Error added in v0.0.4

func (l *HCLogger) Error(msg string, args ...interface{})

Emit a message and key/value pairs at the ERROR level

func (*HCLogger) ImpliedArgs added in v0.0.4

func (l *HCLogger) ImpliedArgs() []interface{}

ImpliedArgs returns With key/value pairs

func (*HCLogger) Info added in v0.0.4

func (l *HCLogger) Info(msg string, args ...interface{})

Emit a message and key/value pairs at the INFO level

func (*HCLogger) IsDebug added in v0.0.4

func (l *HCLogger) IsDebug() bool

Indicate if DEBUG logs would be emitted. This and the other Is* guards

func (*HCLogger) IsError added in v0.0.4

func (l *HCLogger) IsError() bool

Indicate if ERROR logs would be emitted. This and the other Is* guards

func (*HCLogger) IsInfo added in v0.0.4

func (l *HCLogger) IsInfo() bool

Indicate if INFO logs would be emitted. This and the other Is* guards

func (*HCLogger) IsTrace added in v0.0.4

func (l *HCLogger) IsTrace() bool

Indicate if TRACE logs would be emitted. This and the other Is* guards are used to elide expensive logging code based on the current level.

func (*HCLogger) IsWarn added in v0.0.4

func (l *HCLogger) IsWarn() bool

Indicate if WARN logs would be emitted. This and the other Is* guards

func (*HCLogger) Log added in v0.0.4

func (l *HCLogger) Log(level hclog.Level, msg string, args ...interface{})

Emit a message and key/value pairs at a provided log level

func (*HCLogger) Name added in v0.0.4

func (l *HCLogger) Name() string

Returns the Name of the logger

func (*HCLogger) Named added in v0.0.4

func (l *HCLogger) Named(name string) hclog.Logger

Create a logger that will prepend the name string on the front of all messages. If the logger already has a name, the new value will be appended to the current name. That way, a major subsystem can use this to decorate all it's own logs without losing context.

func (*HCLogger) ResetNamed added in v0.0.4

func (l *HCLogger) ResetNamed(name string) hclog.Logger

Create a logger that will prepend the name string on the front of all messages. This sets the name of the logger to the value directly, unlike Named which honor the current name as well.

func (*HCLogger) SetLevel added in v0.0.4

func (l *HCLogger) SetLevel(level hclog.Level)

Updates the level. This should affect all related loggers as well, unless they were created with IndependentLevels. If an implementation cannot update the level on the fly, it should no-op.

func (*HCLogger) StandardLogger added in v0.0.4

func (l *HCLogger) StandardLogger(opts *hclog.StandardLoggerOptions) *log.Logger

Return a value that conforms to the stdlib log.Logger interface

func (*HCLogger) StandardWriter added in v0.0.4

func (l *HCLogger) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writer

Return a value that conforms to io.Writer, which can be passed into log.SetOutput()

func (*HCLogger) Trace added in v0.0.4

func (l *HCLogger) Trace(msg string, args ...interface{})

Emit a message and key/value pairs at the TRACE level

func (*HCLogger) Warn added in v0.0.4

func (l *HCLogger) Warn(msg string, args ...interface{})

Emit a message and key/value pairs at the WARN level

func (*HCLogger) With added in v0.0.4

func (l *HCLogger) With(args ...interface{}) hclog.Logger

Creates a sublogger that will always have the given key/value pairs

type LevelWriter added in v0.2.4

type LevelWriter struct {
	io.Writer
	ErrorWriter io.Writer
}

func (*LevelWriter) WriteLevel added in v0.2.4

func (lw *LevelWriter) WriteLevel(l zerolog.Level, p []byte) (n int, err error)

type OpaLogger added in v0.2.3

type OpaLogger struct {
	// contains filtered or unexported fields
}

func NewOpaLogger added in v0.2.3

func NewOpaLogger(logger *zerolog.Logger) *OpaLogger

func (*OpaLogger) Debug added in v0.2.3

func (l *OpaLogger) Debug(fmt string, a ...interface{})

func (*OpaLogger) Error added in v0.2.3

func (l *OpaLogger) Error(fmt string, a ...interface{})

func (*OpaLogger) GetFields added in v0.2.3

func (l *OpaLogger) GetFields() map[string]interface{}

func (*OpaLogger) GetLevel added in v0.2.3

func (l *OpaLogger) GetLevel() logging.Level

func (*OpaLogger) Info added in v0.2.3

func (l *OpaLogger) Info(fmt string, a ...interface{})

func (*OpaLogger) SetLevel added in v0.2.3

func (l *OpaLogger) SetLevel(level logging.Level)

func (*OpaLogger) Warn added in v0.2.3

func (l *OpaLogger) Warn(fmt string, a ...interface{})

func (*OpaLogger) WithFields added in v0.2.3

func (l *OpaLogger) WithFields(fields map[string]interface{}) logging.Logger

type Writer added in v0.2.5

type Writer io.Writer

type ZerologWriter

type ZerologWriter struct {
	// contains filtered or unexported fields
}

ZerologWriter implements io.Writer for a zerolog logger

func NewZerologWriter

func NewZerologWriter(logger *zerolog.Logger) *ZerologWriter

NewZerologWriter creates a new ZerologWriter

func NewZerologWriterWithLevel added in v0.2.10

func NewZerologWriterWithLevel(logger *zerolog.Logger, level zerolog.Level) *ZerologWriter

func (*ZerologWriter) Write

func (z *ZerologWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL