summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authordmitry kim <jason@nichego.net>2008-06-17 17:23:43 +0400
committerdmitry kim <jason@nichego.net>2008-06-17 18:02:28 +0400
commitbbcd4b0779250c55f312065a599b694b193f35ed (patch)
tree07eb5ffe3785b44e277520fba7089b2415c5f5ac /lib/rbot
parentf7dc2025605d681d22af8cfe70bdd030cc0f8ab6 (diff)
+ print the location of the debug log to stdout on start
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb29
1 files changed, 19 insertions, 10 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index baf52005..65f3edf6 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -66,13 +66,15 @@ def rawlog(level, message=nil, who_pos=1)
$log_queue.push qmsg
end
-def restart_logger
+def restart_logger(newlogger = false)
if $log_thread && $log_thread.alive?
$log_queue << nil
$log_thread.join
$log_thread = nil
end
+ $logger = newlogger if newlogger
+
$log_thread = Thread.new do
ls = nil
while ls = $log_queue.pop
@@ -444,6 +446,7 @@ class Bot
@logfile = @config['log.file']
if @logfile.class!=String || @logfile.empty?
@logfile = "#{botclass}/#{File.basename(botclass).gsub(/^\.+/,'')}.log"
+ debug "Using `#{@logfile}' as debug log"
end
# See http://blog.humlab.umu.se/samuel/archives/000107.html
@@ -462,6 +465,21 @@ class Bot
end
Dir.chdir botclass
# File.umask 0000 # Ensure sensible umask. Adjust as needed.
+ end
+
+ logger = Logger.new(@logfile,
+ @config['log.keep'],
+ @config['log.max_size']*1024*1024)
+ logger.datetime_format= $dateformat
+ logger.level = @config['log.level']
+ logger.level = $cl_loglevel if defined? $cl_loglevel
+ logger.level = 0 if $debug
+
+ restart_logger(logger)
+
+ log_session_start
+
+ if $daemonize
log "Redirecting standard input/output/error"
[$stdin, $stdout, $stderr].each do |fd|
begin
@@ -486,15 +504,6 @@ class Bot
end
end
- # Set the new logfile and loglevel. This must be done after the daemonizing
- $logger = Logger.new(@logfile, @config['log.keep'], @config['log.max_size']*1024*1024)
- $logger.datetime_format= $dateformat
- $logger.level = @config['log.level']
- $logger.level = $cl_loglevel if defined? $cl_loglevel
- $logger.level = 0 if $debug
-
- log_session_start
-
File.open($opts['pidfile'] || "#{@botclass}/rbot.pid", 'w') do |pf|
pf << "#{$$}\n"
end