error method

Future<void> error(
  1. String message, [
  2. List<String> tags = const []
])
inherited

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 log
  • tags - Additional tags to merge with loggerTags

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);
}