This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 7e64c9544 fix: set default value for LOGGING_DIR (#4018)
7e64c9544 is described below

commit 7e64c95445b0bccdd90f72c7d7ca0325946dd42f
Author: Klesh Wong <[email protected]>
AuthorDate: Fri Dec 23 15:18:24 2022 +0800

    fix: set default value for LOGGING_DIR (#4018)
---
 .env.example   |  2 +-
 logger/init.go | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/.env.example b/.env.example
index 4d71e61ed..d906ac405 100644
--- a/.env.example
+++ b/.env.example
@@ -27,7 +27,7 @@ TEMPORAL_URL=
 TEMPORAL_TASK_QUEUE=
 # Debug Info Warn Error
 LOGGING_LEVEL=
-LOGGING_DIR=
+LOGGING_DIR=./logs
 ENABLE_STACKTRACE=false
 FORCE_MIGRATION=false
 
diff --git a/logger/init.go b/logger/init.go
index 7daee9ba7..8abc43bcb 100644
--- a/logger/init.go
+++ b/logger/init.go
@@ -18,14 +18,15 @@ limitations under the License.
 package logger
 
 import (
+       "os"
+       "path/filepath"
+       "strings"
+
        "github.com/apache/incubator-devlake/config"
        "github.com/apache/incubator-devlake/errors"
        "github.com/apache/incubator-devlake/plugins/core"
        "github.com/sirupsen/logrus"
        prefixed "github.com/x-cray/logrus-prefixed-formatter"
-       "os"
-       "path/filepath"
-       "strings"
 )
 
 var inner *logrus.Logger
@@ -52,12 +53,11 @@ func init() {
        })
        basePath := cfg.GetString("LOGGING_DIR")
        if basePath == "" {
-               inner.Warn("LOGGING_DIR is not set. Log files will not be 
generated.")
+               basePath = "./logs"
+       }
+       if abs, err := filepath.Abs(basePath); err != nil {
+               panic(err)
        } else {
-               abs, err := filepath.Abs(basePath)
-               if err != nil {
-                       panic(err)
-               }
                basePath = filepath.Join(abs, "devlake.log")
        }
        var err errors.Error

Reply via email to