fix: enhance error logging in file log driver and update default task log path

- Improved error messages in the FileLogDriver's cleanup method to include error details for better debugging.
- Updated the default task log path from '/app/logs/tasks' to '/var/log/crawlab/tasks' to ensure consistency across environments.
This commit is contained in:
Marvin Zhang
2025-01-01 14:26:10 +08:00
parent 7e7ac621ec
commit db2549e3cd
2 changed files with 4 additions and 4 deletions

View File

@@ -237,7 +237,7 @@ func (d *FileLogDriver) cleanup() {
if !utils.Exists(utils.GetTaskLogPath()) {
// create log directory if not exists
if err := os.MkdirAll(utils.GetTaskLogPath(), os.FileMode(0770)); err != nil {
d.Errorf("failed to create log directory: %s", utils.GetTaskLogPath())
d.Errorf("failed to create log directory: %s. error: %v", utils.GetTaskLogPath(), err)
return
}
}
@@ -249,13 +249,13 @@ func (d *FileLogDriver) cleanup() {
case <-ticker.C:
dirs, err := utils.ListDir(utils.GetTaskLogPath())
if err != nil {
d.Errorf("failed to list log directory: %s", utils.GetTaskLogPath())
d.Errorf("failed to list log directory: %s. error: %v", utils.GetTaskLogPath(), err)
continue
}
for _, dir := range dirs {
if time.Now().After(dir.ModTime().Add(d.getTtl())) {
if err := os.RemoveAll(d.getBasePath(dir.Name())); err != nil {
d.Errorf("failed to remove outdated log directory: %s", d.getBasePath(dir.Name()))
d.Errorf("failed to remove outdated log directory: %s. error: %s", d.getBasePath(dir.Name()), err)
continue
}
d.Infof("removed outdated log directory: %s", d.getBasePath(dir.Name()))

View File

@@ -11,7 +11,7 @@ import (
const (
DefaultWorkspace = "crawlab_workspace"
DefaultTaskLogPath = "/app/logs/tasks"
DefaultTaskLogPath = "/var/log/crawlab/tasks"
DefaultServerHost = "0.0.0.0"
DefaultServerPort = 8000
DefaultGrpcHost = "localhost"