summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-07-27 10:05:52 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-07-27 10:05:52 +0000
commita94d31b65f7e4134217b9623aab992287c480011 (patch)
tree5d71d9430dc75fba0538fb2a92da4152d3c4324a
parent708b18ab6ea124a1646f75785c48d797fdf164a9 (diff)
New logging systems now works correctly even when the bot is daemonized
-rw-r--r--lib/rbot/ircbot.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 8030fd41..d435ac4c 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -35,23 +35,23 @@ def log_session_end
end
def debug(message=nil, who_pos=1)
- rawlog(Logger::Severity::DEBUG, message)
+ rawlog(Logger::Severity::DEBUG, message, who_pos)
end
def log(message=nil, who_pos=1)
- rawlog(Logger::Severity::INFO, message)
+ rawlog(Logger::Severity::INFO, message, who_pos)
end
def warning(message=nil, who_pos=1)
- rawlog(Logger::Severity::WARN, message)
+ rawlog(Logger::Severity::WARN, message, who_pos)
end
def error(message=nil, who_pos=1)
- rawlog(Logger::Severity::ERROR, message)
+ rawlog(Logger::Severity::ERROR, message, who_pos)
end
def fatal(message=nil, who_pos=1)
- rawlog(Logger::Severity::FATAL, message)
+ rawlog(Logger::Severity::FATAL, message, who_pos)
end
debug "debug test"
@@ -282,8 +282,18 @@ class IrcBot
# On Windows, there's not such thing as /dev/null
STDIN.reopen "NUL"
end
- STDOUT.reopen @logfile, "a"
- STDERR.reopen @logfile, "a"
+ def STDOUT.write(str=nil)
+ log str, 2
+ return str.to_s.length
+ end
+ def STDERR.write(str=nil)
+ if str.to_s.match(/:\d+: warning:/)
+ warning str, 2
+ else
+ error str, 2
+ end
+ return str.to_s.length
+ end
end
# Set the new logfile and loglevel. This must be done after the daemonizing