lib/locomotive/common/logger.rb in locomotivecms_common-0.0.2 vs lib/locomotive/common/logger.rb in locomotivecms_common-0.0.3
- old
+ new
@@ -14,11 +14,11 @@
# Setup the single instance of the ruby logger.
#
# @param[ optional ] [ String ] path The path to the log file, full path with log file name
# Sample /home/locomotivecms/log/server.log (default: nil => Stdout)
#
- def setup log_file_full_path=nil
+ def setup(log_file_full_path = nil)
require 'logger'
output = begin
if log_file_full_path
log_file_path log_file_full_path
@@ -37,29 +37,33 @@
def self.instance
@@instance ||= self.new
end
- def self.setup *args
+ def self.setup(*args)
if args.size > 1
puts "[DEPRECATION] Logger.setup(path, stdout=false) is deprecated. " \
"Please use Logger.setup(log_file_full_path) instead, " \
"like: /home/locomotivecms/log/server.log"
end
self.instance.setup args.first
end
+ def self.close
+ self.instance.logger.close
+ end
+
class << self
%w(debug info warn error fatal unknown).each do |name|
define_method(name) do |message|
self.instance.logger.send(name.to_sym, message)
end
end
end
private
- def log_file_path log_file_full_path
+ def log_file_path(log_file_full_path)
if File.directory? log_file_full_path
puts "[DEPRECATION] Please use fully log file path like: /home/locomotivecms/log/server.log"
File.expand_path(File.join(log_file_full_path, 'log', 'locomotivecms.log'))
else
log_file_full_path