Documentation
¶
Index ¶
- func Bold(s string) string
- func Boldf(s string, a ...any) string
- func Clear()
- func ClearLine()
- func Colour(colour colour, s string) string
- func Colourf(colour colour, s string, a ...any) string
- func Colours() colours
- func Configure(loggoConfig Config)
- func CustomColour(red byte, green byte, blue byte) colour
- func Debug(s string)
- func Debugf(s string, a ...any)
- func Error(s string)
- func Errorf(s string, a ...any)
- func Fatal(s string)
- func Fatalf(s string, a ...any)
- func Format(f Formatting, s string) string
- func Formatf(f Formatting, s string, a ...any) string
- func Get() loggo
- func Info(s string)
- func Infof(s string, a ...any)
- func Levels() levels
- func New(config Config) loggo
- func Success(s string)
- func Successf(s string, a ...any)
- func Timestamps() timestamps
- func Trace(s string)
- func Tracef(s string, a ...any)
- func Underline(s string) string
- func Underlinef(s string, a ...any) string
- func Warn(s string)
- func Warnf(s string, a ...any)
- type Colouring
- type Config
- type Formatting
- type LogLevel
- type Logger
- type Loggerf
- type Loggerm
- type Loggo
- type TemplateConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Boldf ¶
Boldf wraps a string in bold ansi codes. Uses the same interface as fmt.Printf. Returns a string
func ClearLine ¶
func ClearLine()
ClearLine will clear the current line and move the cursor to the start of the line.
func Colour ¶
Colour wraps a string in the colour provided. Use the provided colour constants in loggo, or generate one using CustomColour. Returns a string
func Colourf ¶
Colour wraps a string in the colour provided. Use the provided colour constants in loggo, or generate one using CustomColour. Uses the same interface as fmt.Printf after the initial colour string. Returns a string
func Configure ¶
func Configure(loggoConfig Config)
(Singleton) It is a thread safe function which allows you to configure Loggo once, and then use the singleton api to reuse that same configuration throughout your code. The configuration passed to the first call of Configure, is stored and will be used in subsequent calls. Any configuration passed to subsequent calls is ignored. If Configure is never called, the singleton api will use the default configuration.
func CustomColour ¶
CustomColour turns 3 integers for red, green, and blue into an ansi code. Returns a string which can be used to configure Colours
func Fatal ¶
func Fatal(s string)
(Singleton) Calling Fatal will log the message, if logLevel is not Level.Silent, then will always call os.Exit(1).
func Fatalf ¶
(Singleton) Calling Fatal will log the message, if logLevel is not Level.Silent, then will always call os.Exit(1). Uses the same interface as fmt.Printf.
func Format ¶
func Format(f Formatting, s string) string
Format is a helper function which can apply multiple formatting options to a string at once. Using the Formatting struct, you can apply bold, underling and a colour in a any combination. Returns a string.
func Formatf ¶
func Formatf(f Formatting, s string, a ...any) string
Formatf is a helper function which can apply multiple formatting options to a string at once. Using the Formatting struct, you can apply bold, underling and a colour in a any combination. Uses the same interface as fmt.Printf after the inital Formatting struct. Returns a string.
func Get ¶
func Get() loggo
(Singleton) Get returns a copy of the singleton instance. Returns an instance of Loggo
func Successf ¶
(Singleton) Logs at the Level.Info log level. Uses the same interface as fmt.Printf.
func Timestamps ¶
func Timestamps() timestamps
func Underlinef ¶
Underlinef wraps a string in underline ansi codes. Uses the same interface as fmt.Printf. Returns a string
Types ¶
type Colouring ¶
type Colouring struct { Debug colour Error colour Fatal colour Info colour Success colour Trace colour Warn colour }
Configure the colour of each LogLevel.
type Config ¶
type Config struct { // Configure the colour of each LogLevel. Colours Colouring // The default LogLevel for the instance can be overrwridden with environment variables if IgnoreEnvVar is false. Default: Levels().Default LogLevel LogLevel // Configure whether the instance should ignore the env var LOG_LEVEL. Default: false. IgnoreEnvVar bool // Enable ISO timestamps on logs. Default: false Timestamp timestamp // Disable the log level prefix before the built in logging messages. Custom loggers are unaffected. Default: false. DisablePrefix bool // Disable the indent and word wrapping functionality for faster logging. Default: false. DisableWordWrap bool }
Config is a struct for configuring loggo instances.
type Formatting ¶
type Logger ¶
type Logger func(s string)
func CustomLogger ¶
func CustomLogger(config TemplateConfig, logLevel LogLevel) Logger
CustomLogger creates a CustomLogger using the singleton loggo instance. Returns a function which logs a string.
type Loggerf ¶
func CustomLoggerf ¶
func CustomLoggerf(config TemplateConfig, logLevel LogLevel) Loggerf
CustomLoggerf creates a CustomLogger using the singleton loggo instance. Returns a function which uses the same interface as fmt.Printf.
type Loggo ¶
type Loggo interface { Debug(string) Debugf(string, ...any) Error(string) Errorf(string, ...any) Fatal(string) Fatalf(string, ...any) Info(string) Infof(string, ...any) Success(string) Successf(string, ...any) Trace(string) Tracef(string, ...any) Warn(string) Warnf(string, ...any) CustomLogger(TemplateConfig, LogLevel) Logger CustomLoggerf(TemplateConfig, LogLevel) Loggerf }
type TemplateConfig ¶
type TemplateConfig struct { // Enable printing the timestamp in the formats 15:04:05.999, or 2006-01-02 15:04:05.999, before the message. Default: None. Timestamp timestamp // Disable word wrap, and indentation, for a faster template. Default: false. DisableWordWrap bool // Indent requires word wrap to be enabled. Default: 0, Indent int // Colour Name of your logger. Use a builtin loggo colour, loggo.Colours().<name>, or make a custom colour using loggo.CustomColour(...) Colour colour // The name your logger will be printed before the message as part of the prefix. Ignored if left blank. Name string }
Use TemplateConfig to configure CustomLoggers
Directories
¶
Path | Synopsis |
---|---|
benchmarks
|
|
default
command
|
|
multiline
command
|
|
multiline_no_word_wrap
command
|
|
examples
|
|
default
command
|
|
disable_msg_prefix
command
|
|
multiline
command
|
|
timestamps
command
|