Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Michael Hale
Make logdir configurable. [ reply ]  
2009-02-20 02:27
I'd like to be able to configure my daemon's logdir. Something like this:

Daemons.run(
File.join(root, 'script', 'rss_feed_fetcher.rb'),
:dir_mode => :normal, :dir => (root + '/tmp/pids'),
:log_dir => File.join(root, 'log'),
:log_output => true,
:backtrace => true
)

In order to accomplish this I am reopening the class:

module Daemons
class Application
def logdir
logdir = options[:log_dir]
unless logdir
logdir = options[:dir_mode] == :system ? '/var/log' : pidfile_dir
end
logdir
end

def output_logfile
(options[:log_output] && logdir) ? File.join(logdir, @group.app_name + '.output') : nil
end

def logfile
logdir ? File.join(logdir, @group.app_name + '.log') : nil
end
end
end