From 258966dd104acb621477ca594d0c9fb3291fa98c Mon Sep 17 00:00:00 2001 From: Spotlightsrule <19472287+Spotlightsrule@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:34:33 +0000 Subject: [PATCH] Fix File Logger The file `logy.log` would be erroneously created, even if the filename was changed or the file logging component was disabled. This commit fixes this issue and sets all created log files to be non-executable (ie: perm 0644). --- file.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/file.go b/file.go index 1c90f28..ec68b19 100644 --- a/file.go +++ b/file.go @@ -43,7 +43,7 @@ func (h *FileHandler) FilePath() string { func (h *FileHandler) createLogFile(dir, name string) (*os.File, error) { path := filepath.FromSlash(filepath.Join(dir, name)) - return os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0755) + return os.OpenFile(path, os.O_WRONLY|os.O_CREATE, 0644) } func (h *FileHandler) OnConfigure(config Config) error { @@ -63,7 +63,7 @@ func (h *FileHandler) OnConfigure(config Config) error { discarded := false - if !underTest { + if !underTest && h.IsEnabled() { file, err = h.createLogFile(config.File.Path, config.File.Name) if err != nil { h.SetEnabled(false)