Add option to specify logfile

This commit is contained in:
Guillaume DOTT 2013-09-11 15:25:35 +02:00
parent eec4e58dd9
commit 015feedad3
2 changed files with 7 additions and 2 deletions

View File

@ -35,10 +35,11 @@ module SMSd
def init_logger
@logger = Logger.new(
Util::MultiIO.new(STDOUT, File.open('debug.log', 'a')))
Util::MultiIO.new(STDOUT,
File.open(@options[:logfile] || 'smsd.log', 'a')))
logger.formatter = proc do |severity, datetime, progrname, msg|
"#{datetime} [#{severity}] #{msg}\n"
"#{$PROGRAM_NAME}: #{datetime} [#{severity}] #{msg}\n"
end
end

View File

@ -17,6 +17,10 @@ module SMSd
options[:daemonize] = daemon
end
opts.on('-l', '--log-file', 'Define log file') do |logfile|
options[:logfile] = logfile
end
opts.on('-p', '--pin PIN', 'Specify the SIM PIN') do |pin|
options[:pin] = pin
end