semantic_logger 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/semantic_logger.rb +4 -3
 - data/lib/semantic_logger/appender/bugsnag.rb +1 -1
 - data/lib/semantic_logger/appender/elasticsearch.rb +1 -1
 - data/lib/semantic_logger/appender/elasticsearch_http.rb +4 -4
 - data/lib/semantic_logger/appender/graylog.rb +1 -1
 - data/lib/semantic_logger/appender/http.rb +2 -2
 - data/lib/semantic_logger/appender/kafka.rb +7 -7
 - data/lib/semantic_logger/appender/mongodb.rb +1 -1
 - data/lib/semantic_logger/appender/sentry.rb +9 -6
 - data/lib/semantic_logger/appender/splunk_http.rb +6 -6
 - data/lib/semantic_logger/appender/syslog.rb +3 -3
 - data/lib/semantic_logger/appender/tcp.rb +5 -5
 - data/lib/semantic_logger/base.rb +1 -1
 - data/lib/semantic_logger/semantic_logger.rb +2 -2
 - data/lib/semantic_logger/version.rb +1 -1
 - data/test/appender/elasticsearch_test.rb +5 -5
 - data/test/appender/sentry_test.rb +6 -6
 - data/test/formatters/color_test.rb +2 -2
 - data/test/formatters/default_test.rb +2 -2
 - data/test/test_helper.rb +0 -8
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4cf47326afecad1dcc0ecd8cffa732b51c023356
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d8d72838b88abb13b94e1433d1676fff824eda26
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: fbefeb4f49ea32b347f09997baf3c9ca7138177c1ae9ea307088ca900cc74ad0fd8d1af8fba0479fcfbd16c37ec9df24aeb1e0fbe988eef90b3fce0e92933652
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0e168803566680fa7b20843df409e55bc4767b90a23c89249a6d7d7237f1b683d135088fc250a192d37726930ebee972844cb5b002e39c68b244eec8ad271d25
         
     | 
    
        data/lib/semantic_logger.rb
    CHANGED
    
    | 
         @@ -41,8 +41,9 @@ module SemanticLogger 
     | 
|
| 
       41 
41 
     | 
    
         
             
            end
         
     | 
| 
       42 
42 
     | 
    
         
             
            # @formatter:on
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
            #  
     | 
| 
       45 
     | 
    
         
            -
            # to be written first
         
     | 
| 
      
 44 
     | 
    
         
            +
            # Flush all appenders at exit, waiting for outstanding messages on the queue
         
     | 
| 
      
 45 
     | 
    
         
            +
            # to be written first.
         
     | 
| 
       46 
46 
     | 
    
         
             
            at_exit do
         
     | 
| 
       47 
     | 
    
         
            -
               
     | 
| 
      
 47 
     | 
    
         
            +
              # Cannot close since test frameworks only run at exit, at which point the logging would already be closed.
         
     | 
| 
      
 48 
     | 
    
         
            +
              SemanticLogger.flush
         
     | 
| 
       48 
49 
     | 
    
         
             
            end
         
     | 
| 
         @@ -38,7 +38,7 @@ class SemanticLogger::Appender::Bugsnag < SemanticLogger::Subscriber 
     | 
|
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
              # Returns [Hash] of parameters to send to Bugsnag.
         
     | 
| 
       40 
40 
     | 
    
         
             
              def call(log, logger)
         
     | 
| 
       41 
     | 
    
         
            -
                h 
     | 
| 
      
 41 
     | 
    
         
            +
                h            = SemanticLogger::Formatters::Raw.new.call(log, logger)
         
     | 
| 
       42 
42 
     | 
    
         
             
                h[:severity] = log_level(log)
         
     | 
| 
       43 
43 
     | 
    
         
             
                h.delete(:message) if h[:exception] && (h[:message] == h[:exception][:message])
         
     | 
| 
       44 
44 
     | 
    
         
             
                h.delete(:time)
         
     | 
| 
         @@ -69,7 +69,7 @@ class SemanticLogger::Appender::Elasticsearch < SemanticLogger::Subscriber 
     | 
|
| 
       69 
69 
     | 
    
         
             
              #     Name of this application to appear in log messages.
         
     | 
| 
       70 
