You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type `text/html`, `text/plain` and `application/json`.
111
111
*`display_errors` - return application errors and backtraces to the client
112
112
(like PHP).
113
-
*`log_errors` - log application errors using `log.error()`.
114
-
*`log_requests` - log incoming requests.
113
+
*`log_requests` - log incoming requests. This parameter can receive:
114
+
- function value, supporting C-style formatting: log_requests(fmt, ...), where fmt is a format string and ... is Lua Varargs, holding arguments to be replaced in fmt.
115
+
- boolean value, where `true` choose default `log.info` and `false` disable request logs at all.
116
+
117
+
By default uses `log.info` function for requests logging.
118
+
*`log_errors` - same as the `log_requests` option but is used for error messages logging. By default uses `log.error()` function.
115
119
116
120
## Using routes
117
121
@@ -158,6 +162,8 @@ The first argument for `route()` is a Lua table with one or more keys:
158
162
*`path` - route path, as described earlier.
159
163
*`name` - route name.
160
164
*`method` - method on the route like `POST`, `GET`, `PUT`, `DELETE`
165
+
*`log_requests` - option that overrides the server parameter of the same name but only for current route.
166
+
*`log_errors` - option that overrides the server parameter of the same name but only for current route.
161
167
162
168
The second argument is the route handler to be used to produce
test:is_deeply(find_msg_in_log_queue("GET /"), { log_lvl='info', msg='GET /' }, "Route can override logging requests if the http server have turned off 'log_requests' option")
503
+
clear_log_queue()
504
+
505
+
httpd:stop()
506
+
end)
507
+
508
+
test:test("Log route requests with turned off 'log_errors' option", function(test)
test:ok(find_msg_in_log_queue("User business logic exception...", false), "Route can override logging requests if the http server have turned off 'log_errors' option")
0 commit comments