Optionally enable local time for logging

Introduces the option `-log-local-time` which switches to local time
for logging instead of using UTC. Also if this option is applied, a message
is being output to the log on startup about the usage of local time
to draw attention, so the user/operator can take care of anonymity in case
the logs are going to be shared.
This commit is contained in:
Waldemar Zimpel 2024-10-25 04:20:22 +02:00
parent 0e0ca8721e
commit 028ff82683
2 changed files with 17 additions and 2 deletions

View file

@ -10,7 +10,7 @@ import (
)
func NewProxyEventLogger(output io.Writer, disableStats bool) event.SnowflakeEventReceiver {
logger := log.New(output, "", log.LstdFlags|log.LUTC)
logger := log.New(output, "", log.Flags())
return &proxyEventLogger{logger: logger, disableStats: disableStats}
}
@ -21,6 +21,13 @@ type proxyEventLogger struct {
func (p *proxyEventLogger) OnNewSnowflakeEvent(e event.SnowflakeEvent) {
switch e.(type) {
case event.EventOnProxyStarting:
p.logger.Println(e.String())
if p.logger.Flags()&log.LUTC == 0 {
p.logger.Println("Local time is being used for logging. If you want to " +
"share your log, consider to modify the date/time for more anonymity.")
}
case event.EventOnProxyStats:
if !p.disableStats {
p.logger.Println(e.String())