Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error string
Error represents package level error related to logging work.
const ( // ErrParseLevel indicates that string given to function ParseLevel can't be parsed to Level. ErrParseLevel Error = "string can't be parsed as Level, use: `error`, `warning`, `info`, `debug`" )
type Level ¶
type Level byte
Level represents an enumeration of logging levels.
func ParseLevel ¶
ParseLevel takes the string and tries to parse it to the Level.
type LineNumFmt ¶ added in v1.0.0
type LineNumFmt byte
LineNumFmt represents an enumeration of formats for printing the code line number in log output.
const ( // ShortFmt represents format of the code line number. // Contains resulting file name and line number. ShortFmt LineNumFmt = iota // LongFmt represents format of the code line number. // Contains full file path, name and line number. LongFmt )
type Logger ¶
type Logger interface { // Error formats and writes the error level message. Error(format string, v ...any) // Warning formats and writes the warning level message. Warning(format string, v ...any) // Info formats and writes the information level message. Info(format string, v ...any) // Debug formats and writes the debug level message. Debug(format string, v ...any) }
Logger formats the message according to standard format specifiers from the fmt package and writes the message to writer specified by the concrete interface implementation.
type NopLog ¶
type NopLog struct{}
NopLog represents empty/disabled implementation of Logger interface.
type Option ¶
type Option func(l *StdLog)
Option represents a functional option type which can be passed to the NewStdLog function to change its underlying properties.
func WithLevelAtPrefixEnd ¶ added in v1.1.0
func WithLevelAtPrefixEnd() Option
WithLevelAtPrefixEnd sets the level mark at the end of log prefix.
func WithLineNum ¶ added in v0.1.2
func WithLineNum(format LineNumFmt) Option
WithLineNum enables the printing of code line number in log output.
func WithNoColor ¶ added in v0.1.2
func WithNoColor() Option
WithNoColor disables the color output of StdLog.
func WithNoDateTime ¶ added in v1.1.3
func WithNoDateTime() Option
WithNoDateTime disables the output of date and time of StdLog.
func WithWriter ¶
WithWriter changes the writer for each leveled loggers of StdLog to the given on.
type StdLog ¶
type StdLog struct {
// contains filtered or unexported fields
}
StdLog represents wrapper around standard library logger which implements Logger interface.
func New ¶
New returns a new instance of StdLog struct. Takes variadic options which will be applied to StdLog.