Skip to content

Commit

Permalink
correct flags for log file
Browse files Browse the repository at this point in the history
Signed-off-by: seiya <20365512+seiyab@users.noreply.github.com>
  • Loading branch information
seiyab committed Feb 17, 2024
1 parent cb801fc commit 1c070e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions adapter/logrus/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ func Use(l *logrus.Logger, cfg Config) (iface.Logger, error) {
var output io.Writer
switch {
case cfg.EnableConsole && cfg.FileLocation != "":
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, defaultLogFilePermissions)
if err != nil {
return nil, fmt.Errorf("unable to setup log file: %w", err)
}
output = io.MultiWriter(os.Stderr, logFile)
case cfg.EnableConsole:
output = os.Stderr
case cfg.FileLocation != "":
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE, defaultLogFilePermissions)
logFile, err := os.OpenFile(cfg.FileLocation, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, defaultLogFilePermissions)
if err != nil {
return nil, fmt.Errorf("unable to setup log file: %w", err)
}
Expand Down

0 comments on commit 1c070e3

Please # to comment.