timeLogDecorator function

LogDecorator timeLogDecorator({
  1. String separator = ' ',
  2. Adapter<String, String>? wrapper,
  3. Adapter<DateTime, String> formatter = _defaultFormatter,
})

A log decorator that add time of the record behind the log-message

Implementation

LogDecorator timeLogDecorator({
  String separator = ' ',
  Adapter<String, String>? wrapper,
  Adapter<DateTime, String> formatter = _defaultFormatter,
}) {
  return (message, record) {
    final buffer = StringBuffer();
    final formattedTime = formatter(record.time);
    buffer
      ..write(wrapper?.call(formattedTime) ?? formattedTime)
      ..write(separator)
      ..write(message);
    return buffer.toString();
  };
}