Class: Scribbler::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/scribbler/logger.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location, options = {}) ⇒ Logger

Returns a new instance of Logger.


13
14
15
16
# File 'lib/scribbler/logger.rb', line 13

def initialize(location, options = {})
  self.location = location
  self.options = gather_log_options options
end

Class Method Details

.log(location, options = {}) ⇒ Object


9
10
11
# File 'lib/scribbler/logger.rb', line 9

def self.log(location, options = {})
  new(location, options).log
end

Instance Method Details

#logObject

Public: Save ourselves some repetition. Notifies error to NewRelic and drops given string into a given log.

location - Either a pathname from the above method or symbol for an above

method

options - Hash of options for logging on Ngin

:error            - Error object, mostly for passing to NewRelic
:message          - Message to log in the actual file
:custom_fields    - Custom fields dropped into the default template
:template         - Whether or not to use the template at this log
:new_relic        - Notify NewRelic of the error (default: true)

Examples

log(Ngin.subseason_log_location, :error => e, :message  => "Error message stuff", :new_relic => false)

log(:subseason, :error => e, :message => "Error message stuff")

log(:subseason, :message => "Logging like a bauss")

Returns Nothing.


39
40
41
42
# File 'lib/scribbler/logger.rb', line 39

def log
  notify_new_relic options[:error], options[:new_relic]
  apply_to_log
end