daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module ActiveSupport
  2.   module TaggedLogging
  3.     module Formatter
  4.       def current_tags
  5.         thread_key = @thread_key ||= "activesupport_tagged_logging_tags".freeze
  6.         Thread.current[thread_key] ||= []
  7.       end
  8.     end
  9.   end
  10. end
  11.  
  12. module Coralogix
  13.   class TaggedCoralogixLogger < CoralogixLogger
  14.     def self.get_logger name
  15.       TaggedCoralogixLogger.send(:new, name)
  16.     end
  17.  
  18.     def add(severity, message = nil, progname = nil, &block)
  19.       if message.nil?
  20.         if block_given?
  21.           message = yield
  22.         else
  23.           message = progname
  24.         end
  25.       end
  26.  
  27.       tags_text = (Thread.current[:activesupport_tagged_logging_tags] || [])
  28.                   .collect { |tag| "[#{tag}] " }
  29.                   .join
  30.       super severity, "#{tags_text}#{message}", progname
  31.     end
  32.   end
  33. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top