[mirror] Scalable static site server for Git forges (like GitHub Pages)

[breaking-change] Remove the `log-level` config option.

This reverts commit 351d0a0c85a946d5a453b36ffbc5fe8a64f52a5f.

This option does not have any effect at the moment and may potentially
confuse users. It can be easily reintroduced later (by reverting this
commit) once we start logging at any level other than `info`.

miyuko 91f05e21 bc70cba2

Changed files
+2 -33
conf
src
-1
conf/config.example.toml
··· 2 # as the intrinsic default value. 3 4 log-format = "text" 5 - log-level = "info" 6 7 [server] 8 # Use "-" to disable the handler.
··· 2 # as the intrinsic default value. 3 4 log-format = "text" 5 6 [server] 7 # Use "-" to disable the handler.
-1
src/config.go
··· 63 Insecure bool `toml:"-" env:"insecure"` 64 Features []string `toml:"features"` 65 LogFormat string `toml:"log-format" default:"text"` 66 - LogLevel string `toml:"log-level" default:"info"` 67 Server ServerConfig `toml:"server"` 68 Wildcard []WildcardConfig `toml:"wildcard"` 69 Fallback FallbackConfig `toml:"fallback"`
··· 63 Insecure bool `toml:"-" env:"insecure"` 64 Features []string `toml:"features"` 65 LogFormat string `toml:"log-format" default:"text"` 66 Server ServerConfig `toml:"server"` 67 Wildcard []WildcardConfig `toml:"wildcard"` 68 Fallback FallbackConfig `toml:"fallback"`
+2 -31
src/observe.go
··· 13 "os" 14 "runtime/debug" 15 "strconv" 16 - "strings" 17 "sync" 18 "time" 19 ··· 62 63 logHandlers := []slog.Handler{} 64 65 - logLevel := slog.LevelInfo 66 - switch strings.ToLower(config.LogLevel) { 67 - case "debug": 68 - logLevel = slog.LevelDebug 69 - case "info": 70 - logLevel = slog.LevelInfo 71 - case "warn": 72 - logLevel = slog.LevelWarn 73 - case "error": 74 - logLevel = slog.LevelError 75 - default: 76 - log.Println("unknown log level", config.LogLevel) 77 - } 78 - 79 switch config.LogFormat { 80 case "none": 81 // nothing to do 82 case "text": 83 logHandlers = append(logHandlers, 84 - slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel})) 85 case "json": 86 logHandlers = append(logHandlers, 87 - slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{Level: logLevel})) 88 default: 89 log.Println("unknown log format", config.LogFormat) 90 } ··· 93 var err error 94 syslogHandler, err = syslog.NewHandler(&syslog.HandlerOptions{ 95 Address: syslogAddr, 96 - Level: logLevel, 97 AppName: "git-pages", 98 StructuredDataID: "git-pages", 99 }) ··· 154 if enableLogs { 155 logHandlers = append(logHandlers, sentryslog.Option{ 156 AddSource: true, 157 - LogLevel: levelsFromMinimum(logLevel), 158 }.NewSentryHandler(context.Background())) 159 } 160 } 161 162 slog.SetDefault(slog.New(slogmulti.Fanout(logHandlers...))) 163 - } 164 - 165 - // From sentryslog, because for some reason they don't make it public. 166 - func levelsFromMinimum(minLevel slog.Level) []slog.Level { 167 - allLevels := []slog.Level{slog.LevelDebug, slog.LevelInfo, slog.LevelWarn, slog.LevelError, sentryslog.LevelFatal} 168 - var result []slog.Level 169 - for _, level := range allLevels { 170 - if level >= minLevel { 171 - result = append(result, level) 172 - } 173 - } 174 - return result 175 } 176 177 func FiniObservability() {
··· 13 "os" 14 "runtime/debug" 15 "strconv" 16 "sync" 17 "time" 18 ··· 61 62 logHandlers := []slog.Handler{} 63 64 switch config.LogFormat { 65 case "none": 66 // nothing to do 67 case "text": 68 logHandlers = append(logHandlers, 69 + slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{})) 70 case "json": 71 logHandlers = append(logHandlers, 72 + slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{})) 73 default: 74 log.Println("unknown log format", config.LogFormat) 75 } ··· 78 var err error 79 syslogHandler, err = syslog.NewHandler(&syslog.HandlerOptions{ 80 Address: syslogAddr, 81 AppName: "git-pages", 82 StructuredDataID: "git-pages", 83 }) ··· 138 if enableLogs { 139 logHandlers = append(logHandlers, sentryslog.Option{ 140 AddSource: true, 141 }.NewSentryHandler(context.Background())) 142 } 143 } 144 145 slog.SetDefault(slog.New(slogmulti.Fanout(logHandlers...))) 146 } 147 148 func FiniObservability() {