diff --git a/internal/infrastructure/bootstrap/config_log.go b/internal/infrastructure/bootstrap/config_log.go new file mode 100644 index 0000000..17ceb0e --- /dev/null +++ b/internal/infrastructure/bootstrap/config_log.go @@ -0,0 +1,45 @@ +package bootstrap + +import ( + "log/slog" +) + +// logConfig logs the key configuration values when the server starts. +// Sensitive values like passwords and secrets are not logged. +func logConfig() { + slog.Info("Configuration loaded", + "mode", mode, + "log.level", config.GetString(configKeyLogLevel), + "log.format", config.GetString(configKeyLogFormat), + ) + + // Log server configuration based on the command + switch cmdName { + case "grpc": + logGRPCConfig() + case "gateway": + logGatewayConfig() + } +} + +func logGRPCConfig() { + slog.Info("gRPC server configuration", + "grpc_port", config.GetUint("grpc_port"), + "persistence.type", config.GetString("persistence.type"), + "persistence.gorm.driver", config.GetString("persistence.gorm.driver"), + "persistence.gorm.dbname", config.GetString("persistence.gorm.dbname"), + "redis.urls", config.GetStringSlice("redis.urls"), + "smtp_mailer.host", config.GetString("smtp_mailer.host"), + "smtp_mailer.port", config.GetInt("smtp_mailer.port"), + "auth.oauth_state_expiration", config.GetString("auth.oauth_state_expiration"), + "auth.access_token_expiration", config.GetString("auth.access_token_expiration"), + "auth.refresh_token_expiration", config.GetString("auth.refresh_token_expiration"), + "auth.token_issuer", config.GetString("auth.token_issuer"), + ) +} + +func logGatewayConfig() { + slog.Info("Gateway server configuration", + "http_port", config.GetUint("http_port"), + ) +} diff --git a/internal/infrastructure/bootstrap/init.go b/internal/infrastructure/bootstrap/init.go index af58df2..e39681d 100644 --- a/internal/infrastructure/bootstrap/init.go +++ b/internal/infrastructure/bootstrap/init.go @@ -27,6 +27,7 @@ func Init(cmd string) { workdir, _ := os.Getwd() initConfig(path.Join(workdir, "configs")) initLog() + logConfig() slog.Info("APP initialized") } @@ -39,5 +40,6 @@ func InitWithConfigPath(cmd string, configPath string) { } initConfig(configPath) initLog() + logConfig() slog.Info("APP initialized") }