Theia API Documentation v1.68.0
    Preparing search index...

    Service for sanitizing log messages to remove sensitive information.

    Adopters can rebind this service to customize sanitization behavior, for example to mask additional patterns like API keys or tokens.

    // Custom sanitizer that extends the default behavior
    @injectable()
    class CustomLoggerSanitizer extends DefaultLoggerSanitizer {
    override sanitize(message: string): string {
    let sanitized = super.sanitize(message);
    // Add custom sanitization, e.g., mask API keys
    sanitized = sanitized.replace(/api[_-]?key[=:]\s*['"]?[\w-]+['"]?/gi, 'api_key=****');
    return sanitized;
    }
    }

    // In your module:
    rebind(LoggerSanitizer).to(CustomLoggerSanitizer).inSingletonScope();
    interface LoggerSanitizer {
        sanitize(message: string): string;
    }

    Implemented by

    Index

    Methods

    Methods

    • Sanitizes a log message by masking sensitive information.

      Parameters

      • message: string

        The log message to sanitize

      Returns string

      The sanitized message with sensitive data masked