lib/contrast/logger/log.rb in contrast-agent-3.12.2 vs lib/contrast/logger/log.rb in contrast-agent-3.13.0
- old
+ new
@@ -6,10 +6,11 @@
cs__scoped_require 'singleton'
cs__scoped_require 'contrast/components/interface'
cs__scoped_require 'contrast/extension/module'
cs__scoped_require 'contrast/logger/application'
+cs__scoped_require 'contrast/logger/format'
cs__scoped_require 'contrast/logger/time'
module Contrast
module Logger
# This class functions to serve as a wrapper around our logging, as we need
@@ -88,10 +89,11 @@
::Ougai::Logger.new(path)
end
add_contrast_loggers(logger)
logger.progname = 'Contrast Agent'
logger.level = level_const
+ logger.formatter = Contrast::Logger::Format.new
logger.formatter.datetime_format = '%Y-%m-%dT%H:%M:%S.%L%z'
logger
end
def add_contrast_loggers logger
@@ -106,13 +108,17 @@
path = DEFAULT_NAME if path.empty?
if write_permission?(path)
path
elsif write_permission?(DEFAULT_NAME)
- puts "[!] Unable to write to '#{ path }'. Writing to default log '#{ DEFAULT_NAME }' instead."
+ # Log once when the path is invalid. We'll change to this path, so no
+ # need to log again.
+ puts "[!] Unable to write to '#{ path }'. Writing to default log '#{ DEFAULT_NAME }' instead." if previous_path != DEFAULT_NAME
DEFAULT_NAME
else
- puts "[!] Unable to write to '#{ path }'. Writing to standard out instead."
+ # Log once when the path is invalid. We'll change to this path, so no
+ # need to log again.
+ puts "[!] Unable to write to '#{ path }'. Writing to standard out instead." if previous_path != STDOUT_STR
STDOUT_STR
end
end
def valid_level level