mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
create log dir to avoid error
This commit is contained in:
parent
e6d4faea6a
commit
a238da3dc4
|
@ -10,14 +10,14 @@ import (
|
|||
|
||||
"github.com/heroku/rollrus"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/lestrrat-go/file-rotatelogs"
|
||||
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rifflock/lfshook"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/x-cray/logrus-prefixed-formatter"
|
||||
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
||||
|
||||
"github.com/c9s/bbgo/pkg/bbgo"
|
||||
"github.com/c9s/bbgo/pkg/util"
|
||||
|
@ -219,11 +219,14 @@ func init() {
|
|||
|
||||
func Execute() {
|
||||
environment := os.Getenv("BBGO_ENV")
|
||||
logDir := "log"
|
||||
switch environment {
|
||||
case "production", "prod":
|
||||
|
||||
if err := os.MkdirAll(logDir, 0777); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
writer, err := rotatelogs.New(
|
||||
path.Join("log", "access_log.%Y%m%d"),
|
||||
path.Join(logDir, "access_log.%Y%m%d"),
|
||||
rotatelogs.WithLinkName("access_log"),
|
||||
// rotatelogs.WithMaxAge(24 * time.Hour),
|
||||
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
|
||||
|
|
Loading…
Reference in New Issue
Block a user