heavylog 0.0.5 → 0.0.6

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
  SHA256:
3
- metadata.gz: 3c0a001bf84d8cba63f3673c567e6626ccdc09c9627615a302f2159ecfeb8990
4
- data.tar.gz: 8baee7cf7ceae53635d21ef0d6f653f56ffcc89d96e4c7cca24aa214d4c47d89
3
+ metadata.gz: c4f2f4bdbb5f72c23e7308fc62168ba9c8e8d132146984889c41235fe5cac73a
4
+ data.tar.gz: 759a9ed8c5180282772282f7a19a5e25b697184cf892236fe30fe1aeb005615c
5
5
  SHA512:
6
- metadata.gz: fbe667709b38554beacb190476ca00defd9df615133b4d56a9f11fe0d8531790659a2dedca2fdb3c487a389b53a83efbf94719cd5f84ff10d485a4db9e9f9f08
7
- data.tar.gz: 4635bd76a5a35089ec0448c3fc3376fc0229772500d12593200c665034ea5c813564fc790127e723beaa8170a6eb3aac0a7609abcd99bde22e09e51f672b56f4
6
+ metadata.gz: b678d4698a7511535d6b4c492d56ce832ae699a57e7b6a992d5b2371bb4b3739d131e3cea60e2b6b9930c7fb556847c7acaff56cc09b50d8d6e4b0c23a161e4b
7
+ data.tar.gz: 83dbe0859ce53c144648d0088b57a8151bb9325d7b9b27fec6299895a90c72ba5e0906dfcb301d6104398225a42c06f891aefd74c654fe2677ac4413e46c6cd1
@@ -4,6 +4,7 @@ module Heavylog
4
4
  config.heavylog = Heavylog::OrderedOptions.new
5
5
  config.heavylog.enabled = false
6
6
  config.heavylog.path = 'log/heavylog.log'
7
+ config.heavylog.message_limit = 1024 * 1024 * 50 # 50MB
7
8
 
8
9
  initializer "heavylog.insert_middleware" do |app|
9
10
  app.config.middleware.insert_before Rails::Rack::Logger, Heavylog::Middleware
@@ -1,3 +1,3 @@
1
1
  module Heavylog
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/heavylog.rb CHANGED
@@ -10,6 +10,8 @@ require 'heavylog/request_logger'
10
10
  module Heavylog
11
11
  module_function
12
12
 
13
+ TRUNCATION = '[TRUNCATED]'.freeze
14
+
13
15
  mattr_accessor :logger, :application, :formatter, :log_level
14
16
 
15
17
  def setup(app)
@@ -59,6 +61,7 @@ module Heavylog
59
61
 
60
62
  def log(severity, message = nil, progname = nil, &block)
61
63
  return if !config.enabled
64
+ return if !!RequestStore.store[:heavylog_truncated]
62
65
 
63
66
  uuid = RequestStore.store[:heavylog_request_id]
64
67
  return if !uuid
@@ -72,7 +75,14 @@ module Heavylog
72
75
  end
73
76
 
74
77
  RequestStore.store[:heavylog_buffer] ||= StringIO.new
75
- RequestStore.store[:heavylog_buffer].puts(message)
78
+
79
+ if RequestStore.store[:heavylog_buffer].length + message.bytesize > config.message_limit
80
+ RequestStore.store[:heavylog_buffer].truncate(0)
81
+ RequestStore.store[:heavylog_buffer].puts(TRUNCATION)
82
+ RequestStore.store[:heavylog_truncated] = true
83
+ else
84
+ RequestStore.store[:heavylog_buffer].puts(message)
85
+ end
76
86
  end
77
87
 
78
88
  def finish
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heavylog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kristjan Rang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-08 00:00:00.000000000 Z
11
+ date: 2018-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements: []
157
157
  rubyforge_project:
158
- rubygems_version: 2.7.3
158
+ rubygems_version: 2.7.6
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Format all Rails logging per request