logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

DigiStratum GoLib - Logger

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel uint
const (
	CRAZY LogLevel = iota // Crazy output: data structures, dumps, ASCII art, you name it
	TRACE                 // Where in the code base are we, and how were we called?
	DEBUG                 // What is our state and other helpful things for trouble shooting?
	INFO                  // What functional contract operation is running?
	WARN                  // What possible problem do we see that may need a human response?
	ERROR                 // What definite problem is there that will degrade functionality/performance?
	FATAL                 // What fundamental problem is there that is considered do or die?

)

Log levels

func StringToLogLevel

func StringToLogLevel(logLevelStr string) (*LogLevel, error)

func (LogLevel) ToString

func (r LogLevel) ToString() string

type LogLevelIfc

type LogLevelIfc interface {
	ToString() string
}

type Logger

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

func GetLogger

func GetLogger() *Logger

Get our singleton instance

func NewLogger

func NewLogger(streamId string) *Logger

Get a new (non-singleton) instance with a streamId meaningful to the caller (such as its runtime thread id)

func (Logger) Any

func (r Logger) Any(level LogLevel, format string, a ...interface{}) error

Log some output; return a matching error for WARN|ERROR|FATAL, else nil

func (Logger) Crazy

func (r Logger) Crazy(format string, a ...interface{}) error

Log CRAZY output

func (Logger) Debug

func (r Logger) Debug(format string, a ...interface{}) error

Log DEBUG output

func (Logger) Error

func (r Logger) Error(format string, a ...interface{}) error

Log ERROR output

func (Logger) Fatal

func (r Logger) Fatal(format string, a ...interface{}) error

Log FATAL output (caller should exit/panic after this)

func (*Logger) GetNewPrefixedLogger

func (r *Logger) GetNewPrefixedLogger(prefix string) *Logger

func (Logger) Info

func (r Logger) Info(format string, a ...interface{}) error

Log INFO output

func (*Logger) LogTimestamp

func (r *Logger) LogTimestamp(logTimestamp bool) *Logger

Set the logTimestamp state (defaults to true to enable timestamps in logger output)

func (*Logger) SetLogWriter

func (r *Logger) SetLogWriter(logWriter lw.LogWriterIfc) *Logger

Replace the current LogWriter with something more to our liking

func (*Logger) SetMinLogLevel

func (r *Logger) SetMinLogLevel(minLogLevel LogLevel) *Logger

Set the minimum log level

func (Logger) Trace

func (r Logger) Trace(format string, a ...interface{}) error

Log TRACE output

func (Logger) Warn

func (r Logger) Warn(format string, a ...interface{}) error

Log WARN output

type LoggerIfc

type LoggerIfc interface {
	GetNewPrefixedLogger(prefix string) *Logger
	SetMinLogLevel(minLogLevel LogLevel) *Logger
	SetLogWriter(logWriter lw.LogWriterIfc) *Logger
	LogTimestamp(logTimestamp bool) *Logger
	Any(level LogLevel, format string, a ...interface{}) error
	Crazy(format string, a ...interface{}) error
	Trace(format string, a ...interface{}) error
	Debug(format string, a ...interface{}) error
	Info(format string, a ...interface{}) error
	Warn(format string, a ...interface{}) error
	Error(format string, a ...interface{}) error
	Fatal(format string, a ...interface{}) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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