appsignal 0.7.0.alpha.1 → 0.7.0.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmJjZmJmYThiYzQxNmNkYmY3OTljN2M4MzE3ZmI2NTJiNWExM2QyZA==
4
+ NWZmZGFhYzgyNmJhNzg3Y2Y5MGY3ODdmNzgzOGZhOGY1ZmNjOTY1NA==
5
5
  data.tar.gz: !binary |-
6
- MDdlY2ZlZDlhN2FlN2Q4MDI0Nzg0NDFiODdmMDAxODRlYjI4NjQwMA==
6
+ NGJmNDhlYzA5MDc3Njg2NjczMDdhNGY2MGQ4YzA3NTE5MGRkMzA1YQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjQxMWVmNmI4NThmYzdmMDQ3ZDM1YzNkODAwYTZjNWY2NTJlNzNlNzQzNDRk
10
- NGVkYzQwYWZiOGZmN2ZiN2ExMGJhODRmMmFhNGY3N2M0M2VkNjQxNzRiZmRk
11
- MmJlMjFmYmRjMmU4NWI0YWNmZDk3NjY0MThkYzVjMDE3MjRjMmE=
9
+ M2Y0NDM0OThjYTA5MDkwMDYxYzBmNDg0NjU4NzRkMDZjNTBhNTAwNWU0ZTQ4
10
+ ZTY1ZDFjZGYzMWQ0MjI4ZDEyZWE1OGI0NjY1NmEyYzdmYmM1NWE0Mjc4YmNm
11
+ MmM1NThkMDI0N2MxMDlhYzc2MzVlNTY2NzUyZTQwYzBmMDhkMGY=
12
12
  data.tar.gz: !binary |-
13
- ZDUwNTQ3ZGQyZmUwMmQ1OWE1YzcxNTQ4NzNkYWJjNDUwZmQ0OGEyMDY2ODgy
14
- NDExNWQyMGRlZjc3MTMwMzk1MjFkYTdkMzBkZDNjOTNiNTI2YTEyNzdiMWEz
15
- NWMzYzY2MTkyMjg2YzY0NDVmNjBmOTM3ZDkwZjU3ZGNjYmY1MTQ=
13
+ NTNkOTQ2ZjEyOWRjZDljYTMyNGQ5YTcxZWIzZTJmNjhkNTgzMjIxOTU5Zjgz
14
+ YzI5YTkxMDllZGZmMmQ4YzYzZWJmODViNjc3N2FiZjZhMzQ1NzI1YTljY2Mx
15
+ ZWVmMWZkYmU0MWMwMGM0MDkzMTNlMzcyNjYwMGU1NzI3NzI2NWQ=
@@ -3,6 +3,7 @@
3
3
  * New easier onboarding process
4
4
  * Support for Rack apps, including experimental Sinatra integration
5
5
  * Monitor HTTP queue times
6
+ * Always log to stdout on Heroku
6
7
 
7
8
  # 0.6.7
8
9
  * Send HTTP_X_FORWARDED_FOR env var
@@ -72,8 +72,15 @@ module Appsignal
72
72
  end
73
73
  end
74
74
 
75
- def flush_in_memory_log
76
- Appsignal.logger << @in_memory_log.string
75
+ def start_logger(path)
76
+ if path && File.writable?(path) && !ENV['DYNO']
77
+ @logger = Logger.new(File.join(path, 'appsignal.log'))
78
+ @logger.formatter = Logger::Formatter.new
79
+ else
80
+ @logger = Logger.new($stdout)
81
+ end
82
+ @logger.level = Logger::INFO
83
+ @logger << @in_memory_log.string
77
84
  end
78
85
 
79
86
  def json
@@ -10,16 +10,8 @@ if defined?(::Rails)
10
10
  end
11
11
 
12
12
  config.after_initialize do
13
- # Setup logging
14
- if File.writable?(Rails.root.join('log'))
15
- output = Rails.root.join('log/appsignal.log')
16
- else
17
- output = STDOUT
18
- end
19
- Appsignal.logger = Logger.new(output).tap do |l|
20
- l.level = Logger::INFO
21
- end
22
- Appsignal.flush_in_memory_log
13
+ # Start logger
14
+ Appsignal.start_logger(Rails.root.join('log'))
23
15
 
