Class: HotPotato::QueueLogger

Inherits:
Object
  • Object
show all
Includes:
Core
Defined in:
lib/hot_potato/queue_logger.rb

Constant Summary

Constants included from Core

Core::CONFIG_PATH

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Core

#acquire_lock, #config, #queue_inject, #queue_subscribe, #release_lock, #set_logger, #stat

Constructor Details

#initialize(options = {}) ⇒ QueueLogger

Returns a new instance of QueueLogger.



9
10
11
# File 'lib/hot_potato/queue_logger.rb', line 9

def initialize(options = {})
  @classname = options[:classname]
end

Instance Attribute Details

#formatterObject

Returns the value of attribute formatter.



7
8
9
# File 'lib/hot_potato/queue_logger.rb', line 7

def formatter
  @formatter
end

#levelObject

Returns the value of attribute level.



7
8
9
# File 'lib/hot_potato/queue_logger.rb', line 7

def level
  @level
end

Instance Method Details

#debug(m) ⇒ Object



25
# File 'lib/hot_potato/queue_logger.rb', line 25

def debug(m); log m, __method__; end

#error(m) ⇒ Object



28
# File 'lib/hot_potato/queue_logger.rb', line 28

def error(m); log m, __method__; end

#fatal(m) ⇒ Object



29
# File 'lib/hot_potato/queue_logger.rb', line 29

def fatal(m); log m, __method__; end

#info(m) ⇒ Object



26
# File 'lib/hot_potato/queue_logger.rb', line 26

def info(m);  log m, __method__; end

#log(message, severity) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hot_potato/queue_logger.rb', line 13

def log(message, severity)
  log_entry = {}
  log_entry[:created_at] = Time.now
  log_entry[:message]    = message
  log_entry[:severity]   = severity
  log_entry[:host]       = Socket.gethostname
  log_entry[:pid]        = Process.pid
  log_entry[:classname]  = @classname
  
  queue_inject "hotpotato.log.#{log_entry[:host]}", log_entry.to_json
end

#warn(m) ⇒ Object



27
# File 'lib/hot_potato/queue_logger.rb', line 27

def warn(m);  log m, __method__; end