MCPcopy Create free account
hub / github.com/pydio/cells / initLogLevel

Function initLogLevel

cmd/root.go:202–241  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

200}
201
202func 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
243func initLogLevelListener(ctx context.Context) {
244 _, er := broker.Subscribe(ctx, common.TopicLogLevelEvent, func(_ context.Context, message broker.Message) error {

Callers 1

start.goFile · 0.85

Calls 10

LogLevelFunction · 0.92
LogJSONFunction · 0.92
LogToFileFunction · 0.92
DefaultStdoutLoggerFunction · 0.92
ApplicationWorkingDirFunction · 0.92
DefaultJsonLoggerFunction · 0.92
InitFunction · 0.92
LoggerFunction · 0.92
AsCoreContextFunction · 0.92
skipCoreInitFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…