Class: MysqlAlterMonitoring::JsonLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql_alter_monitoring/json_logger.rb

Overview

MysqlAlterMonitoring::JsonLogger

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ void

Parameters:

  • io (::IO)


16
17
18
# File 'lib/mysql_alter_monitoring/json_logger.rb', line 16

def initialize(io)
  @logger = ::Logger.new(io, formatter: FORMATTER)
end

Instance Method Details

#error(error, hash = {}) ⇒ void

This method returns an undefined value.

Parameters:

  • error (Exception)
  • hash (Hash) (defaults to: {})


29
30
31
32
33
# File 'lib/mysql_alter_monitoring/json_logger.rb', line 29

def error(error, hash = {})
  hash.merge(error_class: error.class.name, error_message: error.message)
      .then { build_message(_1) }
      .then { logger.error(_1) }
end

#info(hash) ⇒ void

This method returns an undefined value.

Parameters:

  • hash (Hash)


22
23
24
# File 'lib/mysql_alter_monitoring/json_logger.rb', line 22

def info(hash)
  build_message(hash).then { logger.info(_1) }
end