logs

package
v0.0.0-...-2f1cb99 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	// The level of the log entry
	Level LogLevel

	// The module that generated the entry
	Module string

	// The message passed
	Message string

	// The time the entry was generated
	Time time.Time

	// The machine ID - This is used to identify the machine that generated the log entry
	MachineID string

	// The short ID based on the machine ID
	ShortId string

	// The hostname of the machine that generated the log entry
	Hostname string
}

Log represents a log entry

func (*Log) String

func (l *Log) String() string

type LogLevel

type LogLevel uint8
const (
	LogLevelDebug LogLevel = 0 // Debug level
	LogLevelInfo  LogLevel = 1 //  Info level
	LogLevelWarn  LogLevel = 2 //  Warn level
	LogLevelError LogLevel = 3 // Error level
	LogLevelFatal LogLevel = 4 // Fatal level
)

func FromString

func FromString(l string) LogLevel

func (LogLevel) String

func (l LogLevel) String() string

type LogStream

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

LogStream represents a log stream

func ForkLogStream

func ForkLogStream(client *keyval.KeyvalClient) *LogStream

func NewLogStream

func NewLogStream() (*LogStream, error)

NewLogStream creates a new log stream

func (*LogStream) Log

func (l *LogStream) Log(entry Log) error

func (*LogStream) Terminate

func (l *LogStream) Terminate()

type Logger

type Logger struct {
	// The lowest level of messages that will be logged
	Level LogLevel

	// The module that the logger is for
	Module string

	// The valkey client
	Net *LogStream

	// A unique identifier for the machine
	MachineID string

	// A short identifier based on the machine ID
	ShortId string

	// The hostname of the machine
	Hostname string
}

Logger represents a logger

func NetLogger

func NetLogger(module string) Logger

Creates a new logger with a valkey client instance

func OfflineLogger

func OfflineLogger(module string) Logger

Creates a new logger without a valkey client instance

func (*Logger) Debug

func (l *Logger) Debug(message string)

Log a debug message

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

Log a formatted debug message

func (*Logger) Error

func (l *Logger) Error(message string)

Log an error message

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

Log a formatted error message

func (*Logger) Fatal

func (l *Logger) Fatal(message error)

Log a fatal message

func (*Logger) Fork

func (l *Logger) Fork(module string) Logger

Fork a new logger from the existing instance (minimises the amount of data logged when creating a new logger)

func (*Logger) Info

func (l *Logger) Info(message string)

Log an info message

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

Log a formatted info message

func (*Logger) Log

func (l *Logger) Log(level LogLevel, message string)

Log a message

func (*Logger) Logf

func (l *Logger) Logf(level LogLevel, format string, args ...any)

logs a formatted message

func (*Logger) Terminate

func (l *Logger) Terminate()

func (*Logger) Warn

func (l *Logger) Warn(message string)

Log a warning message

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...any)

Log a formatted warning message

Jump to

Keyboard shortcuts

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