Skip to content

Commit

Permalink
fix: Verbose flag and PrintVerbose work as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Aug 8, 2023
1 parent 6793864 commit b04f9cf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ package core

import (
"fmt"
"log"
"os"
"path/filepath"
"time"

"github.com/vanilla-os/orchid/cmdr"
)

var logFile *os.File

var printLog = log.New(os.Stdout, "(Verbose) ", 0)

func init() {
PrintVerboseNoLog("NewLogFile: running...")

Expand Down Expand Up @@ -57,8 +62,9 @@ func init() {
}

func IsVerbose() bool {
_, res := os.LookupEnv("ABROOT_VERBOSE")
return res
flag := cmdr.FlagValBool("verbose")
_, arg := os.LookupEnv("ABROOT_VERBOSE")
return flag || arg
}

func PrintVerbose(msg string, args ...interface{}) {
Expand All @@ -71,8 +77,8 @@ func PrintVerbose(msg string, args ...interface{}) {

func PrintVerboseNoLog(msg string, args ...interface{}) {
if IsVerbose() {
fmt.Printf("(Verbose) "+msg, args...)
fmt.Println()
printLog.Printf(msg, args...)
printLog.Println()
}
}

Expand Down

0 comments on commit b04f9cf

Please sign in to comment.