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 +4 -4
- data/lib/heavylog/railtie.rb +1 -0
- data/lib/heavylog/version.rb +1 -1
- data/lib/heavylog.rb +11 -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: c4f2f4bdbb5f72c23e7308fc62168ba9c8e8d132146984889c41235fe5cac73a
|
4
|
+
data.tar.gz: 759a9ed8c5180282772282f7a19a5e25b697184cf892236fe30fe1aeb005615c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b678d4698a7511535d6b4c492d56ce832ae699a57e7b6a992d5b2371bb4b3739d131e3cea60e2b6b9930c7fb556847c7acaff56cc09b50d8d6e4b0c23a161e4b
|
7
|
+
data.tar.gz: 83dbe0859ce53c144648d0088b57a8151bb9325d7b9b27fec6299895a90c72ba5e0906dfcb301d6104398225a42c06f891aefd74c654fe2677ac4413e46c6cd1
|
data/lib/heavylog/railtie.rb
CHANGED
@@ -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
|
data/lib/heavylog/version.rb
CHANGED
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
|
-
|
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.
|
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-
|
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.
|
158
|
+
rubygems_version: 2.7.6
|
159
159
|
signing_key:
|
160
160
|
specification_version: 4
|
161
161
|
summary: Format all Rails logging per request
|