log

package
v0.0.0-...-057099a Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultLogFileName

func SetDefaultLogFileName(name string)

Sets the default log file name, if empty or not set via this function, will use "app.log"

func SetDefaultLogsDirectory

func SetDefaultLogsDirectory(dir string)

Sets the default logs directory, if empty or not set via this function, will use "./logs"

Types

type Logger

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

Logger is a simple wrapper around zerolog

func NewLogger

func NewLogger(options ...Option) *Logger

NewLogger creates a new logger with the given options

NOTE: Please use WithConsole() before WithDebug() if you desire to use both

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

Debug logs a message to l.out if log level is debug

Also (pretty) prints to os.Stdout if l.console is true

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

Error logs a message to l.out

Also (pretty) prints to os.Stderr if l.console is true

func (*Logger) GetWriter

func (l *Logger) GetWriter() io.Writer

GetWriter returns the logger's writer

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

Info logs a message to l.out

Also (pretty) prints to os.Stdout if l.console is true

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

Implementation for the Gorm logger interface, does not support colored output

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

Warn logs a message to l.out

Also (pretty) prints to os.Stdout if l.console is true

type Option

type Option func(*Logger)

Option is a function that modifies the logger

func WithConsole

func WithConsole(console bool) Option

WithConsole enables (pretty) logging to console

func WithDebug

func WithDebug(debug bool) Option

WithDebug enables debug level logging

func WithName

func WithName(name string) Option

WithName sets the logger name

func WithOwnLogFile

func WithOwnLogFile(name string) Option

WithOwnLogFile sets the log file name to the given name

Jump to

Keyboard shortcuts

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