Skip to content

Commit

Permalink
Allow moving the log file
Browse files Browse the repository at this point in the history
  • Loading branch information
DamianZaremba committed Dec 10, 2024
1 parent 5ea6ceb commit aff51c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/spf13/pflag"
"gopkg.in/natefinch/lumberjack.v2"
"net/http"
"os"
"sync"
"time"
)
Expand Down Expand Up @@ -80,8 +81,13 @@ func main() {
logrus.FieldKeyMsg: "message",
},
})

logFile := "cbng.log"
if value, ok := os.LookupEnv("BOTNG_LOG"); ok {
logFile = value
}
logrus.AddHook(helpers.NewLogFileHook(&lumberjack.Logger{
Filename: "cbng.log",
Filename: logFile,
MaxBackups: 31,
MaxAge: 1,
Compress: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/cbng/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func NewConfiguration() *Configuration {
configuration := Configuration{}

var configPath string
if val, ok := os.LookupEnv("BOT_CFG"); ok {
if val, ok := os.LookupEnv("BOTNG_CFG"); ok {
configPath = val
}
if configPath != "" {
Expand Down

0 comments on commit aff51c0

Please sign in to comment.