Skip to content

Commit

Permalink
feat: auto attach winfile prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Jun 22, 2021
1 parent 8db34e9 commit 61d2bc3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions api/internal/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"os"
"path/filepath"
"runtime"
"strings"

"github.com/tidwall/gjson"
"gopkg.in/yaml.v2"
Expand Down Expand Up @@ -192,7 +191,7 @@ func setConf() {
if config.Conf.Log.ErrorLog.FilePath != "" {
ErrorLogPath = config.Conf.Log.ErrorLog.FilePath
}
if !strings.HasPrefix(ErrorLogPath, "winfile") && !filepath.IsAbs(ErrorLogPath) {
if !filepath.IsAbs(ErrorLogPath) {
ErrorLogPath, err = filepath.Abs(filepath.Join(WorkDir, ErrorLogPath))
if err != nil {
panic(err)
Expand All @@ -203,13 +202,19 @@ func setConf() {
if config.Conf.Log.AccessLog.FilePath != "" {
AccessLogPath = config.Conf.Log.AccessLog.FilePath
}
if !strings.HasPrefix(ErrorLogPath, "winfile") && !filepath.IsAbs(AccessLogPath) {
if !filepath.IsAbs(AccessLogPath) {
AccessLogPath, err = filepath.Abs(filepath.Join(WorkDir, AccessLogPath))
if err != nil {
panic(err)
}
}

// compatible with Windows
if runtime.GOOS == "windows" {
ErrorLogPath = `winfile:///` + ErrorLogPath
AccessLogPath = `winfile:///` + AccessLogPath
}

AllowList = config.Conf.AllowList

// set degree of parallelism
Expand Down

0 comments on commit 61d2bc3

Please sign in to comment.