error method
Logs an error message with automatic tag merging.
Error messages indicate failures, exceptions, or other conditions
that prevent normal operation and require immediate attention.
The class's loggerTags
are automatically included.
Example:
await error('Failed to process payment: ${exception.message}', ['critical']);
Parameters:
message
- The error message to logtags
- Additional tags to merge withloggerTags
Best Practices:
- Include exception details and relevant context
- Add stack traces in development environments
- Tag with severity indicators ('critical', 'recoverable')
- Consider triggering alerts for critical errors
- Include correlation IDs for distributed systems
Throws:
LoggerException
if the global logger has been disposed
Implementation
Future<void> error(String message, [List<String> tags = const []]) async {
await log(message, type: LogType.error, tags: tags);
}