mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +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/heroku/rollrus"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/lestrrat-go/file-rotatelogs"
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/rifflock/lfshook"
|
"github.com/rifflock/lfshook"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"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/bbgo"
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
|
@ -219,11 +219,14 @@ func init() {
|
||||||
|
|
||||||
func Execute() {
|
func Execute() {
|
||||||
environment := os.Getenv("BBGO_ENV")
|
environment := os.Getenv("BBGO_ENV")
|
||||||
|
logDir := "log"
|
||||||
switch environment {
|
switch environment {
|
||||||
case "production", "prod":
|
case "production", "prod":
|
||||||
|
if err := os.MkdirAll(logDir, 0777); err != nil {
|
||||||
|
log.Panic(err)
|
||||||
|
}
|
||||||
writer, err := rotatelogs.New(
|
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.WithLinkName("access_log"),
|
||||||
// rotatelogs.WithMaxAge(24 * time.Hour),
|
// rotatelogs.WithMaxAge(24 * time.Hour),
|
||||||
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
|
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user