class Binnacle::Logging::Formatter

Public Class Methods

new(client) click to toggle source
# File lib/binnacle/logging/formatter.rb, line 6
def initialize(client)
  @client = client
end

Public Instance Methods

assets_log_prefix() click to toggle source
# File lib/binnacle/logging/formatter.rb, line 56
def assets_log_prefix
  @assets_log_prefix ||= "Started GET \"#{Rails.application.config.assets.prefix}" if defined?(Rails)
end
call(severity, datetime, progname, msg) click to toggle source
# File lib/binnacle/logging/formatter.rb, line 10
def call(severity, datetime, progname, msg)
  unless assets_log_prefix && msg.start_with?(assets_log_prefix)
    session_id, client_id = @client.session_and_client_ids

    event = Binnacle::Event.new()

    logging_tags = current_tags.dup
    if progname
      event.configure_from_logging_progname(progname, @client.logging_channel_id, client_id, session_id, severity, nil, datetime, [], { message: msg })
    elsif defined?(ActiveSupport::TaggedLogging) && logging_tags && !logging_tags.empty? && logging_tags.size > 2
      logging_tags.shift(2)
      event_name = logging_tags.shift
      event.configure_from_logging_progname(event_name, @client.logging_channel_id, client_id, session_id, severity, nil, datetime, logging_tags, { message: msg })
    else
      event.configure(@client.logging_channel_id, 'log', client_id, session_id, severity, nil, datetime, [], { message: msg })
    end

    event
  end
end
clear_tags!() click to toggle source
# File lib/binnacle/logging/formatter.rb, line 48
def clear_tags!
  current_tags.clear
end
current_tags() click to toggle source
# File lib/binnacle/logging/formatter.rb, line 52
def current_tags
  Thread.current[:activesupport_tagged_logging_tags] ||= []
end
pop_tags(size = 1) click to toggle source
# File lib/binnacle/logging/formatter.rb, line 44
def pop_tags(size = 1)
  current_tags.pop size
end
push_tags(*tags) click to toggle source
# File lib/binnacle/logging/formatter.rb, line 38
def push_tags(*tags)
  tags.flatten.reject(&:blank?).tap do |new_tags|
    current_tags.concat new_tags
  end
end
tagged(*tags) { |self| ... } click to toggle source
# File lib/binnacle/logging/formatter.rb, line 31
def tagged(*tags)
  new_tags = push_tags(*tags)
  yield self
ensure
  pop_tags(new_tags.size)
end