Add missing identity position for Common and Combined formats

This commit is contained in:
Forza 2024-10-08 20:50:37 +02:00
parent ae760f4abd
commit 40dc4c2e3c

View File

@ -3,7 +3,7 @@
# shellcheck shell=bash # shellcheck shell=bash
# Caddy webserver JSON log parser # Caddy webserver JSON log parser
# version 0.1.0 # version 0.1.1
# #
# This script reads a Caddy logfile in JSON format and # This script reads a Caddy logfile in JSON format and
# outputs it in Apache Common Log Format. # outputs it in Apache Common Log Format.
@ -270,32 +270,34 @@ case "$format" in
common) common)
# Common Log format # Common Log format
log_format \ log_format \
client_ip \ client_ip \
space user_id \ space hyphen \
space lsqb datetime rsqb \ space user_id \
space quote method \ space lsqb datetime rsqb \
space uri space proto quote \ space quote method \
space status space size space uri space proto quote \
space status space size
;; ;;
combined) combined)
# Combined Log format # Combined Log format
# '_' can be used instead of 'space' # '_' can be used instead of 'space'
# 'q' can be used instead of 'quote' # 'q' can be used instead of 'quote'
log_format \ log_format \
client_ip \ client_ip \
_ user_id \ _ hyphen \
_ lsqb datetime rsqb \ _ user_id \
_ q method _ uri _ proto q \ _ lsqb datetime rsqb \
_ status \ _ q method _ uri _ proto q \
_ size \ _ status \
_ q referer q \ _ size \
_ q user_agent q _ q referer q \
_ q user_agent q
;; ;;
custom) custom)
debug "main: calling: log_format $use_selectors" debug "main: calling: log_format $use_selectors"
# Only use specified selectors # Only use specified selectors
# shellcheck disable=SC2086 # shellcheck disable=SC2086
log_format $use_selectors log_format $use_selectors
;; ;;
esac esac
@ -327,7 +329,7 @@ esac
# #
# Where: # Where:
# %h is the remote host (client IP) # %h is the remote host (client IP)
# %l is the remote logname (not used, so we'll use -) # %l is the remote identity (not used, so we'll use -)
# %u is the authenticated user # %u is the authenticated user
# %t is the time the request was received # %t is the time the request was received
# %r is the request line from the client ("method uri proto") # %r is the request line from the client ("method uri proto")