Consolidate log file env vars: AWP_LOG_FILE (web) and AWP_CLI_LOG_FILE (CLI)
Removes the duplicate log setup from cli/cmd/root.go that was reading AWP_LOG_FILE — log file config now lives only in each binary's main.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
01d2cae282
commit
fc5c986141
3 changed files with 2 additions and 12 deletions
|
|
@ -1,8 +1,6 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
|
|
@ -15,14 +13,6 @@ var rootCmd = &cobra.Command{
|
|||
Long: `CLI utility for Are We Playing? web app`,
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||
godotenv.Load()
|
||||
logFile := os.Getenv("AWP_LOG_FILE")
|
||||
if len(logFile) > 0 {
|
||||
f, err := os.OpenFile(logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to open log file %s: %w", logFile, err)
|
||||
}
|
||||
log.SetOutput(f)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
func main() {
|
||||
godotenv.Load()
|
||||
|
||||
logFile := os.Getenv("CLI_LOG_FILE")
|
||||
logFile := os.Getenv("AWP_CLI_LOG_FILE")
|
||||
if len(logFile) > 0 {
|
||||
utils.SetLogFile(logFile)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func main() {
|
|||
log.Fatal("unable to load APP_KEY")
|
||||
}
|
||||
|
||||
logFile := os.Getenv("WEB_LOG_FILE")
|
||||
logFile := os.Getenv("AWP_LOG_FILE")
|
||||
if len(logFile) > 0 {
|
||||
utils.SetLogFile(logFile)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue