Skip to content

Commit 218aeca

Browse files
committed
Add timeZone configuration to LOGLYNX_CONFIG in header template
1 parent 0a6df83 commit 218aeca

File tree

13 files changed

+5029
-4818
lines changed

13 files changed

+5029
-4818
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,7 @@ GEOIP_CACHE_SIZE=10000 #Loaded but not implemented yet (reserved for future LRU
9696
BATCH_SIZE=1000
9797

9898
# Number of worker goroutines for log processing
99-
WORKER_POOL_SIZE=4
99+
WORKER_POOL_SIZE=4
100+
101+
#Timezone
102+
TIMEZONE=UTC

cmd/server/main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ func main() {
6767
logger.WithCaller().Fatal("Failed to load configuration", logger.Args("error", err))
6868
}
6969

70+
// Initialize TimeZone and set time.Local
71+
if cfg.Server.TimeZone != "" && strings.ToUpper(cfg.Server.TimeZone) != "UTC" {
72+
loc, err := time.LoadLocation(cfg.Server.TimeZone)
73+
if err != nil {
74+
logger.Warn("Failed to load configured timezone, falling back to UTC",
75+
logger.Args("timezone", cfg.Server.TimeZone, "error", err))
76+
} else {
77+
time.Local = loc
78+
logger.Info("Dashboard timezone initialized", logger.Args("timezone", cfg.Server.TimeZone))
79+
}
80+
} else {
81+
// Ensure UTC if not specified or explicitly set to UTC
82+
time.Local = time.UTC
83+
logger.Info("Dashboard timezone set to UTC")
84+
}
85+
7086
// Apply configured log level from environment variable LOG_LEVEL (default: info)
7187
// Supported values: trace, debug, info, warn, error, fatal
7288
lvl := strings.ToLower(cfg.LogLevel)

0 commit comments

Comments
 (0)