Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
~ $ 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