HealthConnectorLogProcessor class abstract
Base class for processing health connector log records.
Extend this class to create custom log processors that handle logs in specific ways (e.g., writing to console, files, or remote services).
Overview
Each processor receives HealthConnectorLog records and can:
- Filter logs by level using the levels property
- Process logs via the process method
- Control which logs to handle with shouldProcess
Example
class ConsoleLogProcessor extends HealthConnectorLogProcessor {
const ConsoleLogProcessor({
super.levels = HealthConnectorLogLevel.values,
});
@override
Future<void> process(HealthConnectorLog log) async {
print('[${log.level.name.toUpperCase()}] ${log.message}');
if (log.error != null) {
print('Error: ${log.error}');
}
}
}
Custom Filtering
Override shouldProcess for advanced filtering logic:
class ProductionLogProcessor extends HealthConnectorLogProcessor {
@override
bool shouldProcess(HealthConnectorLog log) {
// Only process errors from production loggers
return super.shouldProcess(log) &&
log.loggerName.startsWith('prod.');
}
}
See also:
- HealthConnectorLog for the log record structure
- HealthConnectorLogLevel for available log levels
- HealthConnectorLoggerConfig for configuration
@sinceV3_0_0
- Implementers
Constructors
-
HealthConnectorLogProcessor({List<
HealthConnectorLogLevel> levels = HealthConnectorLogLevel.values}) -
Creates a log processor that handles the specified
levels.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
levels
→ List<
HealthConnectorLogLevel> -
The log levels this processor will handle.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
process(
HealthConnectorLog log) → Future< void> - Processes a log record.
-
shouldProcess(
HealthConnectorLog log) → bool -
Determines whether this processor should handle the given
log. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited