logtail 0.1.10 → 0.1.12
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/.github/workflows/main.yml +18 -12
 - data/example-project/Gemfile +1 -1
 - data/example-project/Gemfile.lock +2 -2
 - data/example-project/main.rb +6 -0
 - data/lib/logtail/config.rb +22 -0
 - data/lib/logtail/log_devices/http.rb +2 -0
 - data/lib/logtail/logger.rb +3 -3
 - data/lib/logtail/version.rb +1 -1
 - data/logtail.gemspec +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 0a6b0738bfe520cbd3e443365dff1cb77b6e2ae2849799badf8d47f785df52d4
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ba02074bd5ee3e2ced09e286712c2af97b6b78175e06d372c50e4bc1a158d114
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 0f1f0865055d6f29eff1d251e8f4b13609ce3306ae2b2e72bd38afb44294c28d562ec7ee3aac74a4fd9ad386c302743d5a9c929741c511401afd50f8e59638ff
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c95ee4374d040f864130b6f5ed0fc4f732e94e6d9b17b64c6579cea8fad59f1710b422a878b6bd798cf09b9d773ef0f3a86e609ac597c87d3c3b3c7ae77e2f1f
         
     | 
    
        data/.github/workflows/main.yml
    CHANGED
    
    | 
         @@ -1,26 +1,32 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            name: build
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            on: 
     | 
| 
      
 3 
     | 
    
         
            +
            on:
         
     | 
| 
      
 4 
     | 
    
         
            +
              push:
         
     | 
| 
      
 5 
     | 
    
         
            +
              schedule:
         
     | 
| 
      
 6 
     | 
    
         
            +
                - cron: '20 5 * * 1'
         
     | 
| 
      
 7 
     | 
    
         
            +
              workflow_dispatch:
         
     | 
| 
       4 
8 
     | 
    
         | 
| 
       5 
9 
     | 
    
         
             
            jobs:
         
     | 
| 
       6 
10 
     | 
    
         
             
              test:
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
11 
     | 
    
         
             
                runs-on: ubuntu-20.04
         
     | 
| 
       9 
12 
     | 
    
         | 
| 
       10 
13 
     | 
    
         
             
                strategy:
         
     | 
| 
      
 14 
     | 
    
         
            +
                  fail-fast: false
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       11 
16 
     | 
    
         
             
                  matrix:
         
     | 
| 
       12 
17 
     | 
    
         
             
                    ruby-version:
         
     | 
| 
       13 
     | 
    
         
            -
                      - 3.2 
     | 
| 
       14 
     | 
    
         
            -
                      - 3.1 
     | 
| 
       15 
     | 
    
         
            -
                      - 3.0 
     | 
| 
       16 
     | 
    
         
            -
                      - 2.7 
     | 
| 
       17 
     | 
    
         
            -
                      - 2.6 
     | 
| 
       18 
     | 
    
         
            -
                      - 2.5 
     | 
| 
       19 
     | 
    
         
            -
                      - 2.4 
     | 
| 
       20 
     | 
    
         
            -
                      - 2.3 
     | 
| 
       21 
     | 
    
         
            -
                      -  
     | 
| 
      
 18 
     | 
    
         
            +
                      - 3.2
         
     | 
| 
      
 19 
     | 
    
         
            +
                      - 3.1
         
     | 
| 
      
 20 
     | 
    
         
            +
                      - 3.0
         
     | 
| 
      
 21 
     | 
    
         
            +
                      - 2.7
         
     | 
| 
      
 22 
     | 
    
         
            +
                      - 2.6
         
     | 
| 
      
 23 
     | 
    
         
            +
                      - 2.5
         
     | 
| 
      
 24 
     | 
    
         
            +
                      - 2.4
         
     | 
| 
      
 25 
     | 
    
         
            +
                      - 2.3
         
     | 
| 
      
 26 
     | 
    
         
            +
                      - jruby-9.4.3.0
         
     | 
| 
       22 
27 
     | 
    
         
             
                      - jruby-9.2.14.0
         
     | 
| 
       23 
     | 
    
         
            -
                      - truffleruby- 
     | 
| 
      
 28 
     | 
    
         
            +
                      - truffleruby-23.0.0
         
     | 
