Class: ErrorStalker::Backend::LogFile
- Defined in:
- lib/error_stalker/backend/log_file.rb
Overview
A backend that logs all exception reports to a file. This is probably what you want to be running in development mode, and is also the default backend.
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
The name of the file containing the exception reports.
Instance Method Summary collapse
-
#initialize(filename) ⇒ LogFile
constructor
Creates a new LogFile backend that will log exceptions to
filename
. -
#report(exception_report) ⇒ Object
Writes the information contained in
exception_report
to the log file specified when this backend was initialized.
Constructor Details
#initialize(filename) ⇒ LogFile
Creates a new LogFile backend that will log exceptions to filename
12 13 14 |
# File 'lib/error_stalker/backend/log_file.rb', line 12 def initialize(filename) @filename = filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
The name of the file containing the exception reports
9 10 11 |
# File 'lib/error_stalker/backend/log_file.rb', line 9 def filename @filename end |
Instance Method Details
#report(exception_report) ⇒ Object
Writes the information contained in exception_report
to the log file specified when this backend was initialized.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/error_stalker/backend/log_file.rb', line 18 def report(exception_report) File.open(filename, 'a') do |file| file.puts "Machine: #{exception_report.machine}" file.puts "Application: #{exception_report.application}" file.puts "Timestamp: #{exception_report.}" file.puts "Type: #{exception_report.type}" file.puts "Exception: #{exception_report.exception}" file.puts "Data: #{YAML.dump(exception_report.data)}" if exception_report.backtrace file.puts "Stack trace:" file.puts exception_report.backtrace.join("\n") end file.puts end end |