Last active
December 23, 2015 05:58
-
-
Save agenticsim/6590284 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
# Regular Expression To Parse Ruby Log Messages | |
# parse ruby log message | |
# customize as needed | |
LOG_EXPRESSION = /([\w]+),\s+\[([^\]\s]+)\s+#([^\]]+)\]\s+(\w+)\s+--\s+(\w+)?:\s+(.+)/ | |
# sample log output from this call: | |
# logger.info("Ubiquitously") { "[dequeud] #{JSON.generate(params)}"} | |
string = 'I, [2010-08-15T16:16:46.142801 #81977] INFO -- Ubiquitously: {"title":"Google","url":"google.com","tags":"search, google, api","services":["meta_filter","mixx"],"description":"a search engine!"}' | |
string.gsub(LOG_EXPRESSION) do |match| | |
severity = $1 | |
date = $2 # Time.parse(date) | |
pid = $3 | |
label = $4 | |
app = $5 | |
message = $6 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment