Open dstpierre opened 1 month ago
slog
does not provide the Fatal()
method, which this repository relies on. However, since there are fewer than 10 usages of Fatal()
, we can replace them with Error()
followed by os.Exit(1)
. This change allows us to share slog
globally. If this solution doesn't work, it seems we should extend slog
with Fatal()
and continue to pass a logger around.
BTW, I would like to work on this issue, could you assign it to me? @dstpierre
@andrewtyw nice and thanks for your interests.
For the .Fatal
I believe calling the slog.SetDefault(logger)
replaces the normal log
so we could replace those with log.Fatal
.
If it's cleaner, we could have an exported function in the core/logger
package, say FatalError
that calls slog
and os.Exit. That way we would have a central place to control what's happening when a Fatal
is called.
It would be nice to have slog
output nice log to the terminal and optionally write to a file based on env variable.
There's LogFilename
in the config.AppConfig
which can be used to indicate if the user wants to output to a file.
I'll assign the issue to you, feel free to open a PR and let me know if I can help with anything.
Now that Go has its own structure logger, we can drop the dependency on Zerolog and use Go's
slog
instead.I think the quikest way to do this is by removing all import of zerolog.
Might be a good opportunity to maybe get rid of all
logger
pass around and simply use the globalslog
after configuring it based on the environment variables already used to Zerolog.Couple of pointer for this tasks:
slog
has a sharable global instance.logger
field on structure and function protytope and building / fixing issue seems a good way to do this.