timber 2.4.0 → 2.5.0
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/CHANGELOG.md +21 -1
- data/README.md +1 -1
- data/lib/timber/cli/api.rb +3 -3
- data/lib/timber/cli/config_file.rb +4 -1
- data/lib/timber/cli/installers/rails.rb +15 -7
- data/lib/timber/cli/installers/root.rb +0 -8
- data/lib/timber/cli/io/messages.rb +0 -10
- data/lib/timber/events/http_request.rb +6 -4
- data/lib/timber/events/http_response.rb +19 -5
- data/lib/timber/integrations/rack/http_events.rb +8 -1
- data/lib/timber/overrides.rb +1 -0
- data/lib/timber/overrides/active_support_3_tagged_logging.rb +11 -3
- data/lib/timber/overrides/active_support_buffered_logger.rb +22 -0
- data/lib/timber/version.rb +1 -1
- data/spec/rails/tagged_logging_spec.rb +14 -0
- data/spec/support/rails.rb +1 -0
- data/spec/timber/cli/config_file_spec.rb +1 -1
- data/spec/timber/cli/installers/config_file_spec.rb +1 -1
- data/spec/timber/cli/installers/rails_spec.rb +15 -7
- data/spec/timber/cli/installers/root_spec.rb +0 -1
- data/spec/timber/integrations/rack/http_events_spec.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb90a5dcdaf6811bfa761744ebcb1df521aca6e3
|
4
|
+
data.tar.gz: 92784b6843f7acc7649aa1ff62434c907d7e71ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de2fba5e95d5e0ddf11bb753cd7be7986f9ed836c63793583d076280f30312113f40b48f32718654b57394515afea77867d692a625e7cab2a8f6ee19e88c89e8
|
7
|
+
data.tar.gz: e62cd797becc6aa3bbc8ae37b6b44a42ef5d1d27bc8b0ea7c9510078511b04b5e8cebd12c6a8f6c3bbcd4fc2eba4bf553b4ef4df3923558cae91af2fa71fa7a0
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [2.5.0] - 2017-10-27
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Remove social promotions during the installation process
|
15
|
+
- The default log device for development has been changed to a file (log/development.log)
|
16
|
+
to follow Rails defaults.
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Adds an override for ActiveSupport::Buffered logger. This is a legacy class that was dropped
|
21
|
+
in Rails >= 4. It lacked #formatter accessor methods, which was a bug that was never resolved.
|
22
|
+
|
23
|
+
### Added
|
24
|
+
|
25
|
+
- Capture `content_length` for both HTTP request and HTTP response events. This field is
|
26
|
+
available in the log's metadata. The response event now includes the content length in the
|
27
|
+
actual log message. The request message remains unchanged.
|
28
|
+
|
10
29
|
## [2.4.0] - 2017-10-23
|
11
30
|
|
12
31
|
### Added
|
@@ -78,7 +97,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
78
97
|
instead of applying back pressure.
|
79
98
|
|
80
99
|
|
81
|
-
[Unreleased]: https://github.com/timberio/timber-ruby/compare/v2.
|
100
|
+
[Unreleased]: https://github.com/timberio/timber-ruby/compare/v2.5.0...HEAD
|
101
|
+
[2.5.0]: https://github.com/timberio/timber-ruby/compare/v2.4.0...v2.5.0
|
82
102
|
[2.4.0]: https://github.com/timberio/timber-ruby/compare/v2.3.4...v2.4.0
|
83
103
|
[2.3.4]: https://github.com/timberio/timber-ruby/compare/v2.3.3...v2.3.4
|
84
104
|
[2.3.3]: https://github.com/timberio/timber-ruby/compare/v2.3.2...v2.3.3
|
data/README.md
CHANGED
@@ -280,7 +280,7 @@ Logging features designed to help developers get more done:
|
|
280
280
|
|
281
281
|
1. [**Powerful searching.** - Find what you need faster.](https://timber.io/docs/app/console/searching)
|
282
282
|
2. [**Live tail users.** - Easily solve customer issues.](https://timber.io/docs/app/console/tail-a-user)
|
283
|
-
3. [**
|
283
|
+
3. [**View logs per HTTP request.** - See the full story without the noise.](https://timber.io/docs/app/console/trace-http-requests)
|
284
284
|
4. [**Inspect HTTP request parameters.** - Quickly reproduce issues.](https://timber.io/docs/app/console/inspect-http-requests)
|
285
285
|
5. [**Threshold based alerting.** - Know when things break.](https://timber.io/docs/app/alerts)
|
286
286
|
6. ...and more! Checkout our [the Timber application docs](https://timber.io/docs/app)
|
data/lib/timber/cli/api.rb
CHANGED
@@ -159,9 +159,9 @@ module Timber
|
|
159
159
|
else
|
160
160
|
res
|
161
161
|
end
|
162
|
-
rescue OpenSSL::SSL::SSLError =>
|
163
|
-
if http.ssl_version != :
|
164
|
-
http.ssl_version = :
|
162
|
+
rescue OpenSSL::SSL::SSLError => _e
|
163
|
+
if http.ssl_version != :TLSv1_2
|
164
|
+
http.ssl_version = :TLSv1_2
|
165
165
|
issue!(req)
|
166
166
|
end
|
167
167
|
end
|
@@ -58,7 +58,10 @@ module Timber
|
|
58
58
|
config = Timber::Config.instance
|
59
59
|
|
60
60
|
#{insert_hook}
|
61
|
-
# For
|
61
|
+
# For common configuration options see:
|
62
|
+
# https://timber.io/docs/languages/ruby/configuration
|
63
|
+
#
|
64
|
+
# For a full list of configuration options see:
|
62
65
|
# http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Config
|
63
66
|
|
64
67
|
CONTENT
|
@@ -72,12 +72,17 @@ module Timber
|
|
72
72
|
|
73
73
|
logger_code = <<-CODE
|
74
74
|
# Install the Timber.io logger
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
75
|
+
# ----------------------------
|
76
|
+
# Remove the `http_device` to stop sending development logs to Timber.
|
77
|
+
# Be sure to keep the `file_device` or replace it with `STDOUT`.
|
78
|
+
http_device = Timber::LogDevices::HTTP.new(#{api_key_code})
|
79
|
+
file_device = File.open("\#{Rails.root}/log/development.log", "a")
|
80
|
+
file_device.binmode
|
81
|
+
log_devices = [http_device, file_device]
|
82
|
+
|
83
|
+
# Do not modify below this line. It's important to keep the `Timber::Logger`
|
84
|
+
# because it provides an API for logging structured data and capturing context.
|
85
|
+
logger = Timber::Logger.new(*log_devices)
|
81
86
|
logger.level = config.log_level
|
82
87
|
config.logger = #{config_set_logger_code}
|
83
88
|
CODE
|
@@ -140,7 +145,10 @@ CODE
|
|
140
145
|
|
141
146
|
def install_nil(environment_file_path)
|
142
147
|
logger_code = <<-CODE
|
143
|
-
# Install the Timber.io logger
|
148
|
+
# Install the Timber.io logger
|
149
|
+
# ----------------------------
|
150
|
+
# `nil` is passed to disable logging. It's important to keep the `Timber::Logger`
|
151
|
+
# because it provides an API for logging structured data and capturing context.
|
144
152
|
logger = Timber::Logger.new(nil)
|
145
153
|
logger.level = config.log_level
|
146
154
|
config.logger = #{config_set_logger_code}
|
@@ -32,7 +32,6 @@ module Timber
|
|
32
32
|
confirm_log_delivery
|
33
33
|
api.event(:success)
|
34
34
|
collect_feedback
|
35
|
-
free_data
|
36
35
|
wrap_up(app)
|
37
36
|
end
|
38
37
|
|
@@ -111,13 +110,6 @@ module Timber
|
|
111
110
|
io.puts "Thank you! We take feedback seriously and will work to improve this."
|
112
111
|
end
|
113
112
|
end
|
114
|
-
|
115
|
-
def free_data
|
116
|
-
io.puts ""
|
117
|
-
io.puts IO::Messages.separator
|
118
|
-
io.puts ""
|
119
|
-
io.puts IO::Messages.free_data
|
120
|
-
end
|
121
113
|
end
|
122
114
|
end
|
123
115
|
end
|
@@ -86,16 +86,6 @@ MESSAGE
|
|
86
86
|
message
|
87
87
|
end
|
88
88
|
|
89
|
-
def free_data
|
90
|
-
message = <<-MESSAGE
|
91
|
-
Get free data:
|
92
|
-
|
93
|
-
* Get ✨ 250mb✨ for starring our repo: #{IO::ANSI.colorize(REPO_URL, :blue)}
|
94
|
-
* Get ✨ 250mb✨ for tweeting your experience to #{IO::ANSI.colorize(TWITTER_HANDLE, :blue)}
|
95
|
-
MESSAGE
|
96
|
-
message.rstrip
|
97
|
-
end
|
98
|
-
|
99
89
|
def header
|
100
90
|
message = <<-MESSAGE
|
101
91
|
🌲 Timber.io Ruby Installer - Great Ruby Logging Made *Easy*
|
@@ -9,11 +9,12 @@ module Timber
|
|
9
9
|
# @note This event should be installed automatically through integrations,
|
10
10
|
# such as the {Integrations::ActionController::LogSubscriber} integration.
|
11
11
|
class HTTPRequest < Timber::Event
|
12
|
-
attr_reader :body, :headers, :host, :method, :path, :port, :query_string,
|
13
|
-
:scheme, :service_name
|
12
|
+
attr_reader :body, :content_length, :headers, :host, :method, :path, :port, :query_string,
|
13
|
+
:request_id, :scheme, :service_name
|
14
14
|
|
15
15
|
def initialize(attributes)
|
16
16
|
@body = attributes[:body] && Util::HTTPEvent.normalize_body(attributes[:body])
|
17
|
+
@content_length = attributes[:content_length]
|
17
18
|
@headers = Util::HTTPEvent.normalize_headers(attributes[:headers])
|
18
19
|
@host = attributes[:host]
|
19
20
|
@method = Util::HTTPEvent.normalize_method(attributes[:method]) || raise(ArgumentError.new(":method is required"))
|
@@ -25,8 +26,9 @@ module Timber
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def to_hash
|
28
|
-
{body: body, headers: headers, host: host, method: method,
|
29
|
-
query_string: query_string, request_id: request_id,
|
29
|
+
{body: body, content_length: content_length, headers: headers, host: host, method: method,
|
30
|
+
path: path, port: port, query_string: query_string, request_id: request_id,
|
31
|
+
scheme: scheme}
|
30
32
|
end
|
31
33
|
alias to_h to_hash
|
32
34
|
|
@@ -9,10 +9,11 @@ module Timber
|
|
9
9
|
# @note This event should be installed automatically through integrations,
|
10
10
|
# such as the {Integrations::ActionController::LogSubscriber} integration.
|
11
11
|
class HTTPResponse < Timber::Event
|
12
|
-
attr_reader :body, :headers, :http_context, :request_id, :service_name, :status, :time_ms
|
12
|
+
attr_reader :body, :content_length, :headers, :http_context, :request_id, :service_name, :status, :time_ms
|
13
13
|
|
14
14
|
def initialize(attributes)
|
15
15
|
@body = attributes[:body] && Util::HTTPEvent.normalize_body(attributes[:body])
|
16
|
+
@content_length = attributes[:content_length]
|
16
17
|
@headers = Util::HTTPEvent.normalize_headers(attributes[:headers])
|
17
18
|
@http_context = attributes[:http_context]
|
18
19
|
@request_id = attributes[:request_id]
|
@@ -22,7 +23,8 @@ module Timber
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def to_hash
|
25
|
-
{body: body, headers: headers, request_id: request_id,
|
26
|
+
{body: body, content_length: content_length, headers: headers, request_id: request_id,
|
27
|
+
status: status, time_ms: time_ms}
|
26
28
|
end
|
27
29
|
alias to_h to_hash
|
28
30
|
|
@@ -34,10 +36,22 @@ module Timber
|
|
34
36
|
# Returns the human readable log message for this event.
|
35
37
|
def message
|
36
38
|
if http_context
|
37
|
-
"#{http_context[:method]} #{http_context[:path]}
|
38
|
-
"
|
39
|
+
message = "#{http_context[:method]} #{http_context[:path]} completed with " \
|
40
|
+
"#{status} #{status_description} "
|
41
|
+
|
42
|
+
if content_length
|
43
|
+
message += ", #{content_length} bytes, "
|
44
|
+
end
|
45
|
+
|
46
|
+
message + "in #{time_ms}ms"
|
39
47
|
else
|
40
|
-
"Completed #{status} #{status_description}
|
48
|
+
message = "Completed #{status} #{status_description} "
|
49
|
+
|
50
|
+
if content_length
|
51
|
+
message += ", #{content_length} bytes, "
|
52
|
+
end
|
53
|
+
|
54
|
+
message + "in #{time_ms}ms"
|
41
55
|
end
|
42
56
|
end
|
43
57
|
|
@@ -106,6 +106,8 @@ module Timber
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
+
CONTENT_LENGTH_KEY = 'Content-Length'.freeze
|
110
|
+
|
109
111
|
def call(env)
|
110
112
|
request = Util::Request.new(env)
|
111
113
|
|
@@ -126,9 +128,11 @@ module Timber
|
|
126
128
|
Config.instance.logger.info do
|
127
129
|
http_context_key = Contexts::HTTP.keyspace
|
128
130
|
http_context = CurrentContext.fetch(http_context_key)
|
131
|
+
content_length = headers[CONTENT_LENGTH_KEY]
|
129
132
|
time_ms = (Time.now - start) * 1000.0
|
130
133
|
|
131
134
|
Events::HTTPResponse.new(
|
135
|
+
content_length: content_length,
|
132
136
|
headers: headers,
|
133
137
|
http_context: http_context,
|
134
138
|
request_id: request.request_id,
|
@@ -147,6 +151,7 @@ module Timber
|
|
147
151
|
|
148
152
|
Events::HTTPRequest.new(
|
149
153
|
body: event_body,
|
154
|
+
content_length: request.content_length,
|
150
155
|
headers: request.headers,
|
151
156
|
host: request.host,
|
152
157
|
method: request.request_method,
|
@@ -161,11 +166,13 @@ module Timber
|
|
161
166
|
status, headers, body = @app.call(env)
|
162
167
|
|
163
168
|
Config.instance.logger.info do
|
164
|
-
time_ms = (Time.now - start) * 1000.0
|
165
169
|
event_body = capture_response_body? ? body : nil
|
170
|
+
content_length = headers[CONTENT_LENGTH_KEY]
|
171
|
+
time_ms = (Time.now - start) * 1000.0
|
166
172
|
|
167
173
|
Events::HTTPResponse.new(
|
168
174
|
body: event_body,
|
175
|
+
content_length: content_length,
|
169
176
|
headers: headers,
|
170
177
|
request_id: request.request_id,
|
171
178
|
status: status,
|
data/lib/timber/overrides.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# The order is relevant
|
2
2
|
require "timber/overrides/active_support_3_tagged_logging"
|
3
3
|
require "timber/overrides/active_support_tagged_logging"
|
4
|
+
require "timber/overrides/active_support_buffered_logger"
|
4
5
|
require "timber/overrides/lograge"
|
5
6
|
require "timber/overrides/rails_stdout_logging"
|
6
7
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Please note, this patch is merely an upgrade, backporting improved tagged logging code
|
2
|
+
# from newer versions of Rails:
|
3
|
+
# https://github.com/rails/rails/blob/5-1-stable/activesupport/lib/active_support/tagged_logging.rb
|
4
|
+
# The behavior of tagged logging will not change in any way.
|
5
|
+
#
|
1
6
|
# This patch is specifically for Rails 3. The legacy approach to wrapping the logger in
|
2
7
|
# ActiveSupport::TaggedLogging is rather poor, hence the reason it was changed entirely
|
3
8
|
# for Rails 4 and 5. The problem is that ActiveSupport::TaggedLogging is a wrapping
|
@@ -79,9 +84,12 @@ begin
|
|
79
84
|
end
|
80
85
|
|
81
86
|
def self.new(logger)
|
82
|
-
|
83
|
-
|
84
|
-
|
87
|
+
if logger.respond_to?(:formatter=) && logger.respond_to?(:formatter)
|
88
|
+
# Ensure we set a default formatter so we aren't extending nil!
|
89
|
+
logger.formatter ||= SimpleFormatter.new
|
90
|
+
logger.formatter.extend Formatter
|
91
|
+
end
|
92
|
+
|
85
93
|
logger.extend(self)
|
86
94
|
end
|
87
95
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This adds a #formatter and #formatter= method to the legacy ActiveSupport::BufferedLogger
|
2
|
+
# class. This bug was never resolved due to it being phased out past Rails >= 4.
|
3
|
+
|
4
|
+
begin
|
5
|
+
require "active_support/buffered_logger"
|
6
|
+
|
7
|
+
class ActiveSupport::BufferedLogger
|
8
|
+
def formatter
|
9
|
+
if @log.respond_to?(:formatter)
|
10
|
+
@log.formatter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def formatter=(value)
|
15
|
+
if @log.respond_to?(:formatter=)
|
16
|
+
@log.formatter = value
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
rescue Exception
|
22
|
+
end
|
data/lib/timber/version.rb
CHANGED
@@ -3,6 +3,20 @@ require "spec_helper"
|
|
3
3
|
# ActiveSupport::TaggedLogging is not defined in <= 3.1
|
4
4
|
if defined?(::ActiveSupport::TaggedLogging)
|
5
5
|
describe ActiveSupport::TaggedLogging, :rails_23 => true do
|
6
|
+
describe "#new" do
|
7
|
+
let(:io) { StringIO.new }
|
8
|
+
|
9
|
+
it "should instantiate for Timber::Logger object" do
|
10
|
+
ActiveSupport::TaggedLogging.new(Timber::Logger.new(io))
|
11
|
+
end
|
12
|
+
|
13
|
+
if defined?(ActiveSupport::BufferedLogger)
|
14
|
+
it "should instantiate for a ActiveSupport::BufferedLogger object" do
|
15
|
+
ActiveSupport::TaggedLogging.new(ActiveSupport::BufferedLogger.new(io))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
6
20
|
describe "#info" do
|
7
21
|
let(:time) { Time.utc(2016, 9, 1, 12, 0, 0) }
|
8
22
|
let(:io) { StringIO.new }
|
data/spec/support/rails.rb
CHANGED
@@ -30,6 +30,7 @@ if defined?(::Rails)
|
|
30
30
|
application = ::Rails.application
|
31
31
|
env = application.respond_to?(:env_config) ? application.env_config.clone : application.env_defaults.clone
|
32
32
|
env["rack.request.cookie_hash"] = {}.with_indifferent_access
|
33
|
+
env["CONTENT_LENGTH"] = 100
|
33
34
|
env["REMOTE_ADDR"] = "123.456.789.10"
|
34
35
|
env["HTTP_X_REQUEST_ID"] = "unique-request-id-1234"
|
35
36
|
env["action_dispatch.request_id"] = env["HTTP_X_REQUEST_ID"]
|
@@ -5,7 +5,7 @@ describe Timber::CLI::ConfigFile, :rails_23 => true do
|
|
5
5
|
let(:file_helper) { @file_helper = Timber::CLI::FileHelper.new(api) }
|
6
6
|
let(:path) { "config/initializers/timber.rb" }
|
7
7
|
let(:config_file) { described_class.new(path, file_helper) }
|
8
|
-
let(:initial_contents) { "# Timber.io Ruby Configuration - Simple Structured Logging\n#\n# ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n# /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ / \\_-__\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ |[]| [] | /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# -------------------------------------------------------------------\n# Website: https://timber.io\n# Documentation: https://timber.io/docs\n# Support: support@timber.io\n# -------------------------------------------------------------------\n\nconfig = Timber::Config.instance\n\n# Add additional configuration here.\n# For a full list of configuration options
|
8
|
+
let(:initial_contents) { "# Timber.io Ruby Configuration - Simple Structured Logging\n#\n# ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n# /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ / \\_-__\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ |[]| [] | /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# -------------------------------------------------------------------\n# Website: https://timber.io\n# Documentation: https://timber.io/docs\n# Support: support@timber.io\n# -------------------------------------------------------------------\n\nconfig = Timber::Config.instance\n\n# Add additional configuration here.\n# For common configuration options see:\n# https://timber.io/docs/languages/ruby/configuration\n#\n# For a full list of configuration options see:\n# http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Config\n\n" }
|
9
9
|
let(:contents_hook) { "# Add additional configuration here." }
|
10
10
|
|
11
11
|
describe ".create!" do
|
@@ -17,7 +17,7 @@ describe Timber::CLI::Installers::ConfigFile, :rails_23 => true do
|
|
17
17
|
let(:output) { StringIO.new }
|
18
18
|
let(:io) { Timber::CLI::IO.new(io_out: output, io_in: input) }
|
19
19
|
let(:installer) { described_class.new(io, api) }
|
20
|
-
let(:initial_config_contents) { "# Timber.io Ruby Configuration - Simple Structured Logging\n#\n# ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n# /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ / \\_-__\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ |[]| [] | /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# -------------------------------------------------------------------\n# Website: https://timber.io\n# Documentation: https://timber.io/docs\n# Support: support@timber.io\n# -------------------------------------------------------------------\n\nconfig = Timber::Config.instance\n\n# Add additional configuration here.\n# For a full list of configuration options
|
20
|
+
let(:initial_config_contents) { "# Timber.io Ruby Configuration - Simple Structured Logging\n#\n# ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^\n# /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ / \\_-__\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# /|\\/|\\/|\\ /|\\ |[]| [] | /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\\n# -------------------------------------------------------------------\n# Website: https://timber.io\n# Documentation: https://timber.io/docs\n# Support: support@timber.io\n# -------------------------------------------------------------------\n\nconfig = Timber::Config.instance\n\n# Add additional configuration here.\n# For common configuration options see:\n# https://timber.io/docs/languages/ruby/configuration\n#\n# For a full list of configuration options see:\n# http://www.rubydoc.info/github/timberio/timber-ruby/Timber/Config\n\n" }
|
21
21
|
|
22
22
|
describe ".run" do
|
23
23
|
it "should run properly" do
|
@@ -95,12 +95,17 @@ describe Timber::CLI::Installers::Rails, :rails_23 => true do
|
|
95
95
|
|
96
96
|
expected_code = <<-CODE
|
97
97
|
# Install the Timber.io logger
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
# ----------------------------
|
99
|
+
# Remove the `http_device` to stop sending development logs to Timber.
|
100
|
+
# Be sure to keep the `file_device` or replace it with `STDOUT`.
|
101
|
+
http_device = Timber::LogDevices::HTTP.new('#{app.api_key}')
|
102
|
+
file_device = File.open("\#{Rails.root}/log/development.log", "a")
|
103
|
+
file_device.binmode
|
104
|
+
log_devices = [http_device, file_device]
|
105
|
+
|
106
|
+
# Do not modify below this line. It's important to keep the `Timber::Logger`
|
107
|
+
# because it provides an API for logging structured data and capturing context.
|
108
|
+
logger = Timber::Logger.new(*log_devices)
|
104
109
|
logger.level = config.log_level
|
105
110
|
config.logger = #{logger_code}
|
106
111
|
CODE
|
@@ -314,7 +319,10 @@ CODE
|
|
314
319
|
env_file_path = "config/environments/development.rb"
|
315
320
|
|
316
321
|
expected_code = <<-CODE
|
317
|
-
# Install the Timber.io logger
|
322
|
+
# Install the Timber.io logger
|
323
|
+
# ----------------------------
|
324
|
+
# `nil` is passed to disable logging. It's important to keep the `Timber::Logger`
|
325
|
+
# because it provides an API for logging structured data and capturing context.
|
318
326
|
logger = Timber::Logger.new(nil)
|
319
327
|
logger.level = config.log_level
|
320
328
|
config.logger = #{logger_code}
|
@@ -30,7 +30,6 @@ describe Timber::CLI::Installers::Root, :rails_23 => true do
|
|
30
30
|
expect(installer).to receive(:wrap_up).with(app).exactly(1).times
|
31
31
|
expect(api).to receive(:event).with(:success).exactly(1).times
|
32
32
|
expect(installer).to receive(:collect_feedback).exactly(1).times
|
33
|
-
expect(installer).to receive(:free_data).exactly(1).times
|
34
33
|
|
35
34
|
installer.run(app)
|
36
35
|
end
|
@@ -88,7 +88,7 @@ if defined?(::Rack)
|
|
88
88
|
expect(lines.length).to eq(2)
|
89
89
|
|
90
90
|
expect(lines[0]).to start_with("Processing by RackHttpController#index as HTML @metadata ")
|
91
|
-
expect(lines[1]).to start_with("GET /rack_http
|
91
|
+
expect(lines[1]).to start_with("GET /rack_http completed with 200 OK in 0.0ms @metadata ")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timber Technologies, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -235,6 +235,7 @@ files:
|
|
235
235
|
- lib/timber/logger.rb
|
236
236
|
- lib/timber/overrides.rb
|
237
237
|
- lib/timber/overrides/active_support_3_tagged_logging.rb
|
238
|
+
- lib/timber/overrides/active_support_buffered_logger.rb
|
238
239
|
- lib/timber/overrides/active_support_tagged_logging.rb
|
239
240
|
- lib/timber/overrides/lograge.rb
|
240
241
|
- lib/timber/overrides/rails_stdout_logging.rb
|