Class: Binnacle::Logging::Formatter
- Inherits:
-
Object
- Object
- Binnacle::Logging::Formatter
- Defined in:
- lib/binnacle/logging/formatter.rb
Instance Method Summary collapse
- #assets_log_prefix ⇒ Object
- #call(severity, datetime, progname, msg) ⇒ Object
- #clear_tags! ⇒ Object
- #current_tags ⇒ Object
-
#initialize(client) ⇒ Formatter
constructor
A new instance of Formatter.
- #pop_tags(size = 1) ⇒ Object
- #push_tags(*tags) ⇒ Object
- #tagged(*tags) ⇒ Object
Constructor Details
#initialize(client) ⇒ Formatter
Returns a new instance of Formatter.
6 7 8 |
# File 'lib/binnacle/logging/formatter.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#assets_log_prefix ⇒ Object
56 57 58 |
# 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) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 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() = .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) && && !.empty? && .size > 2 .shift(2) event_name = .shift event.configure_from_logging_progname(event_name, @client.logging_channel_id, client_id, session_id, severity, nil, datetime, , { 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! ⇒ Object
48 49 50 |
# File 'lib/binnacle/logging/formatter.rb', line 48 def .clear end |
#current_tags ⇒ Object
52 53 54 |
# File 'lib/binnacle/logging/formatter.rb', line 52 def Thread.current[:activesupport_tagged_logging_tags] ||= [] end |
#pop_tags(size = 1) ⇒ Object
44 45 46 |
# File 'lib/binnacle/logging/formatter.rb', line 44 def (size = 1) .pop size end |
#push_tags(*tags) ⇒ Object
38 39 40 41 42 |
# File 'lib/binnacle/logging/formatter.rb', line 38 def (*) .flatten.reject(&:blank?).tap do || .concat end end |
#tagged(*tags) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/binnacle/logging/formatter.rb', line 31 def tagged(*) = (*) yield self ensure (.size) end |