Skip to content
This repository

BufferedLogger level while creation #6688

Merged
merged 1 commit into from almost 2 years ago

2 participants

Niranjan Rafael Mendonça França
Niranjan

BufferedLogger accepts level as a parameter to the constructor. It was ignoring this parameter and was not setting the appropriate log level of the underlying Logger.

Rafael Mendonça França rafaelfranca merged commit 35c89a4 into from June 10, 2012
Rafael Mendonça França rafaelfranca closed this June 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 09, 2012
Niranjan buffered logger is initialized with the log level passed trough the i…
…nitializer
01f8f29
This page is out of date. Refresh to see the latest.
4  activesupport/lib/active_support/buffered_logger.rb
@@ -45,7 +45,6 @@ def silence(temporary_level = ERROR)
45 45
     deprecate :auto_flushing
46 46
 
47 47
     def initialize(log, level = DEBUG)
48  
-      @level         = level
49 48
       @log_dest      = log
50 49
 
51 50
       unless log.respond_to?(:write)
@@ -58,6 +57,7 @@ def initialize(log, level = DEBUG)
58 57
       end
59 58
 
60 59
       @log = open_logfile log
  60
+      self.level = level
61 61
     end
62 62
 
63 63
     def open_log(log, mode)
@@ -91,7 +91,7 @@ def #{severity.downcase}(message = nil, progname = nil, &block) # def debug(mess
91 91
         end                                                             # end
92 92
 
93 93
         def #{severity.downcase}?                                       # def debug?
94  
-          #{severity} >= level                                         #   DEBUG >= @level
  94
+          #{severity} >= level                                         #   DEBUG >= level
95 95
         end                                                             # end
96 96
       EOT
97 97
     end
5  activesupport/test/buffered_logger_test.rb
@@ -62,6 +62,11 @@ def test_write_binary_data_create_file
62 62
     File.unlink fname
63 63
   end
64 64
 
  65
+  def test_should_default_logger_level_to_one_passed_while_creating_it
  66
+    logger = Logger.new(@output, Logger::ERROR)
  67
+    assert_equal Logger::ERROR, logger.level
  68
+  end
  69
+
65 70
   def test_should_log_debugging_message_when_debugging
66 71
     @logger.level = Logger::DEBUG
67 72
     @logger.add(Logger::DEBUG, @message)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.