cliolog

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// SuccessName is a designated logging name which prints
	// messages with a [✔] symbol rather than their regular
	// log level.
	SuccessName = "clio.success"

	// NoPrefixName is a designated logging name which prints
	// messages without a prefix.
	NoPrefixName = "clio.noprefix"
)

Variables

This section is empty.

Functions

func New

func New(level zap.AtomicLevel, opts ...func(*Options)) *zap.Logger

New returns a CLI-friendly zap logger which prints to stderr by default.

func NewConsoleEncoder

func NewConsoleEncoder(cfg *zapcore.EncoderConfig, noColor *bool) zapcore.Encoder

NewConsoleEncoder creates an encoder whose output is designed for human - rather than machine - consumption. It serializes the core log entry data (message, level, timestamp, etc.) in a plain-text format. The context is encoded in LTSV.

Note that although the console encoder doesn't use the keys specified in the encoder configuration, it will omit any element whose key is set to the empty string.

func SymbolLevelEncoder

func SymbolLevelEncoder(l zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

SymbolLevelEncoder serializes a Level to a symbol. The mapping is as follows:

INFO: [i] ERROR: [✘] WARN: [!] DEBUG: [DEBUG]

func WithFileLogger added in v1.2.0

func WithFileLogger(cfg FileLoggerConfig) func(*Options)

WithFileLogger will write logs to a file using lumberjack package in addition to printing it in console.

func WithNoColor

func WithNoColor(noColor *bool) func(*Options)

WithNoColor sets up a colorization bypass.

func WithWriter

func WithWriter(w io.Writer) func(*Options)

WithWriter specifies an io.Writer to write logs to.

Types

type FileLoggerConfig added in v1.2.0

type FileLoggerConfig struct {
	// Name of your log file
	Filename string
	// Maximum size of the log file in MB before it gets rotated.
	// If set to 0 the default max size is used (1 MB)
	MaxSize int
	// Maximum number of old log files to retain.
	// If set to 0 the default is 30
	MaxBackups int
	// Maximum number of days to retain old log files based on the timestamp encoded in their filename.
	// If set to 0 the default is 90 days
	MaxAge int

	// ShouldCompress if set to true will compress the rotated log files using gzip.
	ShouldCompress bool
}

type Options

type Options struct {
	Writer          io.Writer
	NoColor         *bool
	FileWriteSyncer *zapcore.WriteSyncer
}

Jump to

Keyboard shortcuts

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