Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1002)

Unified Diff: lib/src/handlers/logger.dart

Issue 2281723002: Improve the documentation of logRequests(). (Closed) Base URL: git@github.com:dart-lang/shelf@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/handlers/logger.dart
diff --git a/lib/src/handlers/logger.dart b/lib/src/handlers/logger.dart
index 9f76f6c91f577cdc41028c1783ad8316eb76fa2c..98866d56c2c9f07c249aac37acffdb5dd3b9cb7f 100644
--- a/lib/src/handlers/logger.dart
+++ b/lib/src/handlers/logger.dart
@@ -12,15 +12,13 @@ import '../middleware.dart';
/// Middleware which prints the time of the request, the elapsed time for the
/// inner handlers, the response's status code and the request URI.
///
-/// [logger] takes two parameters.
+/// If [logger] is passed, it's called for each request. The `msg` parameter is
+/// a formatted string that includes the request time, duration, request method,
+/// and requested path. When an exception is thrown, it also includes the
+/// exception's string and stack trace; otherwise, it includes the status code.
+/// The `isError` parameter indicates whether the message is caused by an error.
///
-/// `msg` includes the request time, duration, request method, and requested
-/// path.
-///
-/// For successful requests, `msg` also includes the status code.
-///
-/// When an error is thrown, `isError` is true and `msg` contains the error
-/// description and stack trace.
+/// If [logger] is not passed, the message is just passed to [print].
Middleware logRequests({void logger(String msg, bool isError)}) =>
(innerHandler) {
if (logger == null) logger = _defaultLogger;
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698