()
| 200 | } |
| 201 | |
| 202 | func initLogLevel() { |
| 203 | |
| 204 | if skipCoreInit() { |
| 205 | return |
| 206 | } |
| 207 | |
| 208 | // Init log level |
| 209 | stdoutLevel := runtime.LogLevel() |
| 210 | common.LogJSON = runtime.LogJSON() |
| 211 | common.LogToFile = runtime.LogToFile() |
| 212 | |
| 213 | // Making sure the log level is passed in forks |
| 214 | _ = os.Setenv("CELLS_LOG", stdoutLevel) |
| 215 | _ = os.Setenv("CELLS_LOG_TO_FILE", strconv.FormatBool(common.LogToFile)) |
| 216 | if common.LogJSON { |
| 217 | _ = os.Setenv("CELLS_LOG_JSON", "true") |
| 218 | } |
| 219 | |
| 220 | switch stdoutLevel { |
| 221 | case "info": |
| 222 | common.LogLevel = zap.InfoLevel |
| 223 | case "warn": |
| 224 | common.LogLevel = zap.WarnLevel |
| 225 | case "debug": |
| 226 | common.LogLevel = zap.DebugLevel |
| 227 | case "error": |
| 228 | common.LogLevel = zap.ErrorLevel |
| 229 | } |
| 230 | |
| 231 | ll := []log.LoggerConfig{ |
| 232 | log.DefaultStdoutLogger(stdoutLevel, common.LogJSON), |
| 233 | } |
| 234 | |
| 235 | if common.LogToFile { |
| 236 | baseDir := runtime.ApplicationWorkingDir(runtime.ApplicationDirLogs) |
| 237 | ll = append(ll, log.DefaultJsonLogger(baseDir, "")) |
| 238 | } |
| 239 | log.Init(otel.Service{}, ll, cw.RichContext) |
| 240 | log.Logger(runtime.AsCoreContext(_ctx)) |
| 241 | } |
| 242 | |
| 243 | func initLogLevelListener(ctx context.Context) { |
| 244 | _, er := broker.Subscribe(ctx, common.TopicLogLevelEvent, func(_ context.Context, message broker.Message) error { |
no test coverage detected
searching dependent graphs…