MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / SetupAndValidateLogging

Method SetupAndValidateLogging

rest/config.go:1422–1450  ·  view source on GitHub ↗

SetupAndValidateLogging validates logging config and initializes all logging.

(ctx context.Context)

Source from the content-addressed store, hash-verified

1420
1421// SetupAndValidateLogging validates logging config and initializes all logging.
1422func (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
1452func SetMaxFileDescriptors(ctx context.Context, maxP *uint64) error {
1453 maxFDs := DefaultMaxFileDescriptors

Callers 12

TestDefaultLoggingFunction · 0.80
TestAuditLoggingFieldsFunction · 0.80
TestEffectiveUserIDFunction · 0.80
TestAuditLoggingGlobalsFunction · 0.80
SetupServerContextFunction · 0.80
TestLogFlushFunction · 0.80
TestConfigEndpointFunction · 0.80

Calls 4

SetRedactionFunction · 0.92
JSONUnmarshalFunction · 0.92
InitLoggingFunction · 0.92
ErrorfMethod · 0.80

Tested by 11

TestDefaultLoggingFunction · 0.64
TestAuditLoggingFieldsFunction · 0.64
TestEffectiveUserIDFunction · 0.64
TestAuditLoggingGlobalsFunction · 0.64
TestLogFlushFunction · 0.64
TestConfigEndpointFunction · 0.64