Log4r and newer versions of Ruby

This patch is needed to get log4r to play nicely with newer versions of
Ruby…

diff -u log4r-1.0.2/src/log4r/formatter/formatter.rb
/usr/local/ruby-1.8.0/lib/ruby/site_ruby/1.8/log4r/formatter/formatter.rb
— formatter/formatter.rb 2002-02-04 22:49:13.000000000 +1300

···

+++
/usr/local/ruby-1.8.0/lib/ruby/site_ruby/1.8/log4r/formatter/formatter.rb
2003-02-27 15:25:17.000000000 +1300
@@ -47,15 +47,15 @@

+depth+:: How many lines of the stacktrace to display.

class BasicFormatter < SimpleFormatter

  • @@basicformat = “%*3$s %s”
  • @@basicformat = “%*s %s”

    def initialize(hash={})
    @depth = (hash[:depth] or hash[‘depth’] or 7).to_i
    end

    def format(event)

  •  buff = sprintf(@@basicformat, LNAMES[event.level],
    
  •         event.name, MaxLevelLength)
    
  •  buff = sprintf(@@basicformat, MaxLevelLength, LNAMES[event.level],
    
  •         event.name)
     buff += (event.tracer.nil? ? "" : "(#{event.tracer[0]})") + ": "
     buff += format_object(event.data) + "\n"
     buff
    

The basic problem is newer versions of ruby correctly ban the mixing of
%*3$s format with %s.

John Carter Phone : (64)(3) 358 6639
Tait Electronics Fax : (64)(3) 359 4632
PO Box 1645 Christchurch Email : john.carter@tait.co.nz
New Zealand

John’s law :-

All advances in computing have arisen through the creation of an
additional level of indirection, the trick is to work out which
indirection is actually useful.