initializeLoggers should be called once per program in init. This is also called to reset logging in a test context.
(ctx context.Context)
| 114 | |
| 115 | // initializeLoggers should be called once per program in init. This is also called to reset logging in a test context. |
| 116 | func initializeLoggers(ctx context.Context) { |
| 117 | nilAllNonConsoleLoggers() |
| 118 | // We'll initilise a default consoleLogger so we can still log stuff before/during parsing logging configs. |
| 119 | // This maintains consistent formatting (timestamps, levels, etc) in the output, |
| 120 | // and allows a single set of logging functions to be used, rather than fmt.Printf() |
| 121 | |
| 122 | // initialCollationBufferSize is set to zero for disabling log collation before |
| 123 | // initializing a logging config, and when running under a test scenario. |
| 124 | initialCollationBufferSize := 0 |
| 125 | |
| 126 | consoleLogger.Store(mustInitConsoleLogger(context.Background(), &ConsoleLoggerConfig{LogKeys: []string{logKeyNames[KeyHTTP]}, FileLoggerConfig: FileLoggerConfig{Enabled: Ptr(true), CollationBufferSize: &initialCollationBufferSize}})) |
| 127 | initExternalLoggers() |
| 128 | } |
| 129 | |
| 130 | type logFn func(ctx context.Context, format string, args ...any) |
| 131 |
no test coverage detected