LogShield class

Singleton log sanitization manager.

Automatically sanitizes PII from all log output. Drop-in replacement for print() and debugPrint().

LogShield().init(LogShieldConfig(silentInRelease: true));
LogShield().log('User email: john@test.com');
// Output: [INFO] User email: [EMAIL HIDDEN]

Constructors

LogShield()
Returns the singleton LogShield instance.
factory

Properties

config → LogShieldConfig
The current configuration.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isEnabled → bool
Whether the log shield is currently enabled.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

disable() → void
Disables all log output.
enable() → void
Enables log output.
init(LogShieldConfig config) → void
Initializes the LogShield with the given config.
log(String message, {String level = 'INFO', String? tag}) → void
Sanitizes and logs a message with an optional level and tag.
logError(String message, {Object? error, StackTrace? stackTrace}) → void
Sanitizes and logs an error message with optional error and stackTrace.
logJson(String label, Map<String, dynamic> json) → void
Sanitizes and logs a JSON map with a label.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Resets the LogShield to its default state.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited