logput 0.0.4 → 0.0.5

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: 19a7457eddef652b545880acae4704d2b6f238da
4
- data.tar.gz: b2a1859fcc2bdb935192a177ce82de6f1234ef46
3
+ metadata.gz: 7e8f4e0db6232485318e0302ccfdfe4adbcff484
4
+ data.tar.gz: 7626dde6eb6405171e7e048b0b89cbce64c662d6
5
5
  SHA512:
6
- metadata.gz: b910ed111410a841bcf269d45731b026cd75d0a8beb6c64b9ec087032a25f82bf810c57114982fb315893ce58460474f4c4d18fcf32a23a0e9cdf4304826422f
7
- data.tar.gz: 06e122d67f32127abee46d988ddcb388c4ec761acf6873df197680b15c81cbfce814f6b404006f4cd05210ed12f9ffbecb7764c755bd1a511a895dfda2d30868
6
+ metadata.gz: 023ef10cd1c6305afeb028ada027151586523bdc3e0514857f0a7f93ef7e0f1d2853dbcf8197c30e7cc05b739f72794d8b0137881ba9316301449247ed62c70c
7
+ data.tar.gz: 442a34bc443f946434c676dae220e3fa414333da5bc5968910a4f6a6b2f5cddf1f8de43008967a44bb4678c7c0a7c0303eadb0e47c6691af230f1c939804b217
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.2
4
- - 2.1.6
5
- - 2.0.0
3
+ - 2.3.4
4
+ - 2.2.7
5
+ - 2.1.9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logput
2
2
 
3
- [![Build Status](https://api.travis-ci.org/asmega/logput.svg)](https://travis-ci.org/asmega/logput) [![Code Climate](https://codeclimate.com/github/asmega/logput/badges/gpa.svg)](https://codeclimate.com/github/asmega/logput) [![Dependency Status](https://gemnasium.com/asmega/logput.svg)](https://gemnasium.com/asmega/logput) [![Gem Version](https://badge.fury.io/rb/logput.svg)](https://badge.fury.io/rb/logput)
3
+ [![Build Status](https://api.travis-ci.org/asmega/logput.svg)](https://travis-ci.org/asmega/logput) [![Code Climate](https://codeclimate.com/github/asmega/logput/badges/gpa.svg)](https://codeclimate.com/github/asmega/logput) [![Gem Version](https://badge.fury.io/rb/logput.svg)](https://badge.fury.io/rb/logput)
4
4
 
5
5
  Rack middleware to sit in a rails app to put put the current environments log to a webpage. eg /logput
6
6
 
@@ -46,6 +46,15 @@ Example.
46
46
 
47
47
  Start your rails server as normal in the set environment. Navigate to /logput e.g. [http://localhost:3000/logput](http://localhost:3000/logput)
48
48
 
49
+ ## Environment Variable Overrides
50
+
51
+ It is possible to overide the location of the log files by using the following environment variables:
52
+
53
+ * `LOG_NAME` - The name of the log file, e.g. `development` - `.log` will be appended to this. If unset logput will try to use `RAILS_ENV` or `RACK_ENV` as a fallback
54
+ * `LOG_LOCATION_DIR` - The directory where the log file is located, e.g. `logs` - a `/` will be added when combined with the log name.
55
+
56
+ The overrides will only be used if both are present (or the fallbacks in the case of the log name).
57
+
49
58
  ## Contributing
50
59
 
51
60
  1. Fork it
@@ -29,6 +29,24 @@ module Logput
29
29
  def path
30
30
  raise NotImplementedError
31
31
  end
32
+
33
+ # Enable overriding of the path with an environment variable
34
+ # @return [String] path
35
+ def path_override
36
+ return unless directory && filename
37
+
38
+ "#{directory}/#{filename}.log"
39
+ end
40
+
41
+ private
42
+
43
+ def filename
44
+ @filename ||= ENV['LOG_NAME'] || ENV['RAILS_ENV'] || ENV['RACK_ENV']
45
+ end
46
+
47
+ def directory
48
+ @directory ||= ENV['LOG_LOCATION_DIR']
49
+ end
32
50
  end
33
51
  end
34
52
  end
@@ -15,6 +15,7 @@ module Logput
15
15
 
16
16
  # @return [String] path
17
17
  def path
18
+ return path_override if path_override
18
19
  @logger.instance_variable_get(:@logdev).filename
19
20
  end
20
21
  end
@@ -15,6 +15,7 @@ module Logput
15
15
 
16
16
  # @return [String] path
17
17
  def path
18
+ return path_override if path_override
18
19
  @logger.instance_variable_get(:@logger).instance_variable_get(:@log_dest).path
19
20
  end
20
21
  end
@@ -1,5 +1,5 @@
1
1
  # Logput
2
2
  module Logput
3
3
  # Gem version
4
- VERSION = "0.0.4"
4
+ VERSION = "0.0.5"
5
5
  end
@@ -33,4 +33,25 @@ describe Logput::Adapters::Base do
33
33
  }.to raise_error(NotImplementedError)
34
34
  end
35
35
  end
36
+
37
+ describe '#path_override' do
38
+ subject { described_class.new(:foo) }
39
+
40
+ after :each do
41
+ ENV['LOG_NAME'] = nil
42
+ ENV['LOG_LOCATION_DIR'] = nil
43
+ end
44
+
45
+ it 'returns nil if environment variables are not set' do
46
+ expect(subject.path_override).to eq(nil)
47
+ end
48
+
49
+ it 'returns a path if the environment variables are set' do
50
+ ENV['LOG_NAME'] = 'development'
51
+ ENV['LOG_LOCATION_DIR'] = 'logs'
52
+ expect(subject.path_override).to eq('logs/development.log')
53
+ end
54
+
55
+
56
+ end
36
57
  end
@@ -26,5 +26,18 @@ describe Logput::Adapters::Logger do
26
26
  it 'returns the correct path' do
27
27
  expect(subject.path).to eq(path)
28
28
  end
29
+
30
+ context 'when environment variable overrides are present' do
31
+ after :each do
32
+ ENV['LOG_NAME'] = nil
33
+ ENV['LOG_LOCATION_DIR'] = nil
34
+ end
35
+
36
+ it 'returns the overridden path' do
37
+ ENV['LOG_NAME'] = 'development'
38
+ ENV['LOG_LOCATION_DIR'] = 'logs'
39
+ expect(subject.path).to eq('logs/development.log')
40
+ end
41
+ end
29
42
  end
30
43
  end
@@ -29,5 +29,18 @@ describe Logput::Adapters::TaggedLogging do
29
29
  it 'returns the correct path' do
30
30
  expect(subject.path).to eq(path)
31
31
  end
32
+
33
+ context 'when environment variable overrides are present' do
34
+ after :each do
35
+ ENV['LOG_NAME'] = nil
36
+ ENV['LOG_LOCATION_DIR'] = nil
37
+ end
38
+
39
+ it 'returns the overridden path' do
40
+ ENV['LOG_NAME'] = 'development'
41
+ ENV['LOG_LOCATION_DIR'] = 'logs'
42
+ expect(subject.path).to eq('logs/development.log')
43
+ end
44
+ end
32
45
  end
33
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logput
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-12 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  version: '0'
201
201
  requirements: []
202
202
  rubyforge_project:
203
- rubygems_version: 2.2.5
203
+ rubygems_version: 2.6.12
204
204
  signing_key:
205
205
  specification_version: 4
206
206
  summary: Rack middleware to output rails logs to a webpage
@@ -212,4 +212,3 @@ test_files:
212
212
  - spec/middleware_spec.rb
213
213
  - spec/spec_helper.rb
214
214
  - spec/support/test.log
215
- has_rdoc: