log method

  1. @override
Future<bool> log(
  1. String level,
  2. String message, {
  3. Object? error,
  4. StackTrace? stackTrace,
  5. Map<String, dynamic>? fields,
  6. Map<String, String>? tags,
})
override

Log a message to Humio.

The level is simply some value which makes sense to you. The message is the important part of the log statement. If you want to log an error the error and stackTrace should be given. You can provide additional values using the fields.

Humio segment data into indexes called data sources. An index will be created for each unique pair of tags.

You can call this method directly - but we recommend you call it using the HumioExtensions.

Implementation

@override
Future<bool> log(
  String level,
  String message, {
  Object? error,
  StackTrace? stackTrace,
  Map<String, dynamic>? fields,
  Map<String, String>? tags,
}) async {
  for (var enricher in _enrichers) {
    var enricherFields = await enricher.enrich(
      level,
      message,
      error: error,
      stackTrace: stackTrace,
      fields: fields,
      tags: tags,
    );

    if (enricher is TagEnricher)
      tags = {
        ...tags ?? {},
        ...enricherFields,
      };
    else
      fields = {
        ...fields ?? {},
        ...enricherFields,
      };
  }

  return await base.log(
    level,
    message,
    error: error,
    stackTrace: stackTrace,
    fields: fields,
    tags: tags,
  );
}