log

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package log contains the CLI logger, abstracting away any major detail about the underlying logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

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

Debug prints the msg, plus any additional even number of arguments, only if the log level is higher than debug

func Error

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

Error prints the msg, plus any additional even number of arguments, only if the log level is higher than error

func Info

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

Info prints the msg, plus any additional even number of arguments, only if the log level is higher than info

func SetLogger

func SetLogger(l LoggerI)

SetLogger sets the global logger

func Warn

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

Warn prints the msg, plus any additional even number of arguments, only if the log level is higher than warn

Types

type Encoding

type Encoding string

Encoding represents the possible formats for logs

const (
	// JSONEncoding should be used to set the log output to json format
	JSONEncoding Encoding = "json"
	// ConsoleEncoding should be used to set the log output to console format
	ConsoleEncoding Encoding = "console"
)

func (*Encoding) Set

func (e *Encoding) Set(s string) error

Set is needed to be able to parse it correctly as flag

func (*Encoding) String

func (e *Encoding) String() string

String is needed to be able to parse it correctly as flag

func (Encoding) Type

func (e Encoding) Type() string

Type is needed to be able to parse it correctly as flag

type Level

type Level struct {
	zapcore.Level
}

Level encodes the log level, can not be a type alias because we need to implement the same interfaces

func GetDefaultLevel

func GetDefaultLevel() Level

GetDefaultLevel returns the default log level

func (Level) Type

func (l Level) Type() string

Type returns "string" as type of the Level, required to correctly parse it

type Logger

type Logger struct {
	*zap.SugaredLogger
}

Logger is the actual logger

func DefaultLogger

func DefaultLogger(level Level, encoding Encoding) (*Logger, error)

DefaultLogger configures the logger, setting the given level

func (*Logger) Debug

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

Debug prints the msg, plus any additional even number of arguments, only if the log level is higher than debug

func (*Logger) Error

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

Error prints the msg, plus any additional even number of arguments, only if the log level is higher than error

func (*Logger) Info

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

Info prints the msg, plus any additional even number of arguments, only if the log level is higher than info

func (*Logger) Warn

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

Warn prints the msg, plus any additional even number of arguments, only if the log level is higher than warn

type LoggerI

type LoggerI interface {
	Debug(string, ...interface{})
	Info(string, ...interface{})
	Warn(string, ...interface{})
	Error(string, ...interface{})
}

LoggerI abstracts the logger

Jump to

Keyboard shortcuts

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