From 259069193fb3ec2084be9c4f823a4b004410dccf Mon Sep 17 00:00:00 2001 From: Stavros Date: Sat, 15 Nov 2025 11:53:04 +0200 Subject: [PATCH] chore: fix typo --- internal/bootstrap/app_bootstrap.go | 4 ++-- internal/service/access_log_service.go | 2 +- internal/utils/app_utils.go | 2 +- internal/utils/app_utils_test.go | 10 +++++----- main.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/bootstrap/app_bootstrap.go b/internal/bootstrap/app_bootstrap.go index e634b79..eeeae63 100644 --- a/internal/bootstrap/app_bootstrap.go +++ b/internal/bootstrap/app_bootstrap.go @@ -49,7 +49,7 @@ func NewBootstrapApp(config config.Config) *BootstrapApp { func (app *BootstrapApp) Setup() error { // Log json - shoudLogJson := utils.ShoudLogJSON(os.Environ(), os.Args) + shouldLogJson := utils.ShouldLogJSON(os.Environ(), os.Args) // Parse users users, err := utils.GetUsers(app.config.Users, app.config.UsersFile) @@ -147,7 +147,7 @@ func (app *BootstrapApp) Setup() error { oauthBrokerService := service.NewOAuthBrokerService(oauthProviders) accessLogService := service.NewAccessLogService(&service.AccessLogServiceConfig{ LogFile: app.config.AccessLogFile, - LogJson: shoudLogJson, + LogJson: shouldLogJson, }) // Initialize services (order matters) diff --git a/internal/service/access_log_service.go b/internal/service/access_log_service.go index d9effa4..0c2d60c 100644 --- a/internal/service/access_log_service.go +++ b/internal/service/access_log_service.go @@ -89,7 +89,7 @@ func (als *AccessLogService) Log(log AccessLog) { Str("provider", log.Provider). Str("username", log.Username). Str("client_ip", log.ClientIP). - Int64("time", time.Now().UnixMilli()). + Int64("time", time.Now().Unix()). Bool("success", log.Success) event.Msg(log.Message) diff --git a/internal/utils/app_utils.go b/internal/utils/app_utils.go index 40f48e8..baa78d3 100644 --- a/internal/utils/app_utils.go +++ b/internal/utils/app_utils.go @@ -201,7 +201,7 @@ func GetOAuthProvidersConfig(env []string, args []string, appUrl string) (map[st return providers, nil } -func ShoudLogJSON(environ []string, args []string) bool { +func ShouldLogJSON(environ []string, args []string) bool { for _, e := range environ { pair := strings.SplitN(e, "=", 2) if len(pair) == 2 && pair[0] == "LOG_JSON" && strings.ToLower(pair[1]) == "true" { diff --git a/internal/utils/app_utils_test.go b/internal/utils/app_utils_test.go index 71c1aa0..599fa2f 100644 --- a/internal/utils/app_utils_test.go +++ b/internal/utils/app_utils_test.go @@ -279,20 +279,20 @@ func TestGetOAuthProvidersConfig(t *testing.T) { assert.DeepEqual(t, expected, result) } -func TestShoudLogJSON(t *testing.T) { +func TestShouldLogJSON(t *testing.T) { // Test with no env or args - result := utils.ShoudLogJSON([]string{"FOO=bar"}, []string{"tinyauth", "--foo-bar=baz"}) + result := utils.ShouldLogJSON([]string{"FOO=bar"}, []string{"tinyauth", "--foo-bar=baz"}) assert.Equal(t, false, result) // Test with env variable set - result = utils.ShoudLogJSON([]string{"LOG_JSON=true"}, []string{"tinyauth", "--foo-bar=baz"}) + result = utils.ShouldLogJSON([]string{"LOG_JSON=true"}, []string{"tinyauth", "--foo-bar=baz"}) assert.Equal(t, true, result) // Test with flag set - result = utils.ShoudLogJSON([]string{"FOO=bar"}, []string{"tinyauth", "--log-json=true"}) + result = utils.ShouldLogJSON([]string{"FOO=bar"}, []string{"tinyauth", "--log-json=true"}) assert.Equal(t, true, result) // Test with both env and flag set to false - result = utils.ShoudLogJSON([]string{"LOG_JSON=false"}, []string{"tinyauth", "--log-json=false"}) + result = utils.ShouldLogJSON([]string{"LOG_JSON=false"}, []string{"tinyauth", "--log-json=false"}) assert.Equal(t, false, result) } diff --git a/main.go b/main.go index 94aefe2..f5335ac 100644 --- a/main.go +++ b/main.go @@ -12,7 +12,7 @@ import ( func main() { log.Logger = log.Logger.With().Caller().Logger() - if !utils.ShoudLogJSON(os.Environ(), os.Args) { + if !utils.ShouldLogJSON(os.Environ(), os.Args) { log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: time.RFC3339}) } cmd.Run()