loga 2.1.0 → 2.1.1

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: 26c6ec05bee75b2cdaf5cc763dec166cfad96ce5
4
- data.tar.gz: 845ef8d271804c24f62195cefb13dae6dd961be9
3
+ metadata.gz: 9ea55004c4f02786aa7326eddf736f2a3f47bdac
4
+ data.tar.gz: 79b1ef4aca4cd6ac9aadd3a501cfdc84dca7ca91
5
5
  SHA512:
6
- metadata.gz: 195a21b0f8ea0a2ac55c8b44f042116b32e2012bc18df2c781863041898ec1360ce0b45a14c3795d156830960ea3b7d076c919f4e75ea5de2f185d6c72966e14
7
- data.tar.gz: 5f8c95fb86e68753e1da356fabf093c89bc3d7fb78b84ad29c569ca7352090546418e4ffdaf76f55508dc760621bb0b7239d15efa186c86ce72e18432b25f4f2
6
+ metadata.gz: e9047a4c1a74ddba23a41216915412f5c24bae7e862a2a03b417432cd6619102d939b90217f30dcbf89afcfde06c553698b702f89465173d1bafced72a09f8ae
7
+ data.tar.gz: b9b82664a07fc4a4175301734a332bbf8110660d493fd0d5226f9042a908b65181aca610fe05628fc546fa59a92afa52b92ebdb1bec03b08aedcd919caea93a3
@@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
- ## [2.1.0]
7
+ ## [2.1.1] - 2016-12-02
8
+ ### Fixed
9
+ - Encoding error when converting uploaded file to JSON
10
+ [rails/rails#25250](https://github.com/rails/rails/issues/25250)
11
+
12
+ ## [2.1.0] - 2016-11-17
8
13
  ## [2.1.0.pre.1]
9
14
  ### Changed
10
15
  - Replace `ActiveSupport::Logger::SimpleFormatter` with `Loga::Formatters::SimpleFormatter`
@@ -48,7 +53,8 @@ when using simple format. The formatter adds level, timestamp, pid and tags prep
48
53
  ### Changed
49
54
  - Silence ActionDispatch::DebugExceptions' logger
50
55
 
51
- [2.1.0]: https://github.com/FundingCircle/loga/compare/v2.0.0...v2.0.0
56
+ [2.1.1]: https://github.com/FundingCircle/loga/compare/v2.1.0...v2.1.1
57
+ [2.1.0]: https://github.com/FundingCircle/loga/compare/v2.0.0...v2.1.0
52
58
  [2.1.0.pre.1]: https://github.com/FundingCircle/loga/compare/v2.0.0...v2.1.0.pre.1
53
59
  [2.0.0]: https://github.com/FundingCircle/loga/compare/v1.4.0...v2.0.0
54
60
  [2.0.0.pre.3]: https://github.com/FundingCircle/loga/compare/v2.0.0.pre.2...v2.0.0.pre.3
data/README.md CHANGED
@@ -1,11 +1,17 @@
1
- # Loga [![Build Status](https://circleci.com/gh/FundingCircle/loga/tree/master.svg?style=shield&circle-token=9b81c3cf8468a8c3dc760f4c0398cf8914cb27d4)](https://circleci.com/gh/FundingCircle/loga/tree/master) [![Code Quality](https://codeclimate.com/repos/5563694f6956805723005d2f/badges/8eecb9144730614fb39e/gpa.svg)](https://codeclimate.com/repos/5563694f6956805723005d2f/feed) [![Test Coverage](https://codeclimate.com/repos/5563694f6956805723005d2f/badges/8eecb9144730614fb39e/coverage.svg)](https://codeclimate.com/repos/5563694f6956805723005d2f/coverage)
1
+ # Loga
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/loga.svg)](https://badge.fury.io/rb/loga)
4
+ [![Build Status](https://circleci.com/gh/FundingCircle/loga/tree/master.svg?style=shield&circle-token=9b81c3cf8468a8c3dc760f4c0398cf8914cb27d4)](https://circleci.com/gh/FundingCircle/loga/tree/master)
5
+ [![Code Quality](https://codeclimate.com/repos/5563694f6956805723005d2f/badges/8eecb9144730614fb39e/gpa.svg)](https://codeclimate.com/repos/5563694f6956805723005d2f/feed)
6
+ [![Test Coverage](https://codeclimate.com/repos/5563694f6956805723005d2f/badges/8eecb9144730614fb39e/coverage.svg)](https://codeclimate.com/repos/5563694f6956805723005d2f/coverage)
7
+ [![Dependency Status](https://gemnasium.com/badges/github.com/FundingCircle/loga.svg)](https://gemnasium.com/github.com/FundingCircle/loga)
2
8
 
3
9
  ## Description
4
10
 
5
11
  Loga provides consistent logging across frameworks and environments.
6
12
 
7
13
  Includes:
8
- - One logger for all environments
14
+ - One tagged logger for all environments
9
15
  - Human readable logs for development
10
16
  - Structured logs for production ([GELF](http://docs.graylog.org/en/2.1/pages/gelf.html))
11
17
  - One Rack logger for all Rack based applications
@@ -31,7 +37,7 @@ Includes:
31
37
  Add this line to your application's Gemfile:
32
38
 
33
39
  ```
34
- gem 'loga', git: 'git@github.com:FundingCircle/loga.git'
40
+ gem 'loga'
35
41
  ```
36
42
 
37
43
  ### Rails
@@ -41,7 +47,7 @@ Let Loga know what your application name is and Loga will do the rest.
41
47
  ```ruby
42
48
  # config/application.rb
43
49
  class MyApp::Application < Rails::Application
44
- config.loga = { service_name: 'MyApp' }
50
+ config.loga = { service_name: 'my_app' }
45
51
  end
46
52
  ```
47
53
 
@@ -62,7 +68,7 @@ class MyApp::Application < Rails::Application
62
68
  config.loga = {
63
69
  device: File.open("log/application.log", 'a'),
64
70
  format: :gelf,
65
- service_name: 'MyApp',
71
+ service_name: 'my_app',
66
72
  }
67
73
  end
68
74
  ```
@@ -167,21 +173,41 @@ Sinatra request output is identical to Rails but without the `_request.controlle
167
173
  Logger output:
168
174
 
169
175
  ```ruby
170
- Rails.logger.info('I love Loga')
176
+ # Rails.logger
171
177
  # or
178
+ # Loga.logger
179
+
180
+ Loga.configure(service_name: 'my_app', format: :gelf)
181
+
172
182
  Loga.logger.info('I love Loga')
183
+ Loga.logger.tagged(%w(USER_123 CRM)) do
184
+ Loga.logger.info('I love Loga with tags')
185
+ end
186
+ ```
187
+
188
+ ```json
189
+ {
190
+ "_service.name": "my_app",
191
+ "_service.version": "v1.0.0",
192
+ "_tags": "",
193
+ "host": "example.com",
194
+ "level": 6,
195
+ "short_message": "I love Loga",
196
+ "timestamp": 1479402679.663,
197
+ "version": "1.1"
198
+ }
173
199
  ```
174
200
 
175
201
  ```json
176
202
  {
177
- "_service.name": "my_app",
178
- "_service.version": "v1.0.0",
179
- "_tags": "12345",
203
+ "_service.name": "my_app",
204
+ "_service.version": "v1.0.0",
205
+ "_tags": "USER_123 CRM",
180
206
  "host": "example.com",
181
- "level": 6,
182
- "short_message": "I love Loga",
183
- "timestamp": 1450150205.123,
184
- "version": "1.1"
207
+ "level": 6,
208
+ "short_message": "I love Loga",
209
+ "timestamp": 1479402706.102,
210
+ "version": "1.1"
185
211
  }
186
212
  ```
187
213
 
@@ -210,11 +236,17 @@ I, [2016-11-15T16:10:08.645521+00:00 #1][12345] GET /ok 200 in 0ms type=request
210
236
  Logger output:
211
237
 
212
238
  ```ruby
239
+ Loga.configure(service_name: 'my_app', format: :simple)
240
+
213
241
  Loga.logger.info('I love Loga')
242
+ Loga.logger.tagged(%w(USER_123 CRM)) do
243
+ Loga.logger.info('I love Loga with tags')
244
+ end
214
245
  ```
215
246
 
216
247
  ```
217
- I, [2015-12-15T09:30:05.123000+06:00 #999] I love Loga
248
+ I, [2016-11-17T17:07:46.714215+00:00 #595] I love Loga
249
+ I, [2016-11-17T17:07:46.725624+00:00 #595][USER_123 CRM] I love Loga with tags
218
250
  ```
219
251
 
220
252
  ## Road map
data/circle.yml CHANGED
@@ -14,7 +14,10 @@ test:
14
14
  - rvm-exec 2.3.1 bundle exec codeclimate-test-reporter
15
15
  deployment:
16
16
  gemfury:
17
- tag: /.*/
17
+ tag: /^v\d.+/
18
+ owner: FundingCircle
18
19
  commands:
19
- - "gem build loga.gemspec"
20
- - "curl -F package=@$(ls -t1 loga-*.gem | head -1) ${GEMFURY_PUSH_URI}"
20
+ - "gem build $CIRCLE_PROJECT_REPONAME.gemspec"
21
+ - 'echo :rubygems_api_key: ${RUBYGEMS_API_KEY} > ~/.gem/credentials'
22
+ - "chmod 0600 ~/.gem/credentials"
23
+ - "gem push $CIRCLE_PROJECT_REPONAME-$(echo $CIRCLE_TAG | sed -e 's/v//').gem"
@@ -0,0 +1,7 @@
1
+ # Fixes encoding error when converting uploaded file to JSON
2
+ # https://github.com/rails/rails/issues/25250
3
+ class Tempfile
4
+ def as_json(_ = nil)
5
+ to_s
6
+ end
7
+ end
@@ -17,6 +17,7 @@ module Loga
17
17
 
18
18
  def call
19
19
  validate_user_options
20
+ change_tempfile_as_json
20
21
  Loga.configure(user_options, rails_options)
21
22
  app.config.colorize_logging = false if Loga.configuration.structured?
22
23
  app.config.logger = Loga.logger
@@ -51,17 +52,23 @@ module Loga
51
52
  Rails::VERSION::MAJOR > 3 ? app.config.autoflush_log : true
52
53
  end
53
54
 
54
- # rubocop:disable Metrics/LineLength
55
55
  def validate_user_options
56
56
  if user_options[:tags].present?
57
- raise Loga::ConfigurationError, 'Configure tags with Rails config.log_tags'
57
+ raise Loga::ConfigurationError,
58
+ 'Configure tags with Rails config.log_tags'
58
59
  elsif user_options[:level].present?
59
- raise Loga::ConfigurationError, 'Configure level with Rails config.log_level'
60
+ raise Loga::ConfigurationError,
61
+ 'Configure level with Rails config.log_level'
60
62
  elsif user_options[:filter_parameters].present?
61
- raise Loga::ConfigurationError, 'Configure filter_parameters with Rails config.filter_parameters'
63
+ raise Loga::ConfigurationError,
64
+ 'Configure filter_parameters with Rails config.filter_parameters'
62
65
  end
63
66
  end
64
- # rubocop:enable Metrics/LineLength
67
+
68
+ # Fixes encoding error when converting uploaded file to JSON
69
+ def change_tempfile_as_json
70
+ require 'loga/ext/core/tempfile'
71
+ end
65
72
  end
66
73
 
67
74
  initializer :loga_initialize_logger, before: :initialize_logger do |app|
@@ -1,3 +1,3 @@
1
1
  module Loga
2
- VERSION = '2.1.0'.freeze
2
+ VERSION = '2.1.1'.freeze
3
3
  end
Binary file
@@ -4,6 +4,13 @@ RSpec.describe Loga::Railtie do
4
4
  let(:app) { Rails.application }
5
5
  let(:middlewares) { app.middleware.middlewares }
6
6
 
7
+ describe 'Tempfile' do
8
+ let(:tempfile) { Tempfile.new('README.md') }
9
+ it 'monkey patches #as_json' do
10
+ expect(tempfile.as_json).to eql(tempfile.to_s)
11
+ end
12
+ end
13
+
7
14
  context 'development', if: Rails.env.development? do
8
15
  describe 'loga_initialize_logger' do
9
16
  let(:formatter) { Loga::Formatters::SimpleFormatter }
@@ -181,4 +181,23 @@ RSpec.shared_examples 'request logger' do
181
181
  end
182
182
  end
183
183
  end
184
+
185
+ describe 'when the request uploads a binary file', focus: true do
186
+ it 'logs the request' do
187
+ post '/users?username=yoshi',
188
+ bob_file: Rack::Test::UploadedFile.new('spec/fixtures/random_bin')
189
+
190
+ expect(last_log_entry).to include(
191
+ 'short_message' => 'POST /users?username=yoshi 200 in 0ms',
192
+ 'level' => 6,
193
+ '_request.params' => {
194
+ 'username' => 'yoshi',
195
+ 'bob_file' => include(
196
+ 'filename' => 'random_bin',
197
+ 'name' => 'bob_file',
198
+ ),
199
+ },
200
+ )
201
+ end
202
+ end
184
203
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loga
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Funding Circle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-17 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -219,6 +219,7 @@ files:
219
219
  - lib/loga.rb
220
220
  - lib/loga/configuration.rb
221
221
  - lib/loga/event.rb
222
+ - lib/loga/ext/core/tempfile.rb
222
223
  - lib/loga/ext/rails/rack/debug_exceptions.rb
223
224
  - lib/loga/ext/rails/rack/logger.rb
224
225
  - lib/loga/ext/rails/rack/logger3.rb
@@ -329,6 +330,7 @@ files:
329
330
  - spec/fixtures/rails50/public/apple-touch-icon.png
330
331
  - spec/fixtures/rails50/public/favicon.ico
331
332
  - spec/fixtures/rails50/public/robots.txt
333
+ - spec/fixtures/random_bin
332
334
  - spec/integration/rails/railtie_spec.rb
333
335
  - spec/integration/rails/request_spec.rb
334
336
  - spec/integration/sinatra_spec.rb
@@ -366,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
366
368
  version: '0'
367
369
  requirements: []
368
370
  rubyforge_project:
369
- rubygems_version: 2.5.1
371
+ rubygems_version: 2.4.5.1
370
372
  signing_key:
371
373
  specification_version: 4
372
374
  summary: Facilitate log aggregation via unified logging
@@ -466,6 +468,7 @@ test_files:
466
468
  - spec/fixtures/rails50/public/apple-touch-icon.png
467
469
  - spec/fixtures/rails50/public/favicon.ico
468
470
  - spec/fixtures/rails50/public/robots.txt
471
+ - spec/fixtures/random_bin
469
472
  - spec/integration/rails/railtie_spec.rb
470
473
  - spec/integration/rails/request_spec.rb
471
474
  - spec/integration/sinatra_spec.rb
@@ -483,4 +486,3 @@ test_files:
483
486
  - spec/unit/loga/service_version_strategies_spec.rb
484
487
  - spec/unit/loga/utilities_spec.rb
485
488
  - spec/unit/loga_spec.rb
486
- has_rdoc: