module Hcheck

Main Hcheck module

Constants

LOG_FILE_PATH
VERSION

Attributes

configuration[RW]
logging[RW]

Public Class Methods

configure(config = {}) click to toggle source
# File lib/hcheck.rb, line 32
def configure(config = {})
  self.configuration ||= Configuration.new(config)
end
logger() click to toggle source
# File lib/hcheck.rb, line 36
def logger
  self.logging ||= set_logger
end
status() click to toggle source
# File lib/hcheck.rb, line 20
def status
  if configuration
    configuration.services.map(&:check)
  else
    [{
      name: 'Hcheck',
      desc: 'Hcheck',
      status: 'Hcheck configuration not found'
    }]
  end
end

Private Class Methods

set_logger() click to toggle source
# File lib/hcheck.rb, line 42
def set_logger
  dir = File.dirname(LOG_FILE_PATH)
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
  logger = Logger.new(LOG_FILE_PATH, 'daily')
  logger.formatter = proc do |severity, datetime, _progname, msg|
    log_msg = "[#{severity}] [#{datetime}] #{msg}"
    puts log_msg
    "#{log_msg}\n"
  end
  logger
end