Introducing the lognotify gem

In an effort to pay more attention to log files I wrote the lognotify gem to make it convenient to monitor a log file's recent entries.

require 'lognotify'

ln ='/tmp/')

def ln.on_update(entry)

  puts 'entry: ' + entry.inspect

  if entry =~ /citserver\[1988\]: Context: james logged in/ then
    puts 'James logged into the mail server'


In the above example the lognotify gem monitors the updates to the file /tmp/ and prints out the most recent log entry. It checks if James has logged into the mail server and if he has it prints out the following message:

James logged into the mail server

Show below is the code used to create a sample log file while lognotify was running:

require 'logger'

log = '/tmp/' 'testing'
sleep 2 'box1 citserver[1988]: Context: james logged in'
sleep 1 'new mail arrived'


entry: "I, [2015-10-04T10:26:38.444514 #5675]  INFO -- : testing\n"
entry: "I, [2015-10-04T10:26:40.446443 #5675]  INFO -- : box1 citserver[1988]: Context: james logged in\n"
James logged into the mail server
entry: "I, [2015-10-04T10:26:41.447813 #5675]  INFO -- : new mail arrived\n"