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/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, 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



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

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

.factory(options, &block) ⇒ Object

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



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

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



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

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