log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 3 Imported by: 13

Documentation

Overview

Package log provides an interface to setup logging when using 'tools-common'.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaskAndUserTagArguments

func MaskAndUserTagArguments(args, flagsToTag, flagsToMask []string) string

MaskAndUserTagArguments is a convenient way of calling both UserTagArguments and MaskArguments on the given data. It will return the resulting string slice joined with a space between element for easy logging.

func MaskAndUserTagCBMArguments

func MaskAndUserTagCBMArguments(args []string) string

func MaskArguments

func MaskArguments(args, flagsToMask []string) []string

MaskArguments returns a new slice with the values of the flags given in flagsToMask replaced by a fix number of *.

func MaskCBMArguments

func MaskCBMArguments(args []string) []string

func UserTagArguments

func UserTagArguments(args, flagsToTag []string) []string

UserTagArguments returns a new slice with the values for the flags given in flagsToTag surrounded by the <ud></ud> tags.

func UserTagCBMArguments

func UserTagCBMArguments(args []string) []string

Types

type Level

type Level uint8

Level is a type alias which is used to indicate the verbosity of an log statement.

const (
	// LevelTrace is the most verbose log level including finer grained informational events than debug level.
	LevelTrace Level = iota

	// LevelDebug includes fine-grained informational events that are the most useful to debug the library.
	LevelDebug

	// LevelInfo includes informational messages that highlight the progress of events in the library at a
	// course-grained level.
	LevelInfo

	// LevelWarning includes expected but potentially harmful/interesting events.
	LevelWarning

	// LevelError includes error events which may still allow the library to continue running.
	LevelError

	// LevelPanic includes errors events which should lead to a panic. This level will only be used in the most severe
	// of cases.
	LevelPanic
)

type Logger

type Logger interface {
	Log(level Level, format string, args ...any)
}

Logger interface which allows applications to provide custom logger implementations.

type StdoutLogger

type StdoutLogger struct{}

StdoutLogger is the standard output logger for printing all logs into the commandline.

func (StdoutLogger) Log

func (s StdoutLogger) Log(level Level, msg string, args ...any)

Log method for the StdoutLogger which adds prefix dependant on the level and prints message inputted to terminal.

type WrappedLogger

type WrappedLogger struct {
	Logger
}

WrappedLogger is the internally used Logger struct that implements Logger and defines varous methods for different levels of logging, eg: trace, debug, info, etc.

func NewWrappedLogger

func NewWrappedLogger(logger Logger) WrappedLogger

NewWrappedLogger returns a WrappedLogger for a given inputted Logger. If logger is nil then assign the nopLogger.

func (*WrappedLogger) Debugf

func (w *WrappedLogger) Debugf(format string, args ...any)

Debugf logs the provided information at the debug level.

func (*WrappedLogger) Errorf

func (w *WrappedLogger) Errorf(format string, args ...any)

Errorf logs the provided information at the error level.

func (*WrappedLogger) Infof

func (w *WrappedLogger) Infof(format string, args ...any)

Infof logs the provided information at the info level.

func (*WrappedLogger) Panicf

func (w *WrappedLogger) Panicf(format string, args ...any)

Panicf logs the provided information at the panic level.

func (*WrappedLogger) Tracef

func (w *WrappedLogger) Tracef(format string, args ...any)

Tracef logs the provided information at the trace level.

func (*WrappedLogger) Warnf

func (w *WrappedLogger) Warnf(format string, args ...any)

Warnf logs the provided information at the warn level.

Jump to

Keyboard shortcuts

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