mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
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:
@@ -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()))
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user