]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
always print FATAL and ERROR logmessages to STDERR
authorMatthias Hecker <apoc@sixserv.org>
Thu, 14 Nov 2013 13:41:16 +0000 (13:41 +0000)
committerMatthias Hecker <apoc@sixserv.org>
Thu, 14 Nov 2013 13:41:16 +0000 (13:41 +0000)
This adds a print to $stderr for log messages with the
level ERROR or FATAL. I did this because in the past errors
connecting to the server weren't immediately obvious but
rather hidden in the logfile. I think it should be right
in-your-face when the connection doesn't work.

It would probaply be better to extend Logger to print
to STDERR but this apparently requires monkeypatching ruby's
Logger. Anyhow I think my solution works for now.

lib/rbot/ircbot.rb

index a1713c2d4a0ecc320d74600cb24a99928ef6c404..108d0b1d04ac85a7d7a8f8f64742168d8b99550a 100644 (file)
@@ -66,6 +66,10 @@ def rawlog(level, message=nil, who_pos=1)
     qmsg.push [level, l.chomp, who]
     who = ' ' * who.size
   }
+  # Also output (fatal) errors to STDERR:
+  if level == Logger::Severity::ERROR or level == Logger::Severity::FATAL
+    $stderr.puts str
+  end
   $log_queue.push qmsg
 end