tablexi-logger 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24f5baa0ee4ada9002d1ede440013adf9700244e
4
- data.tar.gz: 2ea1197b9a786f1a5f0b92cf75dea74493ff6b00
3
+ metadata.gz: 2d9fa826ea67489a42f9e5cb480eaa5f6d6c7bec
4
+ data.tar.gz: 8a6f3c8d05b8154b830874388258b55d10ed4e25
5
5
  SHA512:
6
- metadata.gz: 2828d849cb6f2b4c1822fe0c8bd5341ae7d90ef5c166d17bacd4713eec25aa2fbb2d2f37aea50f5af4b0271945d2bccea065d0ff8c56393f612a0389d0d8490e
7
- data.tar.gz: 6a0d581fc5270ad173d52cf55b248a24415beebbc2bfdc433802ccb314aa740c91c624a6d723ee11275b87f0f33c881c869634e3c4ef6ad15ba173f3897b683f
6
+ metadata.gz: 9a8cc8890f0aa7e77ecbb838f51ccb7d7a148e1377a0ee72deb9d11be842382c149175ad217020da6256a83657d92800707d1ead524f0d62785f5cc1f009319f
7
+ data.tar.gz: cc024a93bf7e314560b2ad3f4e1e0976c96cf4d18a4a92d3e274ccec604846b368984ef30ef4d6ab8f81c1d94163790a48b5bd00e67088484007cdbe58f861e1
data/Changelog.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog (in reverse chronological order)
2
+
3
+ ## 1.1.0 (2015-09-02)
4
+
5
+ * Detect lograge, and prevent corruption of lograge-formatted logs
6
+
7
+ ## 1.0.0 (2015-09-02)
8
+
9
+ Initial release.
data/README.md CHANGED
@@ -21,7 +21,7 @@ Tablexi.logger.error "Request Timeout", metric: :timeout_error
21
21
  You may also assign the logger, for example configuring a null logger would look like this:
22
22
 
23
23
  ```ruby
24
- Tablexi.logger = ::Logger.new(File.open(File::NULL, "w"))
24
+ Tablexi.logger = Tablexi::Logger.new # not configured with any handlers, so does nothing
25
25
  ```
26
26
 
27
27
  ## Extending Functionality
data/circle.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  machine:
2
2
  ruby:
3
- version: 2.1.4
3
+ version: 2.2.2
4
4
  dependencies:
5
5
  pre:
6
6
  - gem install bundler --pre
@@ -8,3 +8,5 @@ test:
8
8
  override:
9
9
  - bundle exec rspec --order rand -fd --format RspecJunitFormatter --out $CIRCLE_TEST_REPORTS/rspec.xml:
10
10
  parallel: true
11
+ post:
12
+ - bundle exec rubocop
@@ -10,6 +10,7 @@ require "tablexi/logger/option_filter/humanize_request"
10
10
  module Tablexi
11
11
  class << self
12
12
  attr_writer :logger
13
+ attr_writer :bare_logger
13
14
 
14
15
  def logger
15
16
  @logger ||= default_logger
@@ -18,9 +19,11 @@ module Tablexi
18
19
  def default_logger(base_logger = bare_logger)
19
20
  Logger.new.tap do |logger|
20
21
  logger.option_filters << Tablexi::Logger::OptionFilter::HumanizeRequest
22
+
21
23
  Tablexi::Logger::SEVERITIES.each do |severity|
22
24
  logger.handlers[severity] << Tablexi::Logger::Standard.new(base_logger, severity: severity)
23
25
  end
26
+
24
27
  trackable_severities = %i(error fatal unknown)
25
28
  logger.handle trackable_severities, &Tablexi::Logger::Rollbar if defined?(::Rollbar)
26
29
  logger.handle trackable_severities, &Tablexi::Logger::NewRelic if defined?(::NewRelic)
@@ -28,9 +31,8 @@ module Tablexi
28
31
  end
29
32
 
30
33
  private def bare_logger
31
- Rails.logger
32
- rescue NameError
33
- ::Logger.new($stdout).tap do |config|
34
+ return @bare_logger if @bare_logger
35
+ @bare_logger = ::Logger.new($stdout).tap do |config|
34
36
  config.level = ::Logger::DEBUG
35
37
  end
36
38
  end
@@ -80,3 +82,5 @@ module Tablexi
80
82
  end
81
83
  end
82
84
  end
85
+
86
+ require "tablexi/logger/railtie" if defined?(Rails)
@@ -0,0 +1,25 @@
1
+ module Tablexi
2
+ class Logger
3
+ class Railtie < Rails::Railtie
4
+ config.after_initialize do |app|
5
+ Tablexi.bare_logger = Rails.logger
6
+
7
+ setup_lograge(app) if defined?(Lograge) && app.config.lograge.enabled
8
+ end
9
+
10
+ def setup_lograge(app)
11
+ # since Lograge's after_initialize isn't guaranteed to run before this one
12
+ # we need to make sure the setup occurs before we check lograge.logger
13
+ Lograge.setup(app)
14
+
15
+ if app.config.lograge.logger == Rails.logger
16
+ # We need to preserve lograge file format integrity if lograge is using
17
+ # Rails.logger - presumably error tracking services will report the errors
18
+ # so they aren't swallowed silently.
19
+ null_logger = ::Logger.new(File.open(File::NULL, "w"))
20
+ Tablexi.bare_logger = null_logger
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Tablexi
2
2
  class Logger
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tablexi-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Table XI Partners LLC
@@ -91,6 +91,7 @@ extra_rdoc_files: []
91
91
  files:
92
92
  - ".gitignore"
93
93
  - ".rubocop.yml"
94
+ - Changelog.md
94
95
  - Gemfile
95
96
  - LICENSE.txt
96
97
  - README.md
@@ -101,6 +102,7 @@ files:
101
102
  - lib/tablexi/logger.rb
102
103
  - lib/tablexi/logger/new_relic.rb
103
104
  - lib/tablexi/logger/option_filter/humanize_request.rb
105
+ - lib/tablexi/logger/railtie.rb
104
106
  - lib/tablexi/logger/rollbar.rb
105
107
  - lib/tablexi/logger/severities.rb
106
108
  - lib/tablexi/logger/standard.rb