70 
     | 
    
         
             
              #     Default: SemanticLogger.application
         
     | 
| 
       71 
71 
     | 
    
         
             
              def initialize(url: 'http://localhost:9200', index: 'semantic_logger', type: 'log', flush_interval: 1, timeout_interval: 10, batch_size: 500,
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
      
 72 
     | 
    
         
            +
                             level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
                @url              = url
         
     | 
| 
       75 
75 
     | 
    
         
             
                @index            = index
         
     | 
| 
         @@ -49,13 +49,13 @@ class SemanticLogger::Appender::ElasticsearchHttp < SemanticLogger::Appender::Ht 
     | 
|
| 
       49 
49 
     | 
    
         
             
              #     Name of this application to appear in log messages.
         
     | 
| 
       50 
50 
     | 
    
         
             
              #     Default: SemanticLogger.application
         
     | 
| 
       51 
51 
     | 
    
         
             
              def initialize(index: 'semantic_logger', type: 'log',
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
                             url: 'http://localhost:9200', compress: false, ssl: {}, open_timeout: 2.0, read_timeout: 1.0, continue_timeout: 1.0,
         
     | 
| 
      
 53 
     | 
    
         
            +
                             level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
                @index = index
         
     | 
| 
       56 
56 
     | 
    
         
             
                @type  = type
         
     | 
| 
       57 
     | 
    
         
            -
                super(url: 
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
      
 57 
     | 
    
         
            +
                super(url:   url, compress: compress, ssl: ssl, open_timeout: 2.0, read_timeout: open_timeout, continue_timeout: continue_timeout,
         
     | 
| 
      
 58 
     | 
    
         
            +
                      level: level, formatter: formatter, filter: filter, application: application, host: host, &block)
         
     | 
| 
       59 
59 
     | 
    
         | 
| 
       60 
60 
     | 
    
         
             
                @request_path = "#{@path.end_with?('/') ? @path : "#{@path}/"}#{@index}-%Y.%m.%d"
         
     | 
| 
       61 
61 
     | 
    
         
             
                @logging_path = "#{@request_path}/#{type}"
         
     | 
| 
         @@ -81,7 +81,7 @@ class SemanticLogger::Appender::Graylog < SemanticLogger::Subscriber 
     | 
|
| 
       81 
81 
     | 
    
         
             
              #     Name of this application to appear in log messages.
         
     | 
| 
       82 
82 
     | 
    
         
             
              #     Default: SemanticLogger.application
         
     | 
| 
       83 
83 
     | 
    
         
             
              def initialize(url: 'udp://localhost:12201', max_size: 'WAN', gelf_options: {}, level_map: LevelMap.new,
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
      
 84 
     | 
    
         
            +
                             level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         
             
                @url          = url
         
     | 
| 
       87 
87 
     | 
    
         
             
                @max_size     = max_size
         
     | 
| 
         @@ -17,7 +17,7 @@ require 'json' 
     | 
|
| 
       17 
17 
     | 
    
         
             
            #   )
         
     | 
| 
       18 
18 
     | 
    
         
             
            class SemanticLogger::Appender::Http < SemanticLogger::Subscriber
         
     | 
| 
       19 
19 
     | 
    
         
             
              attr_accessor :username, :application, :host, :compress, :header,
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
                            :open_timeout, :read_timeout, :continue_timeout
         
     | 
| 
       21 
21 
     | 
    
         
             
              attr_reader :http, :url, :server, :port, :path, :ssl_options
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
              # Create HTTP(S) log appender
         
     | 
| 
         @@ -78,7 +78,7 @@ class SemanticLogger::Appender::Http < SemanticLogger::Subscriber 
     | 
|
| 
       78 
78 
     | 
    
         
             
              #   continue_timeout: [Float]
         
     | 
| 
       79 
79 
     | 
    
         
             
              #     Default: 1.0
         
     | 
| 
       80 
80 
     | 
    
         
             
              def initialize(url:, compress: false, ssl: {}, username: nil, password: nil, open_timeout: 2.0, read_timeout: 1.0, continue_timeout: 1.0,
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 81 
     | 
    
         
            +
                             level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
83 
     | 
    
         
             
                @url              = url
         
     | 
| 
       84 
84 
     | 
    
         
             
                @ssl_options      = ssl
         
     | 
| 
         @@ -21,9 +21,9 @@ require 'date' 
     | 
|
| 
       21 
21 
     | 
    
         
             
            #   )
         
     | 
| 
       22 
22 
     | 
    
         
             
            class SemanticLogger::Appender::Kafka < SemanticLogger::Subscriber
         
     | 
| 
       23 
23 
     | 
    
         
             
              attr_accessor :seed_brokers, :client_id, :connect_timeout, :socket_timeout,
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                            :ssl_ca_cert, :ssl_client_cert, :ssl_client_cert_key,
         
     | 
| 
      
 25 
     | 
    
         
            +
                            :delivery_threshold, :delivery_interval,
         
     | 
| 
      
 26 
     | 
    
         
            +
                            :topic, :partition, :partition_key, :key
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
              # Send log messages to Kafka in JSON format.
         
     | 
| 
       29 
29 
     | 
    
         
             
              #
         
     | 
| 
         @@ -110,10 +110,10 @@ class SemanticLogger::Appender::Kafka < SemanticLogger::Subscriber 
     | 
|
| 
       110 
110 
     | 
    
         
             
              #     Name of this application to appear in log messages.
         
     | 
| 
       111 
111 
     | 
    
         
             
              #     Default: SemanticLogger.application
         
     | 
| 
       112 
112 
     | 
    
         
             
              def initialize(seed_brokers:, client_id: 'semantic-logger', connect_timeout: nil, socket_timeout: nil,
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
      
 113 
     | 
    
         
            +
                             ssl_ca_cert: nil, ssl_client_cert: nil, ssl_client_cert_key: nil,
         
     | 
| 
      
 114 
     | 
    
         
            +
                             topic: 'log_messages', partition: nil, partition_key: nil, key: nil,
         
     | 
| 
      
 115 
     | 
    
         
            +
                             delivery_threshold: 100, delivery_interval: 10,
         
     | 
| 
      
 116 
     | 
    
         
            +
                             level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
       118 
118 
     | 
    
         
             
                @seed_brokers        = seed_brokers
         
     | 
| 
       119 
119 
     | 
    
         
             
                @client_id           = @client_id
         
     | 
| 
         @@ -104,7 +104,7 @@ module SemanticLogger 
     | 
|
| 
       104 
104 
     | 
    
         
             
                  #     Name of this application to appear in log messages.
         
     | 
| 
       105 
105 
     | 
    
         
             
                  #     Default: SemanticLogger.application
         
     | 
| 
       106 
106 
     | 
    
         
             
                  def initialize(uri:, collection_name: 'semantic_logger', write_concern: 0, collection_size: 1024**3, collection_max: nil,
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
      
 107 
     | 
    
         
            +
                                 level: nil, formatter: nil, filter: nil, host: nil, application: nil, &block)
         
     | 
| 
       108 
108 
     | 
    
         | 
| 
       109 
109 
     | 
    
         
             
                    @client          = Mongo::Client.new(uri, logger: SemanticLogger::Processor.logger.clone)
         
     | 
| 
       110 
110 
     | 
    
         
             
                    @collection_name = collection_name
         
     | 
| 
         @@ -36,25 +36,28 @@ class SemanticLogger::Appender::Sentry < SemanticLogger::Subscriber 
     | 
|
| 
       36 
36 
     | 
    
         
             
              #     Name of this application to appear in log messages.
         
     | 
| 
       37 
37 
     | 
    
         
             
              #     Default: SemanticLogger.application
         
     | 
| 
       38 
38 
     | 
    
         
             
              def initialize(level: :error, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
      
 39 
     | 
    
         
            +
                # Replace the Sentry Raven logger so that we can identify its log messages and not forward them to Sentry
         
     | 
| 
      
 40 
     | 
    
         
            +
                Raven.configure { |config| config.logger = SemanticLogger[Raven] }
         
     | 
| 
       39 
41 
     | 
    
         
             
                super(level: level, formatter: formatter, filter: filter, application: application, host: host, &block)
         
     | 
| 
       40 
42 
     | 
    
         
             
              end
         
     | 
| 
       41 
43 
     | 
    
         | 
| 
       42 
44 
     | 
    
         
             
              # Send an error notification to sentry
         
     | 
| 
       43 
45 
     | 
    
         
             
              def log(log)
         
     | 
| 
       44 
46 
     | 
    
         
             
                return false unless should_log?(log)
         
     | 
| 
      
 47 
     | 
    
         
            +
                # Ignore logs coming from Ravent itself
         
     | 
| 
      
 48 
     | 
    
         
            +
                return false if log.name == 'Raven'
         
     | 
| 
       45 
49 
     | 
    
         | 
| 
       46 
50 
     | 
    
         
             
                context = formatter.call(log, self)
         
     | 
| 
       47 
51 
     | 
    
         
             
                if log.exception
         
     | 
| 
       48 
52 
     | 
    
         
             
                  context.delete(:exception)
         
     | 
| 
       49 
53 
     | 
    
         
             
                  Raven.capture_exception(log.exception, context)
         
     | 
| 
       50 
54 
     | 
    
         
             
                else
         
     | 
| 
       51 
     | 
    
         
            -
                   
     | 
| 
       52 
     | 
    
         
            -
                     
     | 
| 
       53 
     | 
    
         
            -
                     
     | 
| 
       54 
     | 
    
         
            -
                    extra:         context
         
     | 
| 
      
 55 
     | 
    
         
            +
                  attrs                     = {
         
     | 
| 
      
 56 
     | 
    
         
            +
                    level: context.delete(:level),
         
     | 
| 
      
 57 
     | 
    
         
            +
                    extra: context
         
     | 
| 
       55 
58 
     | 
    
         
             
                  }
         
     | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
       57 
     | 
    
         
            -
                  Raven.capture_message( 
     | 
| 
      
 59 
     | 
    
         
            +
                  attrs[:extra][:backtrace] = log.backtrace if log.backtrace
         
     | 
| 
      
 60 
     | 
    
         
            +
                  Raven.capture_message(context[:message], attrs)
         
     | 
| 
       58 
61 
     | 
    
         
             
                end
         
     | 
| 
       59 
62 
     | 
    
         
             
                true
         
     | 
| 
       60 
63 
     | 
    
         
             
              end
         
     | 
| 
         @@ -67,14 +67,14 @@ class SemanticLogger::Appender::SplunkHttp < SemanticLogger::Appender::Http 
     | 
|
| 
       67 
67 
     | 
    
         
             
              #     Proc: Only include log messages where the supplied Proc returns true
         
     | 
| 
       68 
68 
     | 
    
         
             
              #           The Proc must return true or false.
         
     | 
| 
       69 
69 
     | 
    
         
             
              def initialize(token: nil, source_type: nil, index: nil,
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
      
 70 
     | 
    
         
            +
                             url:, compress: true, ssl: {}, open_timeout: 2.0, read_timeout: 1.0, continue_timeout: 1.0,
         
     | 
| 
      
 71 
     | 
    
         
            +
                             level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
                @source_type 
     | 
| 
       74 
     | 
    
         
            -
                @index 
     | 
| 
      
 73 
     | 
    
         
            +
                @source_type = source_type
         
     | 
| 
      
 74 
     | 
    
         
            +
                @index       = index
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
       76 
     | 
    
         
            -
                super(url: 
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
                super(url:   url, compress: compress, ssl: ssl, open_timeout: 2.0, read_timeout: open_timeout, continue_timeout: continue_timeout,
         
     | 
| 
      
 77 
     | 
    
         
            +
                      level: level, formatter: formatter, filter: filter, application: application, host: host, &block)
         
     | 
| 
       78 
78 
     | 
    
         | 
| 
       79 
79 
     | 
    
         
             
                # Put splunk auth token in the header of every HTTP post.
         
     | 
| 
       80 
80 
     | 
    
         
             
                @header['Authorization'] = "Splunk #{token}"
         
     | 
| 
         @@ -120,9 +120,9 @@ module SemanticLogger 
     | 
|
| 
       120 
120 
     | 
    
         
             
                  #     # Change the warn level to LOG_NOTICE level instead of a the default of LOG_WARNING.
         
     | 
| 
       121 
121 
     | 
    
         
             
                  #     SemanticLogger.add_appender(appender: :syslog, level_map: {warn: ::Syslog::LOG_NOTICE})
         
     | 
| 
       122 
122 
     | 
    
         
             
                  def initialize(url: 'syslog://localhost',
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 123 
     | 
    
         
            +
                                 facility: ::Syslog::LOG_USER, level_map: SemanticLogger::Formatters::Syslog::LevelMap.new, options: ::Syslog::LOG_PID|::Syslog::LOG_CONS,
         
     | 
| 
      
 124 
     | 
    
         
            +
                                 tcp_client: {},
         
     | 
| 
      
 125 
     | 
    
         
            +
                                 level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block)
         
     | 
| 
       126 
126 
     | 
    
         | 
| 
       127 
127 
     | 
    
         
             
                    @options            = options
         
     | 
| 
       128 
128 
     | 
    
         
             
                    @facility           = facility
         
     | 
| 
         @@ -182,11 +182,11 @@ module SemanticLogger 
     | 
|
| 
       182 
182 
     | 
    
         
             
                  #     connect_retry_count:    5
         
     | 
| 
       183 
183 
     | 
    
         
             
                  #   )
         
     | 
| 
       184 
184 
     | 
    
         
             
                  def initialize(server: nil, servers: nil, separator: "\n",
         
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
      
 185 
     | 
    
         
            +
                                 policy: :ordered, buffered: true, #keepalive: true,
         
     | 
| 
      
 186 
     | 
    
         
            +
                                 connect_timeout: 10.0, read_timeout: 60.0, write_timeout: 60.0,
         
     | 
| 
      
 187 
     | 
    
         
            +
                                 connect_retry_count: 10, retry_count: 3, connect_retry_interval: 0.5, close_on_error: true,
         
     | 
| 
      
 188 
     | 
    
         
            +
                                 on_connect: nil, proxy_server: nil, ssl: nil,
         
     | 
| 
      
 189 
     | 
    
         
            +
                                 level: nil, formatter: nil, filter: nil, application: nil, host: nil, &block
         
     | 
| 
       190 
190 
     | 
    
         
             
                  )
         
     | 
| 
       191 
191 
     | 
    
         
             
                    @separator                 = separator
         
     | 
| 
       192 
192 
     | 
    
         
             
                    @options                   = {
         
     | 
    
        data/lib/semantic_logger/base.rb
    CHANGED
    
    | 
         @@ -326,7 +326,7 @@ module SemanticLogger 
     | 
|
| 
       326 
326 
     | 
    
         
             
                        if silence_level = params[:silence]
         
     | 
| 
       327 
327 
     | 
    
         
             
                          # In case someone accidentally sets `silence: true` instead of `silence: :error`
         
     | 
| 
       328 
328 
     | 
    
         
             
                          silence_level = :error if silence_level == true
         
     | 
| 
       329 
     | 
    
         
            -
                          silence(silence_level) {yield(params)}
         
     | 
| 
      
 329 
     | 
    
         
            +
                          silence(silence_level) { yield(params) }
         
     | 
| 
       330 
330 
     | 
    
         
             
                        else
         
     | 
| 
       331 
331 
     | 
    
         
             
                          yield(params)
         
     | 
| 
       332 
332 
     | 
    
         
             
                        end
         
     | 
| 
         @@ -193,7 +193,7 @@ module SemanticLogger 
     | 
|
| 
       193 
193 
     | 
    
         
             
              #   Not all appenders implement reopen.
         
     | 
| 
       194 
194 
     | 
    
         
             
              #   Check the code for each appender you are using before relying on this behavior.
         
     | 
| 
       195 
195 
     | 
    
         
             
              def self.reopen
         
     | 
| 
       196 
     | 
    
         
            -
                @appenders.each {|appender| appender.reopen if appender.respond_to?(:reopen)}
         
     | 
| 
      
 196 
     | 
    
         
            +
                @appenders.each { |appender| appender.reopen if appender.respond_to?(:reopen) }
         
     | 
| 
       197 
197 
     | 
    
         
             
                # After a fork the appender thread is not running, start it if it is not running.
         
     | 
| 
       198 
198 
     | 
    
         
             
                SemanticLogger::Processor.start
         
     | 
| 
       199 
199 
     | 
    
         
             
              end
         
     | 
| 
         @@ -407,7 +407,7 @@ module SemanticLogger 
     | 
|
| 
       407 
407 
     | 
    
         
             
              def self.named_tags
         
     | 
| 
       408 
408 
     | 
    
         
             
                if (list = Thread.current[:semantic_logger_named_tags]) && !list.empty?
         
     | 
| 
       409 
409 
     | 
    
         
             
                  if list.size > 1
         
     | 
| 
       410 
     | 
    
         
            -
                    list.reduce({}) {|sum, h| sum.merge(h)}
         
     | 
| 
      
 410 
     | 
    
         
            +
                    list.reduce({}) { |sum, h| sum.merge(h) }
         
     | 
| 
       411 
411 
     | 
    
         
             
                  else
         
     | 
| 
       412 
412 
     | 
    
         
             
                    list.first.clone
         
     | 
| 
       413 
413 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -8,7 +8,7 @@ module Appender 
     | 
|
| 
       8 
8 
     | 
    
         
             
                    skip('Concurrent::TimerTask issue is preventing the process from stopping.') if defined? JRuby
         
     | 
| 
       9 
9 
     | 
    
         
             
                    Elasticsearch::Transport::Client.stub_any_instance(:bulk, true) do
         
     | 
| 
       10 
10 
     | 
    
         
             
                      @appender = SemanticLogger::Appender::Elasticsearch.new(
         
     | 
| 
       11 
     | 
    
         
            -
                        url: 
     | 
| 
      
 11 
     | 
    
         
            +
                        url:        'http://localhost:9200',
         
     | 
| 
       12 
12 
     | 
    
         
             
                        batch_size: 1 # immediate flush
         
     | 
| 
       13 
13 
     | 
    
         
             
                      )
         
     | 
| 
       14 
14 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -21,7 +21,7 @@ module Appender 
     | 
|
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                  it 'logs to daily indexes' do
         
     | 
| 
       23 
23 
     | 
    
         
             
                    index = nil
         
     | 
| 
       24 
     | 
    
         
            -
                    @appender.stub(:enqueue, ->(ind, json){ index = ind['index']['_index'] } 
     | 
| 
      
 24 
     | 
    
         
            +
                    @appender.stub(:enqueue, ->(ind, json) { index = ind['index']['_index'] }) do
         
     | 
| 
       25 
25 
     | 
    
         
             
                      @appender.info @message
         
     | 
| 
       26 
26 
     | 
    
         
             
                    end
         
     | 
| 
       27 
27 
     | 
    
         
             
                    assert_equal "semantic_logger-#{Time.now.strftime('%Y.%m.%d')}", index
         
     | 
| 
         @@ -30,7 +30,7 @@ module Appender 
     | 
|
| 
       30 
30 
     | 
    
         
             
                  SemanticLogger::LEVELS.each do |level|
         
     | 
| 
       31 
31 
     | 
    
         
             
                    it "send #{level}" do
         
     | 
| 
       32 
32 
     | 
    
         
             
                      request = nil
         
     | 
| 
       33 
     | 
    
         
            -
                      @appender.client.stub(:bulk, -> r { request = r; {"status" => 201 
     | 
| 
      
 33 
     | 
    
         
            +
                      @appender.client.stub(:bulk, -> r { request = r; {"status" => 201} }) do
         
     | 
| 
       34 
34 
     | 
    
         
             
                        @appender.send(level, @message)
         
     | 
| 
       35 
35 
     | 
    
         
             
                      end
         
     | 
| 
       36 
36 
     | 
    
         | 
| 
         @@ -47,7 +47,7 @@ module Appender 
     | 
|
| 
       47 
47 
     | 
    
         
             
                        exc = e
         
     | 
| 
       48 
48 
     | 
    
         
             
                      end
         
     | 
| 
       49 
49 
     | 
    
         
             
                      request = nil
         
     | 
| 
       50 
     | 
    
         
            -
                      @appender.client.stub(:bulk, -> r { request = r; {"status" => 201 
     | 
| 
      
 50 
     | 
    
         
            +
                      @appender.client.stub(:bulk, -> r { request = r; {"status" => 201} }) do
         
     | 
| 
       51 
51 
     | 
    
         
             
                        @appender.send(level, 'Reading File', exc)
         
     | 
| 
       52 
52 
     | 
    
         
             
                      end
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
         @@ -63,7 +63,7 @@ module Appender 
     | 
|
| 
       63 
63 
     | 
    
         | 
| 
       64 
64 
     | 
    
         
             
                    it "sends #{level} custom attributes" do
         
     | 
| 
       65 
65 
     | 
    
         
             
                      request = nil
         
     | 
| 
       66 
     | 
    
         
            -
                      @appender.client.stub(:bulk, -> r { request = r; {"status" => 201 
     | 
| 
      
 66 
     | 
    
         
            +
                      @appender.client.stub(:bulk, -> r { request = r; {"status" => 201} }) do
         
     | 
| 
       67 
67 
     | 
    
         
             
                        @appender.send(level, @message, {key1: 1, key2: 'a'})
         
     | 
| 
       68 
68 
     | 
    
         
             
                      end
         
     | 
| 
       69 
69 
     | 
    
         | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require_relative '../test_helper'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # Unit Test for SemanticLogger::Appender:: 
     | 
| 
      
 3 
     | 
    
         
            +
            # Unit Test for SemanticLogger::Appender::Sentry
         
     | 
| 
       4 
4 
     | 
    
         
             
            module Appender
         
     | 
| 
       5 
5 
     | 
    
         
             
              class SentryTest < Minitest::Test
         
     | 
| 
       6 
6 
     | 
    
         
             
                describe SemanticLogger::Appender::Sentry do
         
     | 
| 
         @@ -16,16 +16,16 @@ module Appender 
     | 
|
| 
       16 
16 
     | 
    
         
             
                      Raven.stub(:capture_message, -> msg, h { error_message = msg; hash = h }) do
         
     | 
| 
       17 
17 
     | 
    
         
             
                        @appender.send(level, @message)
         
     | 
| 
       18 
18 
     | 
    
         
             
                      end
         
     | 
| 
       19 
     | 
    
         
            -
                      assert_equal @message,  
     | 
| 
       20 
     | 
    
         
            -
                      assert_equal 'SemanticLogger::Appender::Sentry', hash[: 
     | 
| 
      
 19 
     | 
    
         
            +
                      assert_equal @message, error_message
         
     | 
| 
      
 20 
     | 
    
         
            +
                      assert_equal 'SemanticLogger::Appender::Sentry', hash[:extra][:name]
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                      if [:error, :fatal].include?(level)
         
     | 
| 
       23 
     | 
    
         
            -
                        assert hash.has_key?(:backtrace)
         
     | 
| 
      
 23 
     | 
    
         
            +
                        assert hash[:extra].has_key?(:backtrace)
         
     | 
| 
       24 
24 
     | 
    
         
             
                      else
         
     | 
| 
       25 
     | 
    
         
            -
                        refute hash.has_key?(:backtrace)
         
     | 
| 
      
 25 
     | 
    
         
            +
                        refute hash[:extra].has_key?(:backtrace)
         
     | 
| 
       26 
26 
     | 
    
         
             
                      end
         
     | 
| 
       27 
27 
     | 
    
         
             
                      assert_equal true, hash.has_key?(:extra)
         
     | 
| 
       28 
     | 
    
         
            -
                      assert_equal level, hash[: 
     | 
| 
      
 28 
     | 
    
         
            +
                      assert_equal level, hash[:level]
         
     | 
| 
       29 
29 
     | 
    
         
             
                    end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                    it "sends #{level} exceptions" do
         
     | 
| 
         @@ -90,7 +90,7 @@ module SemanticLogger 
     | 
|
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         
             
                      it 'logs short duration' do
         
     | 
| 
       92 
92 
     | 
    
         
             
                        log.duration = 1.34567
         
     | 
| 
       93 
     | 
    
         
            -
                        duration 
     | 
| 
      
 93 
     | 
    
         
            +
                        duration     = SemanticLogger::Formatters::Base::PRECISION == 3 ? "(#{bold}1ms#{clear})" : "(#{bold}1.346ms#{clear})"
         
     | 
| 
       94 
94 
     | 
    
         
             
                        assert_equal duration, formatter.duration
         
     | 
| 
       95 
95 
     | 
    
         
             
                      end
         
     | 
| 
       96 
96 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -143,7 +143,7 @@ module SemanticLogger 
     | 
|
| 
       143 
143 
     | 
    
         
             
                        log.backtrace  = backtrace
         
     | 
| 
       144 
144 
     | 
    
         
             
                        set_exception
         
     | 
| 
       145 
145 
     | 
    
         
             
                        duration = SemanticLogger::Formatters::Base::PRECISION == 3 ? '1' : '1.346'
         
     | 
| 
       146 
     | 
    
         
            -
                        str 
     | 
| 
      
 146 
     | 
    
         
            +
                        str      = "#{expected_time} #{color}D#{clear} [#{$$}:#{Thread.current.name} default_test.rb:35] [#{color}first#{clear}] [#{color}second#{clear}] [#{color}third#{clear}] {#{color}first: 1#{clear}, #{color}second: 2#{clear}, #{color}third: 3#{clear}} (#{bold}#{duration}ms#{clear}) #{color}ColorTest#{clear} -- Hello World -- #{{:first => 1, :second => 2, :third => 3}.ai(multiline: false)} -- Exception: #{color}RuntimeError: Oh no#{clear}\n"
         
     | 
| 
       147 
147 
     | 
    
         
             
                        assert_equal str, formatter.call(log, nil).lines.first
         
     | 
| 
       148 
148 
     | 
    
         
             
                      end
         
     | 
| 
       149 
149 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -102,7 +102,7 @@ module SemanticLogger 
     | 
|
| 
       102 
102 
     | 
    
         | 
| 
       103 
103 
     | 
    
         
             
                      it 'logs short duration' do
         
     | 
| 
       104 
104 
     | 
    
         
             
                        log.duration = 1.34567
         
     | 
| 
       105 
     | 
    
         
            -
                        duration 
     | 
| 
      
 105 
     | 
    
         
            +
                        duration     = SemanticLogger::Formatters::Base::PRECISION == 3 ? "(1ms)" : "(1.346ms)"
         
     | 
| 
       106 
106 
     | 
    
         
             
                        assert_equal duration, formatter.duration
         
     | 
| 
       107 
107 
     | 
    
         
             
                      end
         
     | 
| 
       108 
108 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -165,7 +165,7 @@ module SemanticLogger 
     | 
|
| 
       165 
165 
     | 
    
         
             
                        log.backtrace  = backtrace
         
     | 
| 
       166 
166 
     | 
    
         
             
                        set_exception
         
     | 
| 
       167 
167 
     | 
    
         
             
                        duration = SemanticLogger::Formatters::Base::PRECISION == 3 ? '1' : '1.346'
         
     | 
| 
       168 
     | 
    
         
            -
                        str 
     | 
| 
      
 168 
     | 
    
         
            +
                        str      = "#{expected_time} D [#{$$}:#{Thread.current.name} default_test.rb:99] [first] [second] [third] {first: 1, second: 2, third: 3} (#{duration}ms) DefaultTest -- Hello World -- {:first=>1, :second=>2, :third=>3} -- Exception: RuntimeError: Oh no\n"
         
     | 
| 
       169 
169 
     | 
    
         
             
                        assert_equal str, formatter.call(log, nil).lines.first
         
     | 
| 
       170 
170 
     | 
    
         
             
                      end
         
     | 
| 
       171 
171 
     | 
    
         
             
                    end
         
     | 
    
        data/test/test_helper.rb
    CHANGED
    
    | 
         @@ -13,11 +13,3 @@ require_relative 'mock_logger' 
     | 
|
| 
       13 
13 
     | 
    
         
             
            require 'awesome_print'
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            #Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
         
     | 
| 
       16 
     | 
    
         
            -
            Signal.trap('TTIN') do
         
     | 
| 
       17 
     | 
    
         
            -
              Thread.list.each do |thread|
         
     | 
| 
       18 
     | 
    
         
            -
                puts
         
     | 
| 
       19 
     | 
    
         
            -
                puts
         
     | 
| 
       20 
     | 
    
         
            -
                ap thread.name
         
     | 
| 
       21 
     | 
    
         
            -
                ap thread.backtrace
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: semantic_logger
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 4.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 4.1.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Reid Morrison
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-05-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: concurrent-ruby
         
     |