summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_router_access_log.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2024-11-14http: Support JSON format in access logZhidao HONG1-15/+179
Allow format to be an object to generate JSON logs. The object keys become JSON field names, and values support string, variable, and JS. Note that when there is no JS in the format values, the object will be pre-serialized to a JSON template string at configuration phase for better performance. Example config: { "access_log": { "path": "/tmp/access.log", "format": { "remote_addr": "$remote_addr", "time_local": "$time_local", "request_line": "$request_line", "status": "$status", "body_bytes_sent": "$body_bytes_sent", "header_referer": "$header_referer", "header_user_agent": "$header_user_agent" } } }
2024-11-14http: Introduce nxt_router_access_log_format_t structureZhidao HONG1-18/+48
This is a preparatory refactoring for upcoming JSON format support in access log. We will extend format option to access object for JSON support. No functional changes.
2024-11-14http: Refactor format field in nxt_router_access_log_conf_tZhidao HONG1-12/+15
This is a preparatory refactoring for upcoming JSON format support in access log. No functional changes.
2024-10-22Fix missing newlines in access logs for JS configurationZhidao HONG1-13/+2
When using JS configuration for the "format" option, access log entries were being written without newline characters. This commit adds the missing newline character to each log entry. Closes: https://github.com/nginx/unit/issues/1458
2024-08-20http: Refactor out nxt_tstr_cond_t from the access log moduleZhidao HONG1-9/+2
This nxt_tstr_cond_t will be reused for the feature of adding "if" option to the "match" object. The two "if" options have the same usage.
2024-08-20http: Refactor access log writeZhidao HONG1-25/+11
2024-04-25Constify a bunch of static local variablesAndrew Clayton1-1/+1
A common pattern was to declare variables in functions like static nxt_str_t ... Not sure why static, as they were being treated more like string literals (and of course they are _not_ thread safe), let's actually make them constants (qualifier wise). This handles core code conversion. Reviewed-by: Zhidao HONG <z.hong@f5.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
2024-01-29HTTP: enhanced access log with conditional filtering.Zhidao HONG1-0/+25
This feature allows users to specify conditions to control if access log should be recorded. The "if" option supports a string and JavaScript code. If its value is empty, 0, false, null, or undefined, the logs will not be recorded. And the '!' as a prefix inverses the condition. Example 1: Only log requests that sent a session cookie. { "access_log": { "if": "$cookie_session", "path": "..." } } Example 2: Do not log health check requests. { "access_log": { "if": "`${uri == '/health' ? false : true}`", "path": "..." } } Example 3: Only log requests when the time is before 22:00. { "access_log": { "if": "`${new Date().getHours() < 22}`", "path": "..." } } or { "access_log": { "if": "!`${new Date().getHours() >= 22}`", "path": "..." } } Closes: https://github.com/nginx/unit/issues/594
2022-11-20Basic njs support.Zhidao HONG1-1/+1
2022-11-20Var: separating nxt_tstr_t from nxt_var_t.Zhidao HONG1-12/+15
It's for the introduction of njs support. For each option that supports native variable and JS template literals introduced next, it's unified as template string. No functional changes.
2022-07-28Log: customizable access log format.Zhidao HONG1-117/+113
2022-07-14Log: split access log from nxt_router.c.Zhidao HONG1-0/+446
No functional changes.