logs

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileMode

type FileMode string

FileMode is used to unmarshal a unix file mode from the config file.

func (FileMode) Mode

func (f FileMode) Mode() os.FileMode

Mode returns the compatible os.FileMode.

func (FileMode) String

func (f FileMode) String() string

String creates a unix-octal version of a file mode.

type Level

type Level int

Level represents the log level.

const (
	LogLevelNormal Level = iota
	LogLevelDebug
	LogLevelTrace
)

Log Levels.

func (Level) String

func (l Level) String() string

String returns the human-readable log level.

type LogConfig

type LogConfig struct {
	Name  string
	Path  string
	Size  uint
	Mode  FileMode
	Level Level
	Files uint
}

LogConfig allows sending logs to rotating files.

type Logger

type Logger struct {
	File string
	// contains filtered or unexported fields
}

Logger provides some methods with baked in assumptions.

func New

func New() *Logger

New returns an uninitialized logger. Config is optional, but must be provided here or with Setup().

func (*Logger) CapturePanic

func (l *Logger) CapturePanic()

CapturePanic can be deferred in any go routine to log any panic that occurs.

func (*Logger) Close

func (l *Logger) Close() error

func (*Logger) Debug

func (l *Logger) Debug(msg string)

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, v ...any)

func (*Logger) Error

func (l *Logger) Error(msg string)

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, v ...any)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

func (*Logger) Info

func (l *Logger) Info(msg string)

func (*Logger) Print

func (l *Logger) Print(msg string)

func (*Logger) Printf

func (l *Logger) Printf(msg string, v ...any)

func (*Logger) Setup

func (l *Logger) Setup(ctx context.Context, config *LogConfig)

SetupLogging splits log writers into a file and/or stdout. Config is optional, but must be provided here or with New().

func (*Logger) Trace

func (l *Logger) Trace(msg string)

func (*Logger) Warning

func (l *Logger) Warning(msg string)

Jump to

Keyboard shortcuts

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