Created
October 1, 2010 10:31
-
-
Save wvanbergen/606033 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
# Create a new file format class based on the built-in Rails format. | |
# The name of the class should reflect the filename, i.e.: filename.camelize. | |
class CustomFileFormat < RequestLogAnalyzer::FileFormat::Rails | |
# Regular expressions galore! | |
line_definition :current_user do |line| | |
line.regexp = /Logged in as ([^ ]+) \((\w+)\)/ | |
line.capture(:email).as(:string) | |
line.capture(:account_type).as(:string) | |
end | |
line_definition :current_locale do |line| | |
line.regexp = /Using locale "([^"]+)"/ | |
line.capture(:locale).as(:string) | |
end | |
# Append something to the report | |
report(:append) do |analyze| | |
analyze.frequency :account_type, :title => "Account type" | |
analyze.frequency :locale, :title => "Locales" | |
end | |
end |
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
~ $ request-log-analyzer production.log # Analyze production.log | |
--format custom_file_format.rb # Use custom file format | |
--reject account_type free # Ignore requests from free accounts | |
--select locale en-US # Only look at en-US locale requests | |
--output HTML --file report.html # Generate an HTML report as report.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment