TUN-3756: File logging output must consider the directory

This commit is contained in:
Nuno Diegues 2021-01-14 11:53:35 +00:00
parent 1c9f3ac7d4
commit 391facbedf
1 changed files with 3 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import (
"io"
"os"
"path"
"path/filepath"
"github.com/mattn/go-colorable"
"github.com/rs/zerolog"
@ -159,7 +160,8 @@ func createLogFile(config FileConfig) (io.Writer, error) {
mode := os.FileMode(filePermMode)
logFile, err := os.OpenFile(config.Filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode)
fullPath := filepath.Join(config.Dirname, config.Filename)
logFile, err := os.OpenFile(fullPath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode)
if err != nil {
return nil, fmt.Errorf("unable to create a new logfile: %s", err)
}