log

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Stamp = true

Functions

func Close

func Close()

Close closes the global logger.

No parameters. No return types.

func ConfigLogger

func ConfigLogger(maxLevel string, colorize bool)

ConfigLogger configures the global logger with the specified level. The level parameter can be one of "debug", "info", "notice", "error", or any other value for the default level.

func Debug

func Debug(format string, a ...any)

func DebugOnError

func DebugOnError(err error, format string, a ...any)

func Error

func Error(format string, a ...any)

Error prints an error message using the global logger.

Args:

format (string): The format string for the error message.
a (any): The variadic arguments to be formatted into the message.

func ErrorOnError

func ErrorOnError(err error, format string, a ...any)

ErrorOnError appends the error to the variadic parameter a and logs a debug message if the error is not nil.

Parameters:

  • err: the error to be appended to the variadic parameter a.
  • format: the format string for the debug message.
  • a: variadic parameter that holds additional arguments for the format string.

func Info

func Info(format string, a ...any)

func Notice

func Notice(format string, a ...any)

Notice prints a notice message using the global logger.

Args:

format (string): The format string for the notice message.
a (any): The variadic arguments to be formatted into the message.

func NoticeOnError

func NoticeOnError(err error, format string, a ...any)

NoticeOnError appends the error to the variadic arguments and logs the formatted message if the error is not nil.

Parameters: - err: the error to check and append to the variadic arguments. - format: the format string for the log message. - a: variadic arguments for the format string.

func SprintJSON

func SprintJSON(v any) string

SprintJSON Pretty print a json object

func WarnOnError

func WarnOnError(err error, format string, a ...any)

WarnOnError log warning on error

func Warning

func Warning(format string, a ...any)

Warning prints a warning message with formatted arguments.

format is the format string for the warning message. a is a variadic parameter that represents the arguments to be formatted in the message.

Types

type Logger

type Logger interface {
	Warning(format string, a ...any)
	Info(format string, a ...any)
	Debug(format string, a ...any)
	Notice(format string, a ...any)
	Error(format string, a ...any)
	Close()
}

func NewLogger

func NewLogger(category string) Logger

NewLogger creates a new Logger with the specified category.

Parameters: - category: a string representing the category of the logger.

Returns: - Logger: the created logger.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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