24
16
  # Load config
25
17
  Appsignal.config = Appsignal::Config.new(Rails.root, Rails.env)
@@ -8,10 +8,7 @@ Appsignal.config = Appsignal::Config.new(
8
8
  app_settings.environment.to_s
9
9
  )
10
10
 
11
- Appsignal.logger = Logger.new(File.join(app_settings.root, 'appsignal.log')).tap do |l|
12
- l.level = Logger::DEBUG
13
- end
14
- Appsignal.flush_in_memory_log
11
+ Appsignal.start_logger(app_settings.root)
15
12
 
16
13
  if Appsignal.active?
17
14
  Appsignal.start
@@ -1,3 +1,3 @@
1
1
  module Appsignal
2
- VERSION = '0.7.0.alpha.1'
2
+ VERSION = '0.7.0.alpha.2'
3
3
  end
@@ -3,18 +3,16 @@ require 'appsignal/cli'
3
3
 
4
4
  describe Appsignal::CLI do
5
5
  let(:out_stream) { StringIO.new }
6
- let(:error_stream) { StringIO.new }
7
6
  let(:cli) { Appsignal::CLI }
8
7
  before do
9
- @original_stdout, @original_stderr = $stdout, $stderr
10
- $stdout, $stderr = out_stream, error_stream
8
+ @original_stdout = $stdout
9
+ $stdout = out_stream
11
10
  ENV['PWD'] = project_fixture_path
12
11
  cli.config = nil
13
12
  cli.options = {:environment => 'production'}
14
13
  end
15
- after :each do
14
+ after do
16
15
  $stdout = @original_stdout
17
- $stderr = @original_stderr
18
16
  end
19
17
 
20
18
  describe "#logger" do
@@ -122,6 +122,51 @@ describe Appsignal do
122
122
  it { should be_a Logger }
123
123
  end
124
124
 
125
+ describe ".start_logger" do
126
+ let(:out_stream) { StringIO.new }
127
+ let(:log_file) { File.join(path, 'appsignal.log') }
128
+ before do
129
+ @original_stdout = $stdout
130
+ $stdout = out_stream
131
+ Appsignal.logger.error('Log something')
132
+ end
133
+ after do
134
+ $stdout = @original_stdout
135
+ end
136
+
137
+ context "when the log path is writable" do
138
+ let(:path) { File.join(project_fixture_path, 'log') }
139
+ before { Appsignal.start_logger(path) }
140
+
141
+ it "should log to file" do
142
+ File.exists?(log_file).should be_true
143
+ File.open(log_file).read.should include 'Log something'
144
+ end
145
+ end
146
+
147
+ context "when the log path is not writable" do
148
+ let(:path) { '/nonsense/log' }
149
+ before { Appsignal.start_logger(path) }
150
+
151
+ it "should log to stdout" do
152
+ out_stream.string.should include 'Log something'
153
+ end
154
+ end
155
+
156
+ context "when we're on Heroku" do
157
+ let(:path) { File.join(project_fixture_path, 'log') }
158
+ before do
159
+ ENV['DYNO'] = 'dyno1'
160
+ Appsignal.start_logger(path)
161
+ end
162
+ after { ENV.delete('DYNO') }
163
+
164
+ it "should log to stdout" do
165
+ out_stream.string.should include 'Log something'
166
+ end
167
+ end
168
+ end
169
+
125
170
  describe '.config' do
126
171
  subject { Appsignal.config }
127
172
 
@@ -40,4 +40,9 @@ RSpec.configure do |config|
40
40
  ENV.delete('APPSIGNAL_PUSH_API_KEY')
41
41
  ENV.delete('APPSIGNAL_API_KEY')
42
42
  end
43
+
44
+ config.after do
45
+ FileUtils.rm_f(File.join(project_fixture_path, 'log/appsignal.log'))
46
+ Appsignal.logger = nil
47
+ end
43
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appsignal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.alpha.1
4
+ version: 0.7.0.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Beekman
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-11-11 00:00:00.000000000 Z
15
+ date: 2013-11-13 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport