lib/site_hook/logger.rb in site_hook-0.8.0 vs lib/site_hook/logger.rb in site_hook-0.8.1
- old
+ new
@@ -15,23 +15,25 @@
},
:date => :white,
:logger => :cyan,
:message => :green,
)
-
+PATTERN = '[%d] %-5l %c: %m\n'
+DATE_PATTERN = '%Y-%m-%d %H:%M:%S'
layout = Logging.layouts.pattern \
- :pattern => '[%d] %-5l %c: %m\n',
- :date_pattern => '%Y-%m-%d %H:%M:%S',
+ :pattern => PATTERN,
+ :date_pattern => DATE_PATTERN,
:color_scheme => 'bright'
Logging.appenders.stdout \
:layout => layout
module SiteHook
def mklogdir
path = Pathname(Dir.home).join('.jph', 'logs')
if path.exist?
+ # Path exists, don't do anything
else
FileUtils.mkpath(path.to_s)
end
end
@@ -50,11 +52,11 @@
@log_level = log_level
flayout = Logging.appenders.rolling_file \
Pathname(Dir.home).join('.jph', 'logs', "#{SiteHook.safe_log_name(self)}-#{@log_level}.log").to_s,
:age => 'daily',
- :pattern => '[%d] %-5l %c: %m\n'
+ :pattern => PATTERN
@log.add_appenders 'stdout', flayout
@log.level = log_level
end
end
@@ -75,11 +77,11 @@
@log_level = log_level
flayout = Logging.appenders.rolling_file \
Pathname(Dir.home).join('.jph', 'logs', "#{SiteHook.safe_log_name(self)}-#{@log_level}.log").to_s,
:age => 'daily',
- :pattern => '[%d] %-5l %c: %m\n'
+ :pattern => PATTERN
@log.add_appenders 'stdout', flayout
@log.level = log_level
LL.debug "Initialized #{SiteHook.safe_log_name(self)}"
end
end
@@ -94,11 +96,11 @@
@log = Logging.logger[SiteHook.safe_log_name(self)]
@log_level = log_level
flayout = Logging.appenders.rolling_file \
Pathname(Dir.home).join('.jph', 'logs', "#{SiteHook.safe_log_name(self)}-#{@log_level}.log").to_s,
:age => 'daily',
- :pattern => '[%d] %-5l %c: %m\n'
+ :pattern => PATTERN
@log.add_appenders 'stdout', flayout
@log.level = @log_level
LL.debug "Initialized #{SiteHook.safe_log_name(self)}"
end
end
@@ -113,11 +115,11 @@
@log_level = log_level
flayout = Logging.appenders.rolling_file \
Pathname(Dir.home).join('.jph', 'logs', "#{SiteHook.safe_log_name(self)}-#{@log_level}.log").to_s,
:age => 'daily',
- :pattern => '[%d] %-5l %c: %m\n'
+ :pattern => PATTERN
@log.add_appenders 'stdout', flayout
@log.level = log_level
LL.debug "Initialized #{SiteHook.safe_log_name(self)}"
end
@@ -133,11 +135,11 @@
@log_level = log_level
flayout = Logging.appenders.rolling_file \
Pathname(Dir.home).join('.jph', 'logs', "#{SiteHook.safe_log_name(self)}-#{@log_level}.log").to_s,
:age => 'daily',
- :pattern => '[%d] %-5l %c: %m\n'
+ :pattern => PATTERN
@log.add_appenders 'stdout', flayout
@log.level = log_level
LL.debug "Initialized #{SiteHook.safe_log_name(self)}"
end
end
@@ -169,9 +171,11 @@
case
when msg =~ /From (.*?):(.*?)\/(.*)(\.git)?/
@info_output << "Pulling via #{$2}/#{$3} on #{$1}."
when msg =~ /\* branch (.*?) -> .*/
@info_output << "Using #{$1} branch"
+ else
+ @debug_output << msg
end
end
else
@debug_output << message
end