SetupAndValidateLogging validates logging config and initializes all logging.
(ctx context.Context)
| 1420 | |
| 1421 | // SetupAndValidateLogging validates logging config and initializes all logging. |
| 1422 | func (sc *StartupConfig) SetupAndValidateLogging(ctx context.Context) (err error) { |
| 1423 | |
| 1424 | base.SetRedaction(sc.Logging.RedactionLevel) |
| 1425 | |
| 1426 | if sc.Logging.LogFilePath == "" { |
| 1427 | sc.Logging.LogFilePath = defaultLogFilePath |
| 1428 | } |
| 1429 | |
| 1430 | var auditLoggingFields map[string]any |
| 1431 | if sc.Unsupported.AuditInfoProvider != nil && sc.Unsupported.AuditInfoProvider.GlobalInfoEnvVarName != nil { |
| 1432 | v := os.Getenv(*sc.Unsupported.AuditInfoProvider.GlobalInfoEnvVarName) |
| 1433 | err := base.JSONUnmarshal([]byte(v), &auditLoggingFields) |
| 1434 | if err != nil { |
| 1435 | return fmt.Errorf("Unable to unmarshal audit info from environment variable %s=%s %w", *sc.Unsupported.AuditInfoProvider.GlobalInfoEnvVarName, v, err) |
| 1436 | } |
| 1437 | } |
| 1438 | return base.InitLogging(ctx, |
| 1439 | sc.Logging.LogFilePath, |
| 1440 | sc.Logging.Console, |
| 1441 | sc.Logging.Error, |
| 1442 | sc.Logging.Warn, |
| 1443 | sc.Logging.Info, |
| 1444 | sc.Logging.Debug, |
| 1445 | sc.Logging.Trace, |
| 1446 | sc.Logging.Stats, |
| 1447 | sc.Logging.Audit, |
| 1448 | auditLoggingFields, |
| 1449 | ) |
| 1450 | } |
| 1451 | |
| 1452 | func SetMaxFileDescriptors(ctx context.Context, maxP *uint64) error { |
| 1453 | maxFDs := DefaultMaxFileDescriptors |