digineo / texd

texd wraps TeX in a web API
MIT License
8 stars 1 forks source link

refactor: replace logger #108

Open dmke opened 10 months ago

dmke commented 10 months ago

This replaces the zap logging engine with Go 1.21's new structured logger, log/slog, or more precisely a thin wrapper around that (xlog).

The log/slog package has a few things missing, which are present in xlog:

  1. xlog provides a no-op logger, which simply discards any log output. This is extensively used in our tests.
  2. xlog has a Fatal() output method, which simply calls Error() and then os.Exit(1).
  3. xlog does not provide global convenience functions to access a default logger instance; all calls must go through a Logger instance created with New().
  4. xlog treats error values as first-class citizen. Since (log/slog).Error() is a convenience function for their default logger instance, there is no built-in way to treat errors as values. In comparison, (xlog).Error(err) constructs an slog.Attr.

Point (2) is debatable, since xlog.Fatal is only used in cmd/texd/main.go, so I'd be willing to forfeit it.

Some TODOs remain:

Issue: #1

codecov[bot] commented 10 months ago

Codecov Report

Attention: Patch coverage is 47.03390% with 125 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@7e9eb47). Learn more about missing BASE report.

Files with missing lines Patch % Lines
xlog/xlog.go 21.31% 48 Missing :warning:
cmd/texd/main.go 0.00% 32 Missing :warning:
xlog/options.go 74.19% 14 Missing and 2 partials :warning:
service/renderer.go 44.44% 10 Missing :warning:
xlog/discard.go 0.00% 8 Missing :warning:
xlog/attrs.go 0.00% 6 Missing :warning:
service/service.go 57.14% 3 Missing :warning:
refstore/nop/nop_store.go 50.00% 1 Missing :warning:
service/middleware/logging.go 88.88% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #108 +/- ## ========================================= Coverage ? 69.80% ========================================= Files ? 38 Lines ? 1984 Branches ? 0 ========================================= Hits ? 1385 Misses ? 534 Partials ? 65 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.