Some bug fixes:

- logging: LogToFile shadowed the package-level fileLogger, so
  IsFileLogger was always false and Shutdown never closed the file
- logging: replace IsJSONHandler's unsafe reflection into slog
  internals with a *slog.JSONHandler type check
- cli: fail if the log file can't be opened instead of silently
  logging to the terminal; return the log shutdown error from Finish
- build.sh: -X flags used the wrong module path, so the version, build
  time and commit were never stamped
This commit is contained in:
bwilliams committed 2026-10-09 17:58:48 +01:00
1 parent 399eccf2de
commit dcb714dc19
7 files changed
+24 -45

No files matched your search

+4 -3
View File
@@ -1,6 +1,7 @@
package cli
import (
"fmt"
"log/slog"
"git.avsdev.uk/Go/job-search/internal/config"
@@ -58,8 +59,8 @@ func (o *Options) RunSetup(
if !terminalLog {
if len(conf.Logging.File) == 0 {
slog.Warn("No log file configured, remaining in console logging mode!")
} else {
logging.LogToFile(conf.Logging.File)
} else if err := logging.LogToFile(conf.Logging.File); err != nil {
return nil, fmt.Errorf("opening log file: %w", err)
}
}
}
@@ -70,7 +71,7 @@ func (o *Options) RunSetup(
// Finish shuts down any open file logger
func (o *Options) Finish() error {
if logging.IsFileLogger() {
logging.Shutdown()
return logging.Shutdown()
}
return nil