Class: RooOnRails::Checks::Papertrail::LogDestinationExists

Inherits:
Base
  • Object
show all
Defined in:
lib/roo_on_rails/checks/papertrail/log_destination_exists.rb

Overview

Check for a configured log destination in Papertrail.

Input context

  • papertrail.client: a connected Papertrail client

Output context:

  • papertrail.dest.host, .port: the destination logging host

Constant Summary collapse

NAME =

The shared log destination

'default'.freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize, requires, #run

Methods included from Helpers

#bold, included

Constructor Details

This class inherits a constructor from RooOnRails::Checks::Base

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/roo_on_rails/checks/papertrail/log_destination_exists.rb', line 24

def call
  data = context.papertrail.client.list_destinations.find { |h|
    h['syslog']['description'] == NAME
  }

  fail! "Log destination #{bold NAME} not found" if data.nil?

  context.papertrail!.dest!.host = data['syslog']['hostname']
  context.papertrail!.dest!.port = data['syslog']['port']

  pass "logging to #{context.papertrail.dest.host}:#{context.papertrail.dest.port}"
end

#introObject



20
21
22
# File 'lib/roo_on_rails/checks/papertrail/log_destination_exists.rb', line 20

def intro
  "Checking for log destination #{bold NAME}..."
end