Skip to content

Commit 1191e1f

Browse files
committed
added logging from #132 by @anasinnyk
1 parent 36dcf39 commit 1191e1f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

internal/utils/utils.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,27 @@ package utils
33
import (
44
"errors"
55
"fmt"
6+
"log"
67
"os"
8+
"strings"
79
)
810

11+
var verbose bool
12+
13+
func init() {
14+
verboseEnv := GetOSVar("VERBOSE")
15+
verbose = strings.ToLower(verboseEnv) == "true" || verboseEnv == "1"
16+
}
17+
918
func RespError(err error) error {
1019
if err != nil {
11-
errMsg := fmt.Sprintf("there was an error during the call execution: %s\n", err)
20+
errMsg := fmt.Sprintf("there was an error during the call execution: %s", err)
21+
22+
if verbose {
23+
log.SetOutput(os.Stderr)
24+
log.Printf("ERROR: %s", errMsg)
25+
}
26+
1227
return errors.New(errMsg)
1328
}
1429
return nil

0 commit comments

Comments
 (0)