lib/service_skeleton/config.rb in service_skeleton-0.0.0.3.g1269800 vs lib/service_skeleton/config.rb in service_skeleton-0.0.0.3.g1269800.1.gaaa2fa1

- old
+ new

@@ -1,15 +1,17 @@ require "to_regexp" require_relative "./filtering_logger" +require "loggerstash" + class ServiceSkeleton class Config attr_reader :logger def initialize(env, svc) - @env = env.to_hash.freeze + @env = env.to_hash.dup.freeze @svc = svc parse_registered_variables(env) setup_logger end @@ -43,9 +45,15 @@ else [log_max_files, log_max_file_size] end @logger = Logger.new(log_file || $stderr, shift_age, shift_size) + + if self.logstash_server && !self.logstash_server.empty? + loggerstash = Loggerstash.new(logstash_server: logstash_server, logger: @logger) + loggerstash.metrics_registry = @svc.metrics + loggerstash.attach(@logger) + end if log_enable_timestamps @logger.formatter = ->(s, t, p, m) { "#{t.utc.strftime("%FT%T.%NZ")} #{s[0]} [#{p}] #{m}\n" } else @logger.formatter = ->(s, t, p, m) { "#{s[0]} [#{p}] #{m}\n" }