Brian Takita wrote:
> Hello,
>
> Whenever I log a class using Log4r with full warnings on, I get a bunch
> of warnings. Does anybody know how to resolve this? Is there a patch
> out?
>


There's probably a correct way of doing this but it would mean
understanding more about the structure.


diff -u3pPr log4r_ORIG\loggerfactory.rb log4r\loggerfactory.rb
--- log4r_ORIG\loggerfactory.rb Sat Apr 09 09:23:52 2005
+++ log4r\loggerfactory.rb Mon Jul 11 07:21:20 2005
@@ -51,7 +51,9 @@ class Logger

     def self.unset_log(logger, lname)
       mstr="def logger.#{lname.downcase}(data=nil, propagated=false); end"
+      $VERBOSE, verbose = false, $VERBOSE
       module_eval mstr
+      $VERBOSE = verbose
     end

     # Logger logging methods are defined here.
@@ -73,15 +75,21 @@ class Logger
           #{parentcall}
         end
       -
+      $VERBOSE, verbose = false, $VERBOSE
       module_eval mstr
+      $VERBOSE = verbose
     end

     def self.set_false(logger, lname)
+      $VERBOSE, verbose = false, $VERBOSE
       module_eval "def logger.#{lname.downcase}?; false end"
+      $VERBOSE = verbose
     end

     def self.set_true(logger, lname)
+      $VERBOSE, verbose = false, $VERBOSE
       module_eval "def logger.#{lname.downcase}?; true end"
+      $VERBOSE = verbose
     end

   end
diff -u3pPr log4r_ORIG\outputter\outputterfactory.rb log4r\outputter\outputterfactory.rb
--- log4r_ORIG\outputter\outputterfactory.rb Sat Apr 09 09:23:52 2005
+++ log4r\outputter\outputterfactory.rb Mon Jul 11 07:20:16 2005
@@ -45,13 +45,17 @@ class Outputter
             canonical_log(logevent)
           end
         -
+        $VERBOSE, verbose = false, $VERBOSE
         module_eval mstr
+        $VERBOSE = verbose
       end

       def self.undefine_log(mname, out)
         return if mname == 'off' || mname == 'all'
         mstr = "def out.#{mname}(logevent); end"
+        $VERBOSE, verbose = false, $VERBOSE
         module_eval mstr
+        $VERBOSE = verbose
       end
   end





A short script to test would have been helpful !

#---------------------------------------------------
require 'log4r'
include Log4r

$VERBOSE=true
mylog = Logger.new 'mylog'
mylog.outputters = Outputter.stdout
mylog.debug "This is a message with level DEBUG"
p [:VERBOSE, $VERBOSE]  #-> still true after flips
#---------------------------------------------------

daz