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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: baa611c5defcf24154ffcb829af28252a93b7eda
4
- data.tar.gz: 08ecbf18b034d297b1d184c362bb6789b7655df6
3
+ metadata.gz: d423101774812ddd5dc6e343c16c4ff352fbdb5f
4
+ data.tar.gz: bc934e49ab2cde1d6c9028c11035d3163dd72589
5
5
  SHA512:
6
- metadata.gz: aec84b46f8264c4ea92413c5c85c3277751691148048bb98a8f13554473301429b783c04c1fe5037e13985f3489042fe682dde07064fb59f5601c6cce8a828b6
7
- data.tar.gz: 716a20f56eec22a0447d2a7752b21e5a5de98d887991325ff0a7dad3253ef4cfba89d13ca36f48f9f09153d06d8f37635c0eb18d136739d117fdc745f876cd56
6
+ metadata.gz: faa228a9f6dc5c219d688e4ff40441098d5f57f2f3aa0d3c8eb772e102dea0c5e3c8cfd1305cf859e254fd852b13317261a7966dbca7ef79bd773246f8a522db
7
+ data.tar.gz: 2b0f5a918bdea8286ef1f619369b9c00af0f1eedce91d52c319638a0ab397b013a9944a7aaed26f811b399ded6adce2a46b19a9c53a5f5bf74bf444eb207bc24
data/.travis.yml CHANGED
@@ -23,7 +23,8 @@ env:
23
23
  before_script:
24
24
  - echo $BUNDLE_GEMFILE
25
25
  - bundle install
26
- script: bundle exec rspec --format documentation
26
+ script:
27
+ - bundle exec rspec --format documentation
27
28
  matrix:
28
29
  fast_finish: true
29
30
  exclude:
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
@@ -23,7 +23,7 @@ module Timber
23
23
  end
24
24
 
25
25
  def silence_template_renders!
26
- append!("config.integrations.action_view.silence = true")
26
+ append!("config.integrations.action_view.silence = Rails.env.production?")
27
27
  end
28
28
 
29
29
  private
@@ -33,8 +33,6 @@ module Timber
33
33
  File.open(path, "w") do |f|
34
34
  f.write(contents)
35
35
  end
36
-
37
- api.event(:file_written, path: path)
38
36
  end
39
37
 
40
38
  def verify(path, io)
@@ -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 logrageify?
24
- config_file.logrageify!
25
- elsif silence_template_renders?
26
- config_file.silence_template_renders!
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
- case io.ask_yes_no("Enter your choice:", event_prompt: "Send dev logs to Timber?")
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::Logger already installed #{environment_file_path}")
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 # <---- set to false to stop sending dev logs to Timber.io
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::Logger already installed #{environment_file_path}")
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::Logger already installed #{environment_file_path}")
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
- case io.ask_yes_no("Are the above details correct?", event_prompt: "App details correct?")
31
- when :yes
32
- install_platform(app)
33
- run_sub_installer(app)
34
- send_test_messages
35
- confirm_log_delivery
36
- wrap_up(app)
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! To start using Timber:"
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 - Sane logging for Ruby developers.
101
+ 🌲 Timber.io Ruby Installer - Great Ruby Logging Made *Easy*
105
102
 
106
103
  ^ ^ ^ ^ ___I_ ^ ^ ^ ^ ^ ^ ^
107
104
  /|\\/|\\/|\\ /|\\ /\\-_--\\ /|\\/|\\ /|\\/|\\/|\\ /|\\/|\\
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "2.1.6"
2
+ VERSION = "2.1.7"
3
3
  end
@@ -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(:logrageify?).exactly(1).times.and_return(true)
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 # <---- set to false to stop sending dev logs to Timber.io
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.6
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-23 00:00:00.000000000 Z
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