Skip to content

Commit

Permalink
fix: enhance error logging in file log driver and update default task…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
tikazyq committed Jan 1, 2025
1 parent 7e7ac62 commit db2549e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/task/log/file_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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()))
Expand Down
2 changes: 1 addition & 1 deletion core/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit db2549e

Please sign in to comment.