Documentation
¶
Index ¶
- func Debug(message string)
- func Debugf(format string, args ...interface{})
- func Error(message string)
- func ErrorWithErr(message string, err error)
- func Errorf(format string, args ...interface{})
- func Fatal(message string)
- func Fatalf(format string, args ...interface{})
- func GetRequestID(c *gin.Context) string
- func GetUserID(c *gin.Context) string
- func GinLogger(logger *Logger) gin.HandlerFunc
- func Info(message string)
- func Infof(format string, args ...interface{})
- func SetDefaultLogger(logger *Logger)
- func Warn(message string)
- func Warnf(format string, args ...interface{})
- type Config
- type LogEntry
- type LogLevel
- type Logger
- func (l *Logger) Debug(message string)
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(message string)
- func (l *Logger) ErrorWithErr(message string, err error)
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Fatal(message string)
- func (l *Logger) Fatalf(format string, args ...interface{})
- func (l *Logger) Info(message string)
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) LogOperation(operation string, fn func() error) error
- func (l *Logger) Warn(message string)
- func (l *Logger) Warnf(format string, args ...interface{})
- func (l *Logger) WithComponent(component string) *Logger
- func (l *Logger) WithField(key string, value interface{}) *Logger
- func (l *Logger) WithFields(fields map[string]interface{}) *Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorWithErr ¶
func GetRequestID ¶
GetRequestID extracts request ID from gin context
func SetDefaultLogger ¶
func SetDefaultLogger(logger *Logger)
SetDefaultLogger sets the default logger
Types ¶
type Config ¶
type Config struct {
Level LogLevel
Output io.Writer
Component string
EnableCaller bool
TimeFormat string
}
Config represents logger configuration
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"`
Level LogLevel `json:"level"`
Message string `json:"message"`
Fields map[string]interface{} `json:"fields,omitempty"`
Caller string `json:"caller,omitempty"`
RequestID string `json:"request_id,omitempty"`
UserID string `json:"user_id,omitempty"`
Component string `json:"component,omitempty"`
Operation string `json:"operation,omitempty"`
Duration *int64 `json:"duration_ms,omitempty"`
Error string `json:"error,omitempty"`
HTTPMethod string `json:"http_method,omitempty"`
HTTPPath string `json:"http_path,omitempty"`
HTTPStatus int `json:"http_status,omitempty"`
HTTPLatency *int64 `json:"http_latency_ms,omitempty"`
}
LogEntry represents a structured log entry
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents a structured logger
func (*Logger) ErrorWithErr ¶
ErrorWithErr logs an error message with an error object
func (*Logger) LogOperation ¶
LogOperation logs the start and end of an operation with duration
func (*Logger) WithComponent ¶
WithComponent sets the component for this logger
func (*Logger) WithFields ¶
WithFields adds multiple fields to the logger context
Click to show internal directories.
Click to hide internal directories.