Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
log: not rotate log file when startup
Browse files Browse the repository at this point in the history
Signed-off-by: lowzj <[email protected]>
  • Loading branch information
lowzj committed Sep 18, 2019
1 parent 9114104 commit de058d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 0 additions & 1 deletion cmd/dfdaemon/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func initLogger(cfg config.Properties) error {
dflog.WithLogFile(logFilePath),
dflog.WithSign(fmt.Sprintf("%d", os.Getpid())),
dflog.WithDebug(cfg.Verbose),
dflog.WithConsole(),
}

logrus.Debugf("use log file %s", logFilePath)
Expand Down
15 changes: 8 additions & 7 deletions dfget/core/downloader/p2p_downloader/p2p_downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,14 @@ func (p2p *P2PDownloader) Run() error {
} else if code == constants.CodePeerFinish {
p2p.finishTask(response, clientWriter)
return nil
} else if code == constants.CodePeerWait {
continue
}

logrus.Warnf("request piece result:%v", response)
if code == constants.CodeSourceError {
p2p.cfg.BackSourceReason = config.BackSourceReasonSourceError
} else {
logrus.Warnf("request piece result:%v", response)
if code == constants.CodePeerWait {
continue
}
if code == constants.CodeSourceError {
p2p.cfg.BackSourceReason = config.BackSourceReasonSourceError
}
}
}

Expand Down
5 changes: 1 addition & 4 deletions pkg/dflog/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func WithLogFile(f string) Option {
if logger := getLumberjack(l); logger == nil {
l.SetOutput(&lumberjack.Logger{
Filename: f,
MaxSize: 20, // mb
MaxSize: 40, // mb
MaxBackups: 1,
})
} else {
Expand Down Expand Up @@ -124,9 +124,6 @@ func Init(l *logrus.Logger, opts ...Option) error {
return err
}
}
if logger, ok := l.Out.(*lumberjack.Logger); ok {
return logger.Rotate()
}
return nil
}

Expand Down

0 comments on commit de058d6

Please sign in to comment.