timber 2.1.6 → 2.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +1 -0
- data/lib/timber/cli/config_file.rb +1 -1
- data/lib/timber/cli/file_helper.rb +0 -2
- data/lib/timber/cli/installers/config_file.rb +6 -55
- data/lib/timber/cli/installers/rails.rb +13 -5
- data/lib/timber/cli/installers/root.rb +10 -91
- data/lib/timber/cli/io.rb +0 -9
- data/lib/timber/cli/io/messages.rb +2 -5
- data/lib/timber/version.rb +1 -1
- data/spec/timber/cli/installers/config_file_spec.rb +1 -15
- data/spec/timber/cli/installers/rails_spec.rb +3 -1
- data/spec/timber/cli/installers/root_spec.rb +0 -26
- data/timber.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d423101774812ddd5dc6e343c16c4ff352fbdb5f
|
4
|
+
data.tar.gz: bc934e49ab2cde1d6c9028c11035d3163dd72589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faa228a9f6dc5c219d688e4ff40441098d5f57f2f3aa0d3c8eb772e102dea0c5e3c8cfd1305cf859e254fd852b13317261a7966dbca7ef79bd773246f8a522db
|
7
|
+
data.tar.gz: 2b0f5a918bdea8286ef1f619369b9c00af0f1eedce91d52c319638a0ab397b013a9944a7aaed26f811b399ded6adce2a46b19a9c53a5f5bf74bf444eb207bc24
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![ISC License](https://img.shields.io/badge/license-ISC-ff69b4.svg)](LICENSE.md)
|
4
4
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/timberio/timber-ruby)
|
5
5
|
[![Build Status](https://travis-ci.org/timberio/timber-ruby.svg?branch=master)](https://travis-ci.org/timberio/timber-ruby)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/timberio/timber-ruby/badges/gpa.svg)](https://codeclimate.com/github/timberio/timber-ruby)
|
6
7
|
|
7
8
|
[Timber](https://timber.io) is a cloud-based logging system that integrates directly with your
|
8
9
|
Ruby app to capture context and metadata without parsing. This produces rich, clean, readable logs
|
@@ -15,48 +15,23 @@ module Timber
|
|
15
15
|
config_file = Timber::CLI::ConfigFile.new(path, file_helper)
|
16
16
|
|
17
17
|
if config_file.exists?
|
18
|
-
io.puts ""
|
19
18
|
io.task_complete("#{config_file.path} already created")
|
20
19
|
return true
|
21
20
|
end
|
22
21
|
|
23
|
-
if
|
24
|
-
config_file.
|
25
|
-
|
26
|
-
|
22
|
+
if lograge?
|
23
|
+
task_message = "Enabling logrageify in #{config_file.path}"
|
24
|
+
io.task(task_message) { config_file.logrageify! }
|
25
|
+
elsif action_view?
|
26
|
+
task_message = "Silencing template renders in #{config_file.path}"
|
27
|
+
io.task(task_message) { config_file.silence_template_renders! }
|
27
28
|
end
|
28
29
|
|
29
|
-
io.puts ""
|
30
30
|
task_message = "Creating #{config_file.path}"
|
31
31
|
io.task(task_message) { config_file.create! }
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
35
|
-
def logrageify?
|
36
|
-
if lograge?
|
37
|
-
io.puts ""
|
38
|
-
io.puts IO::Messages.separator
|
39
|
-
io.puts ""
|
40
|
-
io.puts "We noticed you have lograge installed. Would you like to configure "
|
41
|
-
io.puts "Timber to function similarly?"
|
42
|
-
io.puts "(This silences template renders, sql queries, and controller calls."
|
43
|
-
io.puts "You can always do this later in config/initialzers/timber.rb)"
|
44
|
-
io.puts ""
|
45
|
-
io.puts "y) Yes, configure Timber like lograge", :blue
|
46
|
-
io.puts "n) No, use the Rails logging defaults", :blue
|
47
|
-
io.puts ""
|
48
|
-
|
49
|
-
case io.ask_yes_no("Enter your choice:", event_prompt: "Logrageify?")
|
50
|
-
when :yes
|
51
|
-
true
|
52
|
-
when :no
|
53
|
-
false
|
54
|
-
end
|
55
|
-
else
|
56
|
-
false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
35
|
def lograge?
|
61
36
|
require "lograge"
|
62
37
|
true
|
@@ -64,30 +39,6 @@ module Timber
|
|
64
39
|
false
|
65
40
|
end
|
66
41
|
|
67
|
-
def silence_template_renders?
|
68
|
-
if action_view?
|
69
|
-
io.puts ""
|
70
|
-
io.puts IO::Messages.separator
|
71
|
-
io.puts ""
|
72
|
-
io.puts "Would you like to silence template render logs?"
|
73
|
-
io.puts "(We've founds this to be of low value in production environments."
|
74
|
-
io.puts "You can always adjust this later in config/initialzers/timber.rb)"
|
75
|
-
io.puts ""
|
76
|
-
io.puts "y) Yes, silence template renders", :blue
|
77
|
-
io.puts "n) No, use the Rails logging defaults", :blue
|
78
|
-
io.puts ""
|
79
|
-
|
80
|
-
case io.ask_yes_no("Enter your choice:", event_prompt: "Silence template renders?")
|
81
|
-
when :yes
|
82
|
-
true
|
83
|
-
when :no
|
84
|
-
false
|
85
|
-
end
|
86
|
-
else
|
87
|
-
false
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
42
|
def action_view?
|
92
43
|
require("action_view")
|
93
44
|
true
|
@@ -41,7 +41,13 @@ module Timber
|
|
41
41
|
io.puts "n) No, just print development logs to STDOUT", :blue
|
42
42
|
io.puts ""
|
43
43
|
|
44
|
-
|
44
|
+
input = io.ask_yes_no("Enter your choice:", event_prompt: "Send dev logs to Timber?")
|
45
|
+
|
46
|
+
io.puts ""
|
47
|
+
io.puts IO::Messages.separator
|
48
|
+
io.puts ""
|
49
|
+
|
50
|
+
case input
|
45
51
|
when :yes
|
46
52
|
:send
|
47
53
|
when :no
|
@@ -54,7 +60,7 @@ module Timber
|
|
54
60
|
environment_file_path = get_environment_file_path("development")
|
55
61
|
if environment_file_path
|
56
62
|
if already_installed?(environment_file_path)
|
57
|
-
io.task_complete("Timber
|
63
|
+
io.task_complete("Timber already installed #{environment_file_path}")
|
58
64
|
return :already_installed
|
59
65
|
end
|
60
66
|
|
@@ -66,7 +72,9 @@ module Timber
|
|
66
72
|
|
67
73
|
logger_code = <<-CODE
|
68
74
|
# Install the Timber.io logger
|
69
|
-
send_logs_to_timber = true # <----
|
75
|
+
send_logs_to_timber = true # <---- Set to false to stop sending development logs to Timber.io.
|
76
|
+
# But do not remove the logger code below! The log_device should
|
77
|
+
# be set to STDOUT if you want to disable sending logs.
|
70
78
|
|
71
79
|
log_device = send_logs_to_timber ? Timber::LogDevices::HTTP.new(#{api_key_code}) : STDOUT
|
72
80
|
logger = Timber::Logger.new(log_device)
|
@@ -88,7 +96,7 @@ CODE
|
|
88
96
|
environment_file_path = get_environment_file_path("test")
|
89
97
|
if environment_file_path
|
90
98
|
if already_installed?(environment_file_path)
|
91
|
-
io.task_complete("Timber
|
99
|
+
io.task_complete("Timber already installed #{environment_file_path}")
|
92
100
|
return :already_installed
|
93
101
|
end
|
94
102
|
|
@@ -102,7 +110,7 @@ CODE
|
|
102
110
|
environment_file_path = get_environment_file_path(app.environment) || get_environment_file_path("production")
|
103
111
|
if environment_file_path
|
104
112
|
if already_installed?(environment_file_path)
|
105
|
-
io.task_complete("Timber
|
113
|
+
io.task_complete("Timber already installed #{environment_file_path}")
|
106
114
|
return :already_installed
|
107
115
|
end
|
108
116
|
|
@@ -27,41 +27,16 @@ module Timber
|
|
27
27
|
io.puts IO::Messages.application_details(app)
|
28
28
|
io.puts ""
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
api.event(:success)
|
38
|
-
collect_feedback
|
39
|
-
free_data
|
40
|
-
|
41
|
-
when :no
|
42
|
-
io.puts ""
|
43
|
-
io.puts "Bummer. Head to this URL to update the details:"
|
44
|
-
io.puts ""
|
45
|
-
io.puts " #{IO::Messages.edit_app_url(app)}", :blue
|
46
|
-
io.puts ""
|
47
|
-
io.puts "exiting..."
|
48
|
-
end
|
30
|
+
run_sub_installer(app)
|
31
|
+
send_test_messages
|
32
|
+
confirm_log_delivery
|
33
|
+
api.event(:success)
|
34
|
+
collect_feedback
|
35
|
+
free_data
|
36
|
+
wrap_up(app)
|
49
37
|
end
|
50
38
|
|
51
39
|
private
|
52
|
-
def install_platform(app)
|
53
|
-
if app.heroku?
|
54
|
-
io.puts ""
|
55
|
-
io.puts IO::Messages.separator
|
56
|
-
io.puts ""
|
57
|
-
io.puts IO::Messages.heroku_install(app)
|
58
|
-
io.puts ""
|
59
|
-
io.ask_to_proceed
|
60
|
-
end
|
61
|
-
|
62
|
-
true
|
63
|
-
end
|
64
|
-
|
65
40
|
def run_sub_installer(app)
|
66
41
|
sub_installer = get_sub_installer
|
67
42
|
sub_installer.run(app)
|
@@ -100,67 +75,12 @@ module Timber
|
|
100
75
|
end
|
101
76
|
|
102
77
|
def wrap_up(app)
|
103
|
-
if app.development? || app.test?
|
104
|
-
development_note
|
105
|
-
else
|
106
|
-
assist_with_commit_and_deploy
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def development_note
|
111
78
|
io.puts ""
|
112
79
|
io.puts IO::Messages.separator
|
113
80
|
io.puts ""
|
114
|
-
io.puts "All done!
|
81
|
+
io.puts IO::ANSI.colorize("All done! Commit and deploy 🚀 to see logs in Timber.", :yellow)
|
82
|
+
io.puts IO::ANSI.colorize("You can also test drive Timber by starting your app locally.", :yellow)
|
115
83
|
io.puts ""
|
116
|
-
io.puts IO::ANSI.colorize("1. Run your application locally to see logs show up in Timber", :blue)
|
117
|
-
io.puts IO::ANSI.colorize("2. When you're ready to move to production/staging, create a", :blue)
|
118
|
-
io.puts IO::ANSI.colorize(" production/staging app in Timber and follow the instructions shown.", :blue)
|
119
|
-
io.puts ""
|
120
|
-
io.ask_to_proceed
|
121
|
-
end
|
122
|
-
|
123
|
-
def assist_with_commit_and_deploy
|
124
|
-
io.puts ""
|
125
|
-
io.puts IO::Messages.separator
|
126
|
-
io.puts ""
|
127
|
-
|
128
|
-
if OSHelper.has_git?
|
129
|
-
case io.ask_yes_no("All done! Would you like to commit these changes?", event_prompt: "Run git commands?")
|
130
|
-
when :yes
|
131
|
-
io.puts ""
|
132
|
-
|
133
|
-
task_message = "Committing changes via git"
|
134
|
-
io.task_start(task_message)
|
135
|
-
|
136
|
-
committed = OSHelper.git_commit_changes
|
137
|
-
|
138
|
-
if committed
|
139
|
-
io.task_complete(task_message)
|
140
|
-
else
|
141
|
-
io.task_failed(task_message)
|
142
|
-
|
143
|
-
io.puts ""
|
144
|
-
io.puts "Bummer, it looks like we couldn't access the git command.", :yellow
|
145
|
-
io.puts "No problem though, just run these commands yourself:", :yellow
|
146
|
-
io.puts ""
|
147
|
-
io.puts IO::Messages.git_commands
|
148
|
-
end
|
149
|
-
when :no
|
150
|
-
io.puts ""
|
151
|
-
io.puts "No problem. Here's the commands for reference when you're ready:"
|
152
|
-
io.puts ""
|
153
|
-
io.puts IO::Messages.git_commands
|
154
|
-
end
|
155
|
-
else
|
156
|
-
io.puts ""
|
157
|
-
io.puts "All done! Commit your changes:"
|
158
|
-
io.puts ""
|
159
|
-
io.puts IO::Messages.git_commands
|
160
|
-
end
|
161
|
-
|
162
|
-
io.puts ""
|
163
|
-
io.puts "=> Reminder: remember to deploy 🚀 to see logs in staging/production", :yellow
|
164
84
|
end
|
165
85
|
|
166
86
|
def collect_feedback
|
@@ -168,7 +88,7 @@ module Timber
|
|
168
88
|
io.puts IO::Messages.separator
|
169
89
|
io.puts ""
|
170
90
|
|
171
|
-
rating = io.ask("How would rate this install experience? 1 (bad) - 5 (perfect)", ["1", "2", "3", "4", "5"])
|
91
|
+
rating = io.ask("How would rate this install experience? 1 (bad) - 5 (perfect) or 'skip':", ["1", "2", "3", "4", "5", "skip"])
|
172
92
|
|
173
93
|
case rating
|
174
94
|
when "4", "5"
|
@@ -197,7 +117,6 @@ module Timber
|
|
197
117
|
io.puts IO::Messages.separator
|
198
118
|
io.puts ""
|
199
119
|
io.puts IO::Messages.free_data
|
200
|
-
io.puts ""
|
201
120
|
end
|
202
121
|
end
|
203
122
|
end
|
data/lib/timber/cli/io.rb
CHANGED
@@ -17,18 +17,9 @@ module Timber
|
|
17
17
|
|
18
18
|
def ask(prompt, allowed_inputs, options = {}, iteration = 0)
|
19
19
|
event_prompt = options[:event_prompt] || prompt
|
20
|
-
|
21
|
-
if api
|
22
|
-
api.event(:waiting_for_input, prompt: event_prompt)
|
23
|
-
end
|
24
|
-
|
25
20
|
write prompt + " "
|
26
21
|
input = gets.downcase
|
27
22
|
|
28
|
-
if api
|
29
|
-
api.event(:received_input, prompt: event_prompt, value: input)
|
30
|
-
end
|
31
|
-
|
32
23
|
if allowed_inputs.include?(input)
|
33
24
|
input
|
34
25
|
else
|
@@ -20,10 +20,7 @@ module Timber
|
|
20
20
|
|
21
21
|
def application_details(app)
|
22
22
|
message = <<-MESSAGE
|
23
|
-
Woot! Your API 🔑 is valid:
|
24
|
-
|
25
|
-
Name: #{app.name} (#{app.environment})
|
26
|
-
Platform: #{app.platform_type}
|
23
|
+
Woot! Your API 🔑 is valid: #{app.name} (#{app.environment}) on #{app.platform_type}
|
27
24
|
MESSAGE
|
28
25
|
message.rstrip
|
29
26
|
end
|
@@ -101,7 +98,7 @@ MESSAGE
|
|
101
98
|
|
102
99
|
def header
|
103
100
|
message = <<-MESSAGE
|
104
|
-
🌲 Timber.io Ruby Installer -
|
101
|
+
🌲 Timber.io Ruby Installer - Great Ruby Logging Made *Easy*
|
105
102
|
|
106
103
|
^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^
|
107
104
|
/|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\
|
data/lib/timber/version.rb
CHANGED
@@ -26,25 +26,11 @@ describe Timber::CLI::Installers::ConfigFile, :rails_23 => true do
|
|
26
26
|
|
27
27
|
expect(Timber::CLI::ConfigFile).to receive(:new).with(path, installer.file_helper).and_return(config_file)
|
28
28
|
expect(config_file).to receive(:exists?).exactly(1).times.and_return(false)
|
29
|
-
expect(installer).to receive(:
|
29
|
+
expect(installer).to receive(:lograge?).exactly(1).times.and_return(true)
|
30
30
|
expect(config_file).to receive(:logrageify!).exactly(1).times
|
31
31
|
expect(config_file).to receive(:create!).exactly(1).times
|
32
32
|
|
33
33
|
installer.run(app, path)
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
37
|
-
describe ".logrageify?" do
|
38
|
-
it "should do nothing if Lograge is not detected" do
|
39
|
-
expect(installer.send(:logrageify?)).to eq(false)
|
40
|
-
expect(output.string).to eq("")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should prompt for Lograge configuration and return true for y" do
|
44
|
-
allow(installer).to receive(:lograge?).and_return(true)
|
45
|
-
input.string = "y\n"
|
46
|
-
expect(installer.send(:logrageify?)).to eq(true)
|
47
|
-
expect(output.string).to eq("\n--------------------------------------------------------------------------------\n\nWe noticed you have lograge installed. Would you like to configure \nTimber to function similarly?\n(This silences template renders, sql queries, and controller calls.\nYou can always do this later in config/initialzers/timber.rb)\n\n\e[34my) Yes, configure Timber like lograge\e[0m\n\e[34mn) No, use the Rails logging defaults\e[0m\n\nEnter your choice: (y/n) ")
|
48
|
-
end
|
49
|
-
end
|
50
36
|
end
|
@@ -95,7 +95,9 @@ describe Timber::CLI::Installers::Rails, :rails_23 => true do
|
|
95
95
|
|
96
96
|
expected_code = <<-CODE
|
97
97
|
# Install the Timber.io logger
|
98
|
-
send_logs_to_timber = true # <----
|
98
|
+
send_logs_to_timber = true # <---- Set to false to stop sending development logs to Timber.io.
|
99
|
+
# But do not remove the logger code below! The log_device should
|
100
|
+
# be set to STDOUT if you want to disable sending logs.
|
99
101
|
|
100
102
|
log_device = send_logs_to_timber ? Timber::LogDevices::HTTP.new('#{app.api_key}') : STDOUT
|
101
103
|
logger = Timber::Logger.new(log_device)
|
@@ -24,7 +24,6 @@ describe Timber::CLI::Installers::Root, :rails_23 => true do
|
|
24
24
|
it "should run properly" do
|
25
25
|
input.string = "y\n"
|
26
26
|
|
27
|
-
expect(installer).to receive(:install_platform).with(app).exactly(1).times
|
28
27
|
expect(installer).to receive(:run_sub_installer).with(app).exactly(1).times
|
29
28
|
expect(installer).to receive(:send_test_messages).exactly(1).times
|
30
29
|
expect(installer).to receive(:confirm_log_delivery).exactly(1).times
|
@@ -37,31 +36,6 @@ describe Timber::CLI::Installers::Root, :rails_23 => true do
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
describe ".install_platform" do
|
41
|
-
context "non-heroku" do
|
42
|
-
it "should do nothing" do
|
43
|
-
expect(installer.send(:install_platform, app)).to eq(true)
|
44
|
-
expect(output.string).to eq("")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "heroku" do
|
49
|
-
before(:each) do
|
50
|
-
app.platform_type = "heroku"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should prompt for Heroku install" do
|
54
|
-
input.string = "y\n"
|
55
|
-
|
56
|
-
expect(installer.send(:install_platform, app)).to eq(true)
|
57
|
-
|
58
|
-
copy_to_clipboard_message = Timber::CLI::OSHelper.can_copy_to_clipboard? ? "\n \e[32m(✓ copied to clipboard)\e[0m" : ""
|
59
|
-
expected_output = "\n--------------------------------------------------------------------------------\n\nFirst, let's setup your Heroku drain. Run this command in a separate window:\n\n \e[34mheroku drains:add http://drain.heroku.com\e[0m#{copy_to_clipboard_message}\n\nReady to proceed? (y/n) "
|
60
|
-
expect(output.string).to eq(expected_output)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
39
|
describe ".get_sub_installer" do
|
66
40
|
context "with Rails" do
|
67
41
|
around(:each) do |example|
|
data/timber.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_dependency('msgpack', '~> 1.0')
|
22
22
|
|
23
|
+
s.add_development_dependency('bundler-audit', '>= 0')
|
23
24
|
s.add_development_dependency('rails_stdout_logging', '>= 0')
|
24
25
|
s.add_development_dependency('rake', '>= 0')
|
25
26
|
s.add_development_dependency('rspec', '~> 3.4')
|
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.1.
|
4
|
+
version: 2.1.7
|
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-08-
|
11
|
+
date: 2017-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler-audit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rails_stdout_logging
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|