mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: expand Logger interface and implement additional logging methods in ServiceLogger
- Added Debug, Info, Warn, Error, and Fatal methods to the Logger interface for comprehensive logging capabilities. - Implemented corresponding methods in ServiceLogger to facilitate structured logging with service context. - Enhanced the logging functionality to support various log levels, improving error tracking and debugging.
This commit is contained in:
@@ -2,6 +2,21 @@ package interfaces
|
||||
|
||||
// Logger interface for reporting informational and warning messages.
|
||||
type Logger interface {
|
||||
// Debug logs a debugging message.
|
||||
Debug(message string)
|
||||
|
||||
// Info logs an informational message.
|
||||
Info(message string)
|
||||
|
||||
// Warn logs a warning message.
|
||||
Warn(message string)
|
||||
|
||||
// Error logs an error message.
|
||||
Error(message string)
|
||||
|
||||
// Fatal logs a fatal message.
|
||||
Fatal(message string)
|
||||
|
||||
// Debugf logs a formatted debugging message.
|
||||
Debugf(format string, args ...interface{})
|
||||
|
||||
|
||||
@@ -17,6 +17,36 @@ func NewServiceLogger(serviceName string) *ServiceLogger {
|
||||
}
|
||||
}
|
||||
|
||||
// Debug logs a debug message.
|
||||
func (l *ServiceLogger) Debug(message string) {
|
||||
log.Debug(l.getFormat(message))
|
||||
}
|
||||
|
||||
// Info logs an informational message.
|
||||
func (l *ServiceLogger) Info(message string) {
|
||||
log.Info(l.getFormat(message))
|
||||
}
|
||||
|
||||
// Warn logs a warning message.
|
||||
func (l *ServiceLogger) Warn(message string) {
|
||||
log.Warn(l.getFormat(message))
|
||||
}
|
||||
|
||||
// Error logs an error message.
|
||||
func (l *ServiceLogger) Error(message string) {
|
||||
log.Error(l.getFormat(message))
|
||||
}
|
||||
|
||||
// Fatal logs a fatal message.
|
||||
func (l *ServiceLogger) Fatal(message string) {
|
||||
log.Fatal(l.getFormat(message))
|
||||
}
|
||||
|
||||
// Debugf logs a debug message with formatted content.
|
||||
func (l *ServiceLogger) Debugf(format string, args ...interface{}) {
|
||||
log.Debugf(l.getFormat(format), args...)
|
||||
}
|
||||
|
||||
// Infof logs an informational message with formatted content.
|
||||
func (l *ServiceLogger) Infof(format string, args ...interface{}) {
|
||||
log.Infof(l.getFormat(format), args...)
|
||||
@@ -32,12 +62,7 @@ func (l *ServiceLogger) Errorf(format string, args ...interface{}) {
|
||||
log.Errorf(l.getFormat(format), args...)
|
||||
}
|
||||
|
||||
// Debugf logs a debug message with formatted content.
|
||||
func (l *ServiceLogger) Debugf(format string, args ...interface{}) {
|
||||
log.Debugf(l.getFormat(format), args...)
|
||||
}
|
||||
|
||||
// Fatalf logs a fatal message with formatted content and exits the program.
|
||||
// Fatalf logs an error message with formatted content.
|
||||
func (l *ServiceLogger) Fatalf(format string, args ...interface{}) {
|
||||
log.Fatalf(l.getFormat(format), args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user