logex

logex is a little command line tool around logopen(). It basically allows fetching individual fields from a log, and/or restructuring it into a specific format (e.g. tab or comma-delimited).

logex access.log @request_uri @datetime @user_agent

Where the first param is always the log file, and then an arbitrary number of field names - either individually or as part of a string argument:

logex access.log --tab "uri,date,status" user_agent

(Would delimit the first three per comma, the last with a tab.)

Flags

param desc
--json output each row as JSON
--csv join all fields with comma
--tab tab-separated output
--iso8601 fix any datetime fields
--regex just output regex for log
--debug debug_rx in case the regex fails

Pefixes

The argument list allows field name prefixes. Which are only relevant to container-fields (expanded key:value pairs for some application formats), in case they're holding lists.

prefix output
@name will just show the first entry
%name space-separated list
*name comma-separated list
+name plus-joined list
#name as json array
name whatever