Class GELF::Notifier
In: lib/gelf/notifier.rb
Parent: Object

Graylog2 notifier.

Methods

Constants

MAX_CHUNKS = 128   Maximum number of GELF chunks as per GELF spec
MAX_CHUNK_SIZE_WAN = 1420
MAX_CHUNK_SIZE_LAN = 8154
CALLER_REGEXP = /^(.*):(\d+).*/
LIB_GELF_PATTERN = File.join('lib', 'gelf')

Attributes

collect_file_and_line  [RW] 
default_options  [R] 
enabled  [RW] 
level  [R] 
level_mapping  [R] 
max_chunk_size  [R] 
rescue_network_errors  [RW] 

Public Class methods

host and port are host/ip and port of graylog2-server. max_size is passed to max_chunk_size=. default_options is used in notify!

Public Instance methods

Get a list of receivers.

   notifier.addresses  # => [['localhost', 12201], ['localhost', 12202]]

Set a list of receivers.

   notifier.addresses = [['localhost', 12201], ['localhost', 12202]]

Closes sender

mapping may be a hash, ‘logger’ (GELF::LOGGER_MAPPING) or ‘direct’ (GELF::DIRECT_MAPPING). Default (compatible) value is ‘logger’.

size may be a number of bytes, ‘WAN’ (1420 bytes) or ‘LAN’ (8154). Default (safe) value is ‘WAN’.

Same as notify!, but rescues all exceptions (including ArgumentError) and sends them instead.

Sends message to Graylog2 server. args can be:

  • hash-like object (any object which responds to to_hash, including Hash instance):
     notify!(:short_message => 'All your rebase are belong to us', :user => 'AlekSi')
    
  • exception with optional hash-like object:
     notify!(SecurityError.new('ALARM!'), :trespasser => 'AlekSi')
    
  • string-like object (anything which responds to to_s) with optional hash-like object:
     notify!('Plain olde text message', :scribe => 'AlekSi')
    

Resulted fields are merged with default_options, the latter will never overwrite the former. This method will raise ArgumentError if arguments are wrong. Consider using notify instead.

[Validate]