loggerOut function

ResponseMiddleware loggerOut (
  1. {Logger logger: null,
  2. bool messages: false}
)

Implementation

ResponseMiddleware loggerOut({Logger logger: null, bool messages: false}) {
  return (Response res) {
    if (logger == null) logger = _defaultLogger;
    var log = res.context.get<LogRequests>(loggerContextKey);
    log.end();
    if (res.statusCode < 200 || res.statusCode > 299) {
      logger(
          '[ERROR] ${res.statusCode} ${log.message()}${_messages(res, messages)}${_errorMessages(res, messages)}');
    } else {
      logger(
          '${res.statusCode} ${log.message()}${_messages(res, messages)}');
    }
    return res;
  };
}