@@ -53,33 +53,35 @@ func initLog() error {
5353 for _ , ext := range extensions {
5454 files = append (files , filepath .Join (c .LocalDir , "log" + ext ))
5555 }
56-
57- if c .Profiles != "" {
58- profile : = strings .TrimSpace (strings . Split ( c . Profiles , "," )[ 0 ])
59- if profile != "" {
60- for _ , ext := range extensions {
61- files = append ( files , filepath . Join ( c . LocalDir , "log-" + profile + ext ))
56+ if c . Profiles = strings . TrimSpace ( c . Profiles ); c . Profiles != "" {
57+ for s := range strings . SplitSeq ( c .Profiles , "," ) {
58+ if s = strings .TrimSpace (s ); s != "" {
59+ for _ , ext := range extensions {
60+ files = append ( files , filepath . Join ( c . LocalDir , "log-" + s + ext ))
61+ }
6262 }
6363 }
6464 }
6565
6666 // Determine which log configuration file to use.
67- var logFile string
67+ var logFiles [] string
6868 for _ , s := range files {
6969 if ok , err := util .PathExists (s ); err != nil {
7070 return err
7171 } else if ! ok {
7272 continue
7373 }
74- logFile = s
74+ logFiles = append ( logFiles , s )
7575 break
7676 }
7777
7878 // If no configuration file exists, leave the logger as default.
79- if logFile == "" {
79+ if n := len ( logFiles ); n == 0 {
8080 return nil
81+ } else if n > 1 {
82+ return util .FormatError (nil , "multiple log files found: %s" , logFiles )
8183 }
8284
8385 // Refresh the logger configuration from the selected file.
84- return log .RefreshFile (logFile )
86+ return log .RefreshFile (logFiles [ 0 ] )
8587}
0 commit comments