Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Reduce task logger glog noise and remove per-write fsync (#8603)

Chris Lu2ff4a0754472
diff --git a/weed/worker/tasks/task_logger.go b/weed/worker/tasks/task_logger.go
index 96f1846377..90383c7692 100644
--- a/weed/worker/tasks/task_logger.go
+++ b/weed/worker/tasks/task_logger.go
@@ -317,26 +317,15 @@ func (l *FileTaskLogger) writeLogEntry(entry TaskLogEntry) {
return
}
- // Flush to disk
- if err := l.logFile.Sync(); err != nil {
- glog.Errorf("Failed to sync log file: %v", err)
- }
-
- // Also log to console and stderr if enabled
+ // Only forward errors and warnings to glog; routine task logs stay in the task log file.
if l.config.EnableConsole {
- // Log to glog with proper call depth to show actual source location
- // We need depth 3 to skip: writeLogEntry -> log -> Info/Warning/Error calls to reach the original caller
formattedMsg := fmt.Sprintf("[TASK-%s] %s: %s", l.taskID, entry.Level, entry.Message)
switch entry.Level {
case "ERROR":
- glog.ErrorDepth(3, formattedMsg)
+ glog.ErrorDepth(4, formattedMsg)
case "WARNING":
- glog.WarningDepth(3, formattedMsg)
- default: // INFO, DEBUG, etc.
- glog.InfoDepth(3, formattedMsg)
+ glog.WarningDepth(4, formattedMsg)
}
- // Also log to stderr for immediate visibility
- fmt.Fprintf(os.Stderr, "[TASK-%s] %s: %s\n", l.taskID, entry.Level, entry.Message)
}
}