From 4327a33bcfb9a5fc1d851bc508174819093c9f8a Mon Sep 17 00:00:00 2001 From: did Date: Mon, 30 Mar 2015 23:59:24 +0200 Subject: [PATCH] add the close method for the logger --- Gemfile.lock | 4 ++-- lib/locomotive/common/exception.rb | 3 --- lib/locomotive/common/logger.rb | 10 +++++++--- lib/locomotive/common/version.rb | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d0deda2..7e42c0b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,13 @@ PATH remote: . specs: - locomotivecms_common (0.0.2) + locomotivecms_common (0.0.3) colorize GEM remote: https://rubygems.org/ specs: - colorize (0.7.3) + colorize (0.7.5) diff-lcs (1.2.5) rake (10.2.2) rspec (2.14.1) diff --git a/lib/locomotive/common/exception.rb b/lib/locomotive/common/exception.rb index eaa8ae3..eb673f3 100644 --- a/lib/locomotive/common/exception.rb +++ b/lib/locomotive/common/exception.rb @@ -51,8 +51,5 @@ def log_page_into_backtrace(exception) end end - class MounterException < DefaultException; end - class GeneratorException < DefaultException; end - end end diff --git a/lib/locomotive/common/logger.rb b/lib/locomotive/common/logger.rb index a8e56dc..f0248db 100644 --- a/lib/locomotive/common/logger.rb +++ b/lib/locomotive/common/logger.rb @@ -16,7 +16,7 @@ def initialize # @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 @@ -39,7 +39,7 @@ 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, " \ @@ -48,6 +48,10 @@ def self.setup *args 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| @@ -58,7 +62,7 @@ class << self 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')) diff --git a/lib/locomotive/common/version.rb b/lib/locomotive/common/version.rb index c250ec4..887ac1a 100644 --- a/lib/locomotive/common/version.rb +++ b/lib/locomotive/common/version.rb @@ -1,5 +1,5 @@ module Locomotive module Common - VERSION = '0.0.2' + VERSION = '0.0.3' end -end \ No newline at end of file +end