| 
      
 29 
     | 
    
         
            +
                      - truffleruby-22.1.0
         
     | 
| 
       24 
30 
     | 
    
         | 
| 
       25 
31 
     | 
    
         
             
                steps:
         
     | 
| 
       26 
32 
     | 
    
         
             
                  - uses: actions/checkout@v2
         
     | 
    
        data/example-project/Gemfile
    CHANGED
    
    | 
         @@ -1,2 +1,2 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            source 'https://rubygems.org'
         
     | 
| 
       2 
     | 
    
         
            -
            gem "logtail"
         
     | 
| 
      
 2 
     | 
    
         
            +
            gem "logtail", "~> 0.1.12"
         
     | 
    
        data/example-project/main.rb
    CHANGED
    
    | 
         @@ -15,6 +15,9 @@ end 
     | 
|
| 
       15 
15 
     | 
    
         
             
            http_device = Logtail::LogDevices::HTTP.new(ARGV[0])
         
     | 
| 
       16 
16 
     | 
    
         
             
            logger = Logtail::Logger.new(http_device)
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
            # Filter logs that shouldn't be sent to Better Stack, see {Logtail::LogEntry} for available attributes
         
     | 
| 
      
 19 
     | 
    
         
            +
            Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?("DO_NOT_SEND") }
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       18 
21 
     | 
    
         
             
            # LOGGING
         
     | 
| 
       19 
22 
     | 
    
         | 
| 
       20 
23 
     | 
    
         
             
            # Send debug logs messages using the debug() method
         
     | 
| 
         @@ -33,6 +36,9 @@ logger.warn( 
     | 
|
| 
       33 
36 
     | 
    
         
             
                }
         
     | 
| 
       34 
37 
     | 
    
         
             
            )
         
     | 
| 
       35 
38 
     | 
    
         | 
| 
      
 39 
     | 
    
         
            +
            # Some messages can be filtered, see {Logtail::Config#filter_sent_to_better_stack} call above
         
     | 
| 
      
 40 
     | 
    
         
            +
            logger.info("This message will not be sent to Better Stack because it contains 'DO_NOT_SEND'")
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
       36 
42 
     | 
    
         
             
            # Send error messages using the error() method
         
     | 
| 
       37 
43 
     | 
    
         
             
            logger.error("Oops! An error occurred!")
         
     | 
| 
       38 
44 
     | 
    
         | 
    
        data/lib/logtail/config.rb
    CHANGED
    
    | 
         @@ -32,6 +32,28 @@ module Logtail 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                attr_writer :http_body_limit
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
      
 35 
     | 
    
         
            +
                # Whether a particular {Logtail::LogEntry} should be sent to Better Stack
         
     | 
| 
      
 36 
     | 
    
         
            +
                def send_to_better_stack?(log_entry)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  !@better_stack_filters&.any? { |blocker| blocker.call(log_entry) }
         
     | 
| 
      
 38 
     | 
    
         
            +
                rescue => e
         
     | 
| 
      
 39 
     | 
    
         
            +
                  debug { "Could not determine whether to send LogEntry to Better Stack (assumed yes): #{e}" }
         
     | 
| 
      
 40 
     | 
    
         
            +
                  true
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                # This allows filtering logs that are sent to Better Stack. Can be called multiple times, all filters will
         
     | 
| 
      
 44 
     | 
    
         
            +
                # be applied. If the passed block RETURNS TRUE for a particular LogEntry, it WILL NOT BE SENT to Better Stack.
         
     | 
| 
      
 45 
     | 
    
         
            +
                #
         
     | 
| 
      
 46 
     | 
    
         
            +
                # See {Logtail::LogEntry} for available attributes of the block parameter.
         
     | 
| 
      
 47 
     | 
    
         
            +
                #
         
     | 
| 
      
 48 
     | 
    
         
            +
                # @example Rails
         
     | 
| 
      
 49 
     | 
    
         
            +
                #   config.logtail.filter_sent_to_better_stack { |log_entry| log_entry.context_snapshot[:http][:path].start_with?('_') }
         
     | 
| 
      
 50 
     | 
    
         
            +
                # @example Everything else
         
     | 
