lib/elastic_apm/config.rb in elastic-apm-4.3.0 vs lib/elastic_apm/config.rb in elastic-apm-4.4.0
- old
+ new
@@ -68,10 +68,11 @@
option :hostname, type: :string
option :http_compression, type: :bool, default: true
option :ignore_url_patterns, type: :list, default: [], converter: RegexpList.new
option :instrument, type: :bool, default: true
option :instrumented_rake_tasks, type: :list, default: []
+ option :log_ecs_formatting, type: :string, default: 'off'
option :log_level, type: :int, default: Logger::INFO, converter: LogLevelMap.new
option :log_path, type: :string
option :metrics_interval, type: :int, default: '30s', converter: Duration.new
option :pool_size, type: :int, default: 1
option :proxy_address, type: :string
@@ -244,10 +245,28 @@
opts[option.key] = value
end
end
def build_logger
+ if self.log_ecs_formatting == 'override'
+ begin
+ return build_ecs_logger
+ rescue LoadError
+ logger.info "Attempted to use EcsLogging::Logger but the gem couldn't be " \
+ "loaded so a ::Logger was created instead. Check if you have the `ecs-logging` " \
+ "gem installed and attempt to start the agent again."
+ end
+ end
+
Logger.new(log_path == '-' ? $stdout : log_path).tap do |logger|
+ logger.level = log_level
+ end
+ end
+
+ def build_ecs_logger
+ require 'ecs_logging/logger'
+
+ ::EcsLogging::Logger.new(log_path == '-' ? $stdout : log_path).tap do |logger|
logger.level = log_level
end
end
def app_type?(app)