Class: Radar::Logger
- Inherits:
-
Logger
- Object
- Logger
- Radar::Logger
- Defined in:
- lib/radar/logger.rb
Overview
A lightweight logger which logs what Radar does to a single configurable location. This logger is simply meant as a way you can verify that Radar is working as intended, and not meant as a logger of every exception's data; this is the job of Reporters.
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
Instance Method Summary collapse
- #format_message(severity, timestamp, progname, message) ⇒ Object
-
#initialize(application) ⇒ Logger
constructor
A new instance of Logger.
-
#log_location ⇒ String
Returns the location of the logfile.
Constructor Details
#initialize(application) ⇒ Logger
Returns a new instance of Logger.
12 13 14 15 |
# File 'lib/radar/logger.rb', line 12 def initialize(application) @application = application super(log_location) end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
10 11 12 |
# File 'lib/radar/logger.rb', line 10 def application @application end |
Instance Method Details
#format_message(severity, timestamp, progname, message) ⇒ Object
17 18 19 |
# File 'lib/radar/logger.rb', line 17 def (severity, , progname, ) "[#{application.name}][#{severity[0,1].upcase}][#{}] -- #{}\n" end |
#log_location ⇒ String
Returns the location of the logfile. This is configurable using Config#log_location=.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/radar/logger.rb', line 25 def log_location location = @application.config.log_location location = location.is_a?(Proc) ? location.call(application) : location if location.is_a?(String) directory = File.dirname(location) FileUtils.mkdir_p(directory) if !File.directory?(directory) end location end |