| 
      
 51 
     | 
    
         
            +
                #   Logtail.config.filter_sent_to_better_stack { |log_entry| log_entry.message.include?('IGNORE') }
         
     | 
| 
      
 52 
     | 
    
         
            +
                def filter_sent_to_better_stack(&block)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  @better_stack_filters ||= []
         
     | 
| 
      
 54 
     | 
    
         
            +
                  @better_stack_filters << -> (log_entry) { yield(log_entry) }
         
     | 
| 
      
 55 
     | 
    
         
            +
                end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
       35 
57 
     | 
    
         
             
                # Convenience method for logging debug statements to the debug logger
         
     | 
| 
       36 
58 
     | 
    
         
             
                # set in this class.
         
     | 
| 
       37 
59 
     | 
    
         
             
                # @private
         
     | 
| 
         @@ -89,6 +89,8 @@ module Logtail 
     | 
|
| 
       89 
89 
     | 
    
         
             
                  # size is constricted by the Logtail API. The actual application limit is a multiple
         
     | 
| 
       90 
90 
     | 
    
         
             
                  # of this. Hence the `@request_queue`.
         
     | 
| 
       91 
91 
     | 
    
         
             
                  def write(msg)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    return unless Logtail.config.send_to_better_stack?(msg)
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
       92 
94 
     | 
    
         
             
                    @msg_queue.enq(msg)
         
     | 
| 
       93 
95 
     | 
    
         | 
| 
       94 
96 
     | 
    
         
             
                    # Lazily start flush threads to ensure threads are alive after forking processes.
         
     | 
    
        data/lib/logtail/logger.rb
    CHANGED
    
    | 
         @@ -57,11 +57,11 @@ module Logtail 
     | 
|
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                    # Because of all the crazy ways Rails has attempted tags, we need this crazy method.
         
     | 
| 
       59 
59 
     | 
    
         
             
                    def extract_active_support_tagged_logging_tags
         
     | 
| 
       60 
     | 
    
         
            -
                      if defined?( 
     | 
| 
       61 
     | 
    
         
            -
                         
     | 
| 
      
 60 
     | 
    
         
            +
                      if defined?(current_tags)
         
     | 
| 
      
 61 
     | 
    
         
            +
                        return current_tags
         
     | 
| 
       62 
62 
     | 
    
         
             
                      end
         
     | 
| 
       63 
63 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
                       
     | 
| 
      
 64 
     | 
    
         
            +
                      defined?(ActiveSupport::IsolatedExecutionState) && ActiveSupport::IsolatedExecutionState[tagged_logging_object_key_name] ||
         
     | 
| 
       65 
65 
     | 
    
         
             
                        Thread.current[:activesupport_tagged_logging_tags] ||
         
     | 
| 
       66 
66 
     | 
    
         
             
                        Thread.current[tagged_logging_object_key_name] ||
         
     | 
| 
       67 
67 
     | 
    
         
             
                        EMPTY_ARRAY
         
     | 
    
        data/lib/logtail/version.rb
    CHANGED
    
    
    
        data/logtail.gemspec
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       18 
18 
     | 
    
         
             
              spec.metadata["homepage_uri"] = spec.homepage
         
     | 
| 
       19 
19 
     | 
    
         
             
              spec.metadata["source_code_uri"] = spec.homepage
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              spec.required_ruby_version = Gem::Requirement.new(">= 2. 
     | 
| 
      
 21 
     | 
    
         
            +
              spec.required_ruby_version = Gem::Requirement.new(">= 2.3")
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
              spec.files         = `git ls-files`.split("\n")
         
     | 
| 
       24 
24 
     | 
    
         
             
              spec.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: logtail
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.12
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Better Stack
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-08-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: msgpack
         
     | 
| 
         @@ -216,7 +216,7 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       216 
216 
     | 
    
         
             
              requirements:
         
     | 
| 
       217 
217 
     | 
    
         
             
              - - ">="
         
     | 
| 
       218 
218 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       219 
     | 
    
         
            -
                  version: 2. 
     | 
| 
      
 219 
     | 
    
         
            +
                  version: '2.3'
         
     | 
| 
       220 
220 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       221 
221 
     | 
    
         
             
              requirements:
         
     | 
| 
       222 
222 
     | 
    
         
             
              - - ">="
         
     |