Documentation
¶
Overview ¶
Package clog provides an enhanced logging system with colored output, multiple log levels, and debug features for Go applications.
Basic usage:
clog.Info("Starting application...") clog.Success("Server started on port %d", 8080) clog.Error("Failed to connect: %v", err)
Log Levels (from lowest to highest):
- PanicLevel: System is unusable, halts execution
- ErrorLevel: Error events that might still allow the application to continue running
- WarningLevel: Warning messages for potentially harmful situations
- InfoLevel: General informational messages about system operation
- DebugLevel: Detailed information for debugging
- TraceLevel: Extremely detailed debugging information
Configuration:
clog.SetLogLevel(clog.DebugLevel) clog.SetShowFileLine(true) clog.SetShowGoroutineID(true)
Features:
- Colored output using emoji prefixes
- UTC timestamp with millisecond precision
- File and line number tracking
- Goroutine ID tracking
- Performance metrics logging
- Multiple log levels with filtering
- Panic handling with stack traces
Index ¶
- func Config(format string, args ...interface{})
- func Debug(format string, args ...interface{})
- func Error(format string, args ...interface{})
- func Info(format string, args ...interface{})
- func Init(format string, args ...interface{})
- func Metric(name string, value interface{}, tags ...string)
- func Panic(format string, args ...interface{})
- func SetLogLevel(level LogLevel)
- func SetShowFileLine(show bool)
- func SetShowGoroutineID(show bool)
- func Success(format string, args ...interface{})
- func Trace(format string, args ...interface{})
- func Warning(format string, args ...interface{})
- type LogLevel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetShowFileLine ¶
func SetShowFileLine(show bool)
SetShowFileLine enables/disables file and line number in logs
func SetShowGoroutineID ¶
func SetShowGoroutineID(show bool)
SetShowGoroutineID enables/disables goroutine ID in logs
Types ¶
type LogLevel ¶
type LogLevel int
LogLevel type for controlling log output
const ( // PanicLevel logs and then calls panic() PanicLevel LogLevel = iota // ErrorLevel indicates error conditions ErrorLevel // WarningLevel indicates potentially harmful situations WarningLevel // InfoLevel indicates general operational information InfoLevel // DebugLevel indicates detailed debug information DebugLevel // TraceLevel indicates the most detailed debugging information TraceLevel )
Click to show internal directories.
Click to hide internal directories.