mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
feat: add Fatalf logging method to Logger interface and ServiceLogger
- Introduced Fatalf method in Logger interface for logging fatal messages with formatted content. - Implemented Fatalf in ServiceLogger to log fatal messages and exit the program, enhancing error handling capabilities.
This commit is contained in:
@@ -13,4 +13,7 @@ type Logger interface {
|
||||
|
||||
// Errorf logs a formatted error message.
|
||||
Errorf(format string, args ...interface{})
|
||||
|
||||
// Fatalf logs a formatted fatal message.
|
||||
Fatalf(format string, args ...interface{})
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ 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.
|
||||
func (l *ServiceLogger) Fatalf(format string, args ...interface{}) {
|
||||
log.Fatalf(l.getFormat(format), args...)
|
||||
}
|
||||
|
||||
func (l *ServiceLogger) getFormat(format string) string {
|
||||
return fmt.Sprintf("[%s] %s", l.prefix, format)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user