Module: SemanticLogger::Appender

Defined in:
lib/semantic_logger/appender.rb,
lib/semantic_logger/appender/tcp.rb,
lib/semantic_logger/appender/udp.rb,
lib/semantic_logger/appender/file.rb,
lib/semantic_logger/appender/http.rb,
lib/semantic_logger/appender/async.rb,
lib/semantic_logger/appender/kafka.rb,
lib/semantic_logger/appender/sentry.rb,
lib/semantic_logger/appender/splunk.rb,
lib/semantic_logger/appender/syslog.rb,
lib/semantic_logger/appender/bugsnag.rb,
lib/semantic_logger/appender/graylog.rb,
lib/semantic_logger/appender/mongodb.rb,
lib/semantic_logger/appender/wrapper.rb,
lib/semantic_logger/appender/rabbitmq.rb,
lib/semantic_logger/appender/new_relic.rb,
lib/semantic_logger/appender/async_batch.rb,
lib/semantic_logger/appender/honeybadger.rb,
lib/semantic_logger/appender/splunk_http.rb,
lib/semantic_logger/appender/elasticsearch.rb,
lib/semantic_logger/appender/elasticsearch_http.rb

Defined Under Namespace

Classes: Async, AsyncBatch, Bugsnag, Elasticsearch, ElasticsearchHttp, File, Graylog, Honeybadger, Http, Kafka, MongoDB, NewRelic, Rabbitmq, Sentry, Splunk, SplunkHttp, Syslog, Tcp, Udp, Wrapper

Constant Summary collapse

AnsiColors =

DEPRECATED, use SemanticLogger::AnsiColors

SemanticLogger::AnsiColors
ASYNC_OPTION_KEYS =
%i[max_queue_size lag_threshold_s batch_size batch_seconds lag_check_interval].freeze

Class Method Summary collapse

Class Method Details

.colorized_formatterObject

DEPRECATED: use SemanticLogger::Formatters::Color.new



30
31
32
# File 'lib/semantic_logger/appender.rb', line 30

def self.colorized_formatter
  SemanticLogger::Formatters::Color.new
end

.factory(options, &block) ⇒ Object

Returns [SemanticLogger::Subscriber] appender for the supplied options



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/semantic_logger/appender.rb', line 40

def self.factory(options, &block)
  options = options.dup
  async   = options.delete(:async)
  batch   = options.delete(:batch)

  # Extract batch and async options
  proxy_options = {}
  ASYNC_OPTION_KEYS.each { |key| proxy_options[key] = options.delete(key) if options.key?(key) }

  appender = build(options, &block)

  # If appender implements #batch, then it should use the batch proxy by default.
  batch    = true if batch.nil? && appender.respond_to?(:batch)

  if batch == true
    proxy_options[:appender] = appender
    Appender::AsyncBatch.new(proxy_options)
  elsif async == true
    proxy_options[:appender] = appender
    Appender::Async.new(proxy_options)


  else
    appender
  end
end

.json_formatterObject

DEPRECATED: use SemanticLogger::Formatters::Json.new



35
36
37
# File 'lib/semantic_logger/appender.rb', line 35

def self.json_formatter
  SemanticLogger::Formatters::Json.new
end