Class: UniformNotifier::CustomizedLogger

Inherits:
Base
  • Object
show all
Defined in:
lib/uniform_notifier/customized_logger.rb

Class Method Summary collapse

Methods inherited from Base

inline_notify, out_of_channel_notify

Class Method Details

._out_of_channel_notify(data) ⇒ Object



11
12
13
14
# File 'lib/uniform_notifier/customized_logger.rb', line 11

def self._out_of_channel_notify(data)
  message = data.values.compact.join("\n")
  @logger.warn message
end

.active?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/uniform_notifier/customized_logger.rb', line 7

def self.active?
  @logger
end

.format_message(severity, timestamp, _progname, msg) ⇒ Object



21
22
23
# File 'lib/uniform_notifier/customized_logger.rb', line 21

def @logger.format_message(severity, timestamp, _progname, msg)
  "#{timestamp.strftime('%Y-%m-%d %H:%M:%S')}[#{severity}] #{msg}"
end

.setup(logdev) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/uniform_notifier/customized_logger.rb', line 16

def self.setup(logdev)
  require 'logger'

  @logger = Logger.new(logdev)

  def @logger.format_message(severity, timestamp, _progname, msg)
    "#{timestamp.strftime('%Y-%m-%d %H:%M:%S')}[#{severity}] #{msg}"
  end
end