Created
October 1, 2014 07:03
-
-
Save rcsheets/66cd8e79d4afdb209835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
use v5.12; | |
# have: | |
# time [PID]: [sessionID-1] db=databaes,user=user,remote=remote TYPE: rest | |
# want: | |
# time|user|database|session ID|log entry type|rest | |
while (<>) { | |
chomp; | |
/^(?<time>\d{4}-\d{2}-\d{2}\s\d\d:\d\d:\d\d\.\d\d\d\sPDT)\s # timestamp | |
\[\d+\]:\s # PID | |
\[(?<sessionid>\d+)-1\]\s | |
db=(?<db>.*?),user=(?<user>.*?),remote=[^A-Z]+ | |
(?<type>[A-Z]+):\s+(?<rest>.*)$/x; | |
printf "%s|%s|%s|%s|%s|%s\n", | |
$+{time}, $+{user}, $+{db}, $+{sessionid}, $+{type}, $+{rest}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment