logger

package
v0.23.11 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: GPL-3.0 Imports: 6 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(v ...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(v ...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(v ...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(v ...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(v ...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(t writers.TYPE, l levels.TYPE) *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: - t: writers.TYPE The writer type (e.g., console, file) for the logger. - l: levels.TYPE The logging level for the logger.

Returns: - *Logger: A new Logger instance.

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

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

Parameters: - v: ...interface{} The debug messages or data to log.

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 ...interface{})

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

Parameters: - v: ...interface{} The informational messages or data to log.

func (*Logger) Message

func (l *Logger) Message(v ...interface{})

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

Parameters: - v: ...interface{} The messages or data to log.

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 ...interface{})

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

Parameters: - v: ...interface{} The success messages or data to log.

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 ...interface{})

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

Parameters: - v: ...interface{} The warning messages or data to log.

func (*Logger) Write

func (l *Logger) Write(level levels.TYPE, messages ...interface{})

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: ...interface{} 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