log_item

package
v3.0.0-...-5669fa1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loc

type Loc string

func Locf

func Locf(str string, v ...any) Loc

func (Loc) String

func (l Loc) String() string

type LogErr

type LogErr = *LogItem

type LogItem

type LogItem struct {
	Location  Loc            `json:"location"`
	Time      time.Time      `json:"time"`
	After     string         `json:"after"`
	Body      map[string]any `json:"body"`
	Message   string         `json:"message"`
	Level     LogLevel       `json:"log_level"`
	CallStack []error        `json:"call_stack"`
}

func NewLogErr

func NewLogErr(loc Loc, log_level LogLevel) (lt *LogItem)

func NewLogItem

func NewLogItem(loc Loc, log_level LogLevel) (lt *LogItem)

func NewLogf

func NewLogf(str string, v ...any) (lt *LogItem)

func (*LogItem) AppendParentError

func (li *LogItem) AppendParentError(err ...error) *LogItem

func (*LogItem) Error

func (li *LogItem) Error() string

func (*LogItem) ErrorHas

func (li *LogItem) ErrorHas(err error) bool

func (*LogItem) Get

func (li *LogItem) Get(key string) (it any, ok bool)

func (*LogItem) Now

func (lt *LogItem) Now() *LogItem

func (*LogItem) Print

func (lt *LogItem) Print(print_option ...PrintOptions) string

func (*LogItem) Set

func (li *LogItem) Set(key string, value any) *LogItem

func (*LogItem) SetAfter

func (li *LogItem) SetAfter(after string) *LogItem

func (*LogItem) SetAfterf

func (li *LogItem) SetAfterf(after string, v ...any) *LogItem

func (*LogItem) SetLevel

func (li *LogItem) SetLevel(level LogLevel) *LogItem

func (*LogItem) SetLoc

func (li *LogItem) SetLoc(loc Loc) *LogItem

func (*LogItem) SetLocf

func (li *LogItem) SetLocf(str string, v ...any) *LogItem

func (*LogItem) SetMessage

func (lt *LogItem) SetMessage(v ...any) *LogItem

func (*LogItem) SetMessagef

func (lt *LogItem) SetMessagef(str string, v ...any) *LogItem

func (*LogItem) SetTime

func (li *LogItem) SetTime(t time.Time) *LogItem

func (*LogItem) Setf

func (li *LogItem) Setf(key string, str string, value ...any) *LogItem

func (*LogItem) String

func (li *LogItem) String() string

type LogLevel

type LogLevel int
const (
	LogLevelWrite LogLevel = iota - 1
	/*
	 Only when I would be "tracing" the code and trying
	 to find one part of a function specifically.
	*/
	LogLevelTrace

	/*
	   Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
	*/
	LogLevelDebug01
	/*
	   Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
	*/
	LogLevelDebug02
	/*
	   Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
	*/
	LogLevelDebug03
	/*
	   Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
	*/
	LogLevelDebug04
	/*
	   Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
	*/
	LogLevelDebug05
	/*
	   Information that is diagnostically helpful to people more than just developers (IT, sysadmins, etc.).
	*/
	LogLevelDebug06
	/*
		Generally useful information to log (service start/stop, configuration assumptions, etc).
		Info I want to always have available but usually don't care about under normal circumstances.
		This is my out-of-the-box config level.
	*/
	LogLevelInfo01
	/*
		Generally useful information to log (service start/stop, configuration assumptions, etc).
		Info I want to always have available but usually don't care about under normal circumstances.
		This is my out-of-the-box config level.
	*/
	LogLevelInfo02
	/*
		Generally useful information to log (service start/stop, configuration assumptions, etc).
		Info I want to always have available but usually don't care about under normal circumstances.
		This is my out-of-the-box config level.
	*/
	LogLevelInfo03
	/*
		Anything that can potentially cause application oddities,
		but for which I am automatically recovering.
		(Such as switching from a primary to backup server,
		retrying an operation, missing secondary data, etc.)
	*/
	LogLevelWarn
	/*
		Any error which is fatal to the operation, but not the service or application
		(can't open a required file, missing data, etc.).
		These errors will force user (administrator, or direct user) intervention.
		These are usually reserved (in my apps) for incorrect connection strings, missing services, etc.
	*/
	LogLevelError01
	/*
		Any error which is fatal to the operation, but not the service or application
		(can't open a required file, missing data, etc.).
		These errors will force user (administrator, or direct user) intervention.
		These are usually reserved (in my apps) for incorrect connection strings, missing services, etc.
	*/
	LogLevelError02
	/*
		Any error that is forcing a shutdown of the service or application to prevent data loss (or further data loss).
		I reserve these only for the most heinous errors and situations
		where there is guaranteed to have been data corruption or loss.
	*/
	LogLevelFatal
)

func (LogLevel) String

func (ll LogLevel) String() string

type PrintOptions

type PrintOptions = int
const (
	PO_LINE PrintOptions = iota + 1
	PO_JSON
	PO_PLAIN
)

Jump to

Keyboard shortcuts

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