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



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

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

.active?Boolean

Returns:

  • (Boolean)


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

def active?
  @logger
end

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



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

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

.setup(logdev) ⇒ Object



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

def 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