chore: fix typo

This commit is contained in:
Stavros
2025-11-15 11:53:04 +02:00
parent 8894064e10
commit 259069193f
5 changed files with 10 additions and 10 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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" {

View File

@@ -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)
}

View File

@@ -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()