Skip to content

Commit 9f11e94

Browse files
committed
[TASK] Add option to enable logging on run.
1 parent e1ff479 commit 9f11e94

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Utilities/Utility.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,11 @@ func GetInlineDialogSize(window fyne.Window, marginSize fyne.Size, minSize fyne.
299299
}
300300
return windowSize
301301
}
302+
303+
func ParseBoolean(value string) (bool, error) {
304+
booleanValue, err := strconv.ParseBool(value)
305+
if err != nil {
306+
return false, fmt.Errorf("invalid boolean value: %s", value)
307+
}
308+
return booleanValue, nil
309+
}

main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ func main() {
114114
//whisperProcess.SettingsFile = Settings.Config.SettingsFilename
115115
//RuntimeBackend.BackendsList = append(RuntimeBackend.BackendsList, whisperProcess)
116116

117+
// allow enabling logging via environment variable
118+
loggingVal, loggingOk := os.LookupEnv("ENABLE_LOGGING")
119+
if loggingOk {
120+
if loggingVal != "" {
121+
enableLogging, err := Utilities.ParseBoolean(loggingVal)
122+
if err != nil {
123+
log.Printf("Error parsing ENABLE_LOGGING: %v", err)
124+
enableLogging = true // default to true if parsing fails
125+
}
126+
fyne.CurrentApp().Preferences().SetBool("WriteLogfile", enableLogging)
127+
}
128+
}
129+
117130
profileWindow := a.NewWindow(lang.L("Whispering Tiger Profiles"))
118131

119132
onProfileClose := func() {

0 commit comments

Comments
 (0)