[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sup-devel] [PATCH] add console commands to get/set loglevel



---
 lib/sup/logger.rb             |    3 ++-
 lib/sup/modes/console-mode.rb |    4 ++++
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/sup/logger.rb b/lib/sup/logger.rb
index ccaeae0..ab97e47 100644
--- a/lib/sup/logger.rb
+++ b/lib/sup/logger.rb
@@ -14,13 +14,14 @@ class Logger
 
   def initialize level=nil
     level ||= ENV["SUP_LOG_LEVEL"] || "info"
-    @level = LEVELS.index(level) or raise ArgumentError, "invalid log level #{level.inspect}: should be one of #{LEVELS * ', '}"
+    self.level = level
     @mutex = Mutex.new
     @buf = StringIO.new
     @sinks = []
   end
 
   def level; LEVELS[@level] end
+  def level=(level); @level = LEVELS.index(level) || raise(ArgumentError, "invalid log level #{level.inspect}: should be one of #{LEVELS * ', '}"); end
 
   def add_sink s, copy_current=true
     @mutex.synchronize do
diff --git a/lib/sup/modes/console-mode.rb b/lib/sup/modes/console-mode.rb
index e9bf47c..8ea8f38 100644
--- a/lib/sup/modes/console-mode.rb
+++ b/lib/sup/modes/console-mode.rb
@@ -21,6 +21,10 @@ class Console
 
   def xapian; Index.instance.instance_variable_get :@xapian; end
   def ferret; Index.instance.instance_variable_get :@index; end
+
+  def loglevel; Redwood::Logger.level; end
+  def set_loglevel(level); Redwood::Logger.level = level; end
+
   def special_methods; methods - Object.methods end
 
   ## files that won't cause problems when reloaded
-- 
1.6.3.3

_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel