logger

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const PATH = "| \033[38;5;%sm%s\033[39;49m |"

Constant for formatting log path with color.

Variables

This section is empty.

Functions

func Debug

func Debug(a ...any)

Debug logs a message with Debug level. It logs detailed debugging information.

Parameters: - v: ...any The message or variables to log.

func Debugf

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

Debug logs a message with Debug level. It logs detailed debugging information.

Parameters: - v: ...any The message or variables to log.

func Error

func Error(err error) bool

Error logs a message with Error level. It logs an error message, used for non-critical failures.

Parameters: - err: error The error to log.

Returns: - bool: true if the message was successfully logged, otherwise false.

func Fatal

func Fatal(err error) bool

Fatal logs a message with Fatal level. It logs a critical error message and typically exits the program.

Parameters: - err: error The error to log.

Returns: - bool: true if the message was successfully logged, otherwise false.

func Info

func Info(a ...any)

Info logs a message with Info level. It logs informational messages, useful for tracking the flow of the application.

Parameters: - v: ...any The message or variables to log.

func Infof

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

Info logs a message with Info level. It logs informational messages, useful for tracking the flow of the application.

Parameters: - v: ...any The message or variables to log.

func Message

func Message(a ...any)

Message logs a message with Message level. It logs a general, informational message.

Parameters: - v: ...any The message or variables to log.

func Messagef

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

Message logs a message with Message level. It logs a general, informational message.

Parameters: - v: ...any The message or variables to log.

func Panic

func Panic(err error) bool

Panic logs a message with Panic level. It logs a message and then panics.

Parameters: - err: error The error to log.

Returns: - bool: true if the message was successfully logged, otherwise false.

func SetLevel

func SetLevel(l levels.TYPE)

SetLevel sets the log level of the standard logger. This function allows dynamic adjustment of the logging level.

Parameters: - l: levels.TYPE The log level to set for the standard logger.

func Success

func Success(a ...any)

Success logs a message with Success level. It logs a success or completion message.

Parameters: - v: ...any The message or variables to log.

func Successf

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

Success logs a message with Success level. It logs a success or completion message.

Parameters: - v: ...any The message or variables to log.

func Trace

func Trace()

Trace logs a message with Trace level. It logs the most detailed information, often for tracing code execution paths.

func Warn

func Warn(a ...any)

Warn logs a message with Warn level. It logs a warning message, indicating potential issues.

Parameters: - v: ...any The message or variables to log.

func Warnf

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

Warn logs a message with Warn level. It logs a warning message, indicating potential issues.

Parameters: - v: ...any The message or variables to log.

Types

type Logger

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

Logger struct holds the logging configuration and loggers for different levels.

func New

func New(l levels.TYPE, ws ...io.Writer) *Logger

New creates a new Logger instance with the specified writer type and log level. It initializes two loggers: one for success and another for failure messages.

Parameters: - l: levels.TYPE The logging level for the logger. - ws: []io.Writer The writer for success or failure messages (optional).

Returns: - *Logger: A new Logger instance.

func (*Logger) Debug

func (l *Logger) Debug(v ...any)

Debug logs the debug message with the DEBUG level. It provides detailed debug information for troubleshooting.

Parameters: - v: ...any The debug messages or data to log.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, a ...any)

Debugf logs a debug message with formatted output. It is similar to Debug but allows for formatted messages.

Parameters: - format: string The format string. - a: ...any The arguments for formatting.

func (*Logger) Error

func (l *Logger) Error(err error) bool

Error logs the error with the ERROR level. It is used for logging general errors.

Parameters: - err: error The error to log.

Returns: - bool: true if the error is not nil, false otherwise.

func (*Logger) Fatal

func (l *Logger) Fatal(err error) bool

Fatal logs the error and stack trace with the FATAL level. It logs critical errors that might require the application to stop.

Parameters: - err: error The error to log.

Returns: - bool: true if the error is not nil, false otherwise.

func (*Logger) Info

func (l *Logger) Info(v ...any)

Info logs the info message with the INFO level. It is used for logging informational messages.

Parameters: - v: ...any The informational messages or data to log.

func (*Logger) Infof

func (l *Logger) Infof(format string, a ...any)

Infof logs an informational message with formatted output. It is similar to Info but allows for formatted messages.

Parameters: - format: string The format string. - a: ...any The arguments for formatting.

func (*Logger) Message

func (l *Logger) Message(v ...any)

Message logs the message with the MESSAGE level. It is used for general-purpose logging.

Parameters: - v: ...any The messages or data to log.

func (*Logger) Messagef

func (l *Logger) Messagef(format string, a ...any)

Messagef logs a general message with formatted output. It is similar to Message but allows for formatted messages.

Parameters: - format: string The format string. - a: ...any The arguments for formatting.

func (*Logger) Panic

func (l *Logger) Panic(err error) bool

Panic logs the error and stack trace with the PANIC level. It logs the error and a stack trace for debugging.

Parameters: - err: error The error to log.

Returns: - bool: true if the error is not nil, false otherwise.

func (*Logger) Success

func (l *Logger) Success(v ...any)

Success logs the success message with the SUCCESS level. It is used for logging successful operations.

Parameters: - v: ...any The success messages or data to log.

func (*Logger) Successf

func (l *Logger) Successf(format string, a ...any)

Successf logs a success message with formatted output. It is similar to Success but allows for formatted messages.

Parameters: - format: string The format string. - a: ...any The arguments for formatting.

func (*Logger) Trace

func (l *Logger) Trace()

Trace logs the stack trace with the TRACE level. It is used for logging detailed execution traces for in-depth debugging.

func (*Logger) Warn

func (l *Logger) Warn(v ...any)

Warn logs the warning message with the WARN level. It is used for logging potential issues or warnings.

Parameters: - v: ...any The warning messages or data to log.

func (*Logger) Warnf

func (l *Logger) Warnf(format string, a ...any)

Warnf logs a warning message with formatted output. It is similar to Warn but allows for formatted messages.

Parameters: - format: string The format string. - a: ...any The arguments for formatting.

func (*Logger) Write

func (l *Logger) Write(level levels.TYPE, messages ...any)

Write writes the log message with the specified log level. It formats the message and decides which logger to use based on the level.

Parameters: - level: levels.TYPE The log level for the message. - messages: ...any The messages or data to log.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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