From bbcd4b0779250c55f312065a599b694b193f35ed Mon Sep 17 00:00:00 2001 From: dmitry kim Date: Tue, 17 Jun 2008 17:23:43 +0400 Subject: [PATCH] + print the location of the debug log to stdout on start --- lib/rbot/ircbot.rb | 29 +++++++++++++++++++---------- 1 file 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 -- 2.39.2