betterlog 0.15.1 → 0.15.2

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
  SHA256:
3
- metadata.gz: 310ec632c3d859e3b2ec3bfed5a71df3ce63234799004346df979aa12d6adb7e
4
- data.tar.gz: a5f2bf5a77787d58ba3a47ee7a35419bf2d057a5edcc95665e06966ae8d3d422
3
+ metadata.gz: 27e6af480e7ec65272867c76176a644ce2c925e853aff060074840f17ad5d714
4
+ data.tar.gz: 0531306c3a7b421691b67e78be5d7e960c91cb421e4e2db22657cdbe2cc248e0
5
5
  SHA512:
6
- metadata.gz: 4d38842901b4f50db613853f8acb63bd3a3d9f6e06290bd59e5b5f4dc69471848048bc06da20279cf966cf62710105178390838174a0282a4cfcdaa032b6c752
7
- data.tar.gz: cc1aa1af891a4e507c43a910e952057546947d27c34e91f96cb9408d99d5e03fd9ff175beb28d206e9e32b0d83e2276c112d9fd450bf0419d6ab5ff26164d51d
6
+ metadata.gz: '096483149f340b0cb1f8fc5253ad033e7ce7a4dc4abdd2c07c78beb464a8cd95538b956c4f82b45133d2287cfb767c754fdd1fd8079de780534ed9def9532267'
7
+ data.tar.gz: 610301cb7fc4b028816d78f5ce5f8330b5c04e291ff5099035af49ab3de85def2048455276767b0253f60bebc9d7dd1eb9fb3c3902414ae60e79bf4057ac054b
@@ -16,6 +16,7 @@ blocks:
16
16
  commands:
17
17
  - sem-version ruby 2.7.2
18
18
  - cache restore gems-$SEMAPHORE_GIT_BRANCH,gems-master
19
+ - bundle config set path 'vendor/bundle'
19
20
  - bundle config jobs $(getconf _NPROCESSORS_ONLN)
20
21
  - bundle install
21
22
  - cache store gems-$SEMAPHORE_GIT_BRANCH vendor/bundle
@@ -34,13 +35,14 @@ blocks:
34
35
 
35
36
  # Setup gems
36
37
  - cache restore gems-$SEMAPHORE_GIT_BRANCH,gems-master
38
+ - bundle config set path 'vendor/bundle'
37
39
  - bundle config jobs $(getconf _NPROCESSORS_ONLN)
38
40
  - bundle install
39
41
 
40
42
  jobs:
41
43
  - name: RSpec Unit Tests
42
44
  commands:
43
- - rake
45
+ - bundle exec rake
44
46
 
45
47
  - name: Building Docker Image
46
48
  task:
@@ -51,10 +53,11 @@ blocks:
51
53
  prologue:
52
54
  commands:
53
55
  - gcloud auth activate-service-account --key-file=.secrets/gcp.json
54
- - gcloud auth configure-docker -q
56
+ - gcloud auth configure-docker -q eu.gcr.io
55
57
  - checkout
56
58
 
57
59
  jobs:
58
60
  - name: Building and pushing
59
61
  commands:
60
- - make build push-latest
62
+ - make build
63
+ - test "$SEMAPHORE_GIT_BRANCH" = "master" && make push-latest
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM alpine:3.12.1 AS builder
1
+ FROM alpine:3.12.3 AS builder
2
2
 
3
3
  # Update/Upgrade/Add packages for building
4
4
 
@@ -18,7 +18,7 @@ RUN go get -u github.com/betterplace/go-init
18
18
 
19
19
  RUN make setup all
20
20
 
21
- FROM alpine:3.12.1 AS runner
21
+ FROM alpine:3.12.3 AS runner
22
22
 
23
23
  # Update/Upgrade/Add packages
24
24
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.15.1
1
+ 0.15.2
data/betterlog.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: betterlog 0.15.1 ruby lib
2
+ # stub: betterlog 0.15.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "betterlog".freeze
6
- s.version = "0.15.1"
6
+ s.version = "0.15.2"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["betterplace Developers".freeze]
11
- s.date = "2020-12-07"
11
+ s.date = "2021-02-03"
12
12
  s.description = "This library provides structure json logging for our rails projects".freeze
13
13
  s.email = "developers@betterplace.org".freeze
14
14
  s.executables = ["betterlog".freeze, "betterlog_pusher".freeze, "betterlog_sink".freeze]
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.files = [".gitignore".freeze, ".semaphore/semaphore.yml".freeze, "Dockerfile".freeze, "Gemfile".freeze, "LICENSE".freeze, "Makefile".freeze, "README.md".freeze, "Rakefile".freeze, "TODO.md".freeze, "VERSION".freeze, "betterlog.gemspec".freeze, "betterlog/config.go".freeze, "betterlog/healthz.go".freeze, "betterlog/redis_cert_cache.go".freeze, "bin/betterlog".freeze, "bin/betterlog_pusher".freeze, "bin/betterlog_sink".freeze, "cloudbuild.yaml".freeze, "cmd/betterlog-server/LICENSE".freeze, "cmd/betterlog-server/main.go".freeze, "config/log.yml".freeze, "go.mod".freeze, "go.sum".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/severity.rb".freeze, "lib/betterlog/log_event_formatter.rb".freeze, "lib/betterlog/logger.rb".freeze, "lib/betterlog/notifiers.rb".freeze, "lib/betterlog/railtie.rb".freeze, "lib/betterlog/version.rb".freeze, "spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log/event_spec.rb".freeze, "spec/betterlog/log/severity_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/logger_spec.rb".freeze, "spec/spec_helper.rb".freeze]
17
17
  s.homepage = "http://github.com/betterplace/betterlog".freeze
18
18
  s.rdoc_options = ["--title".freeze, "Betterlog".freeze, "--main".freeze, "README.md".freeze]
19
- s.rubygems_version = "3.1.4".freeze
19
+ s.rubygems_version = "3.2.5".freeze
20
20
  s.summary = "Structured logging support for bp".freeze
21
21
  s.test_files = ["spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log/event_spec.rb".freeze, "spec/betterlog/log/severity_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/logger_spec.rb".freeze, "spec/spec_helper.rb".freeze]
22
22
 
data/lib/betterlog/log.rb CHANGED
@@ -138,7 +138,7 @@ module Betterlog
138
138
  end
139
139
  event[:emitter] = self.class.name.downcase
140
140
  notify(event)
141
- logger.send(event.severity.to_sym, event.to_json)
141
+ logger.send(event.severity.to_sym, JSON.generate(event))
142
142
  self
143
143
  ensure
144
144
  GlobalMetadata.data.clear
@@ -75,7 +75,15 @@ module Betterlog
75
75
  end
76
76
 
77
77
  def to_json(*a)
78
- as_json.to_json(*a)
78
+ JSON.generate(as_json)
79
+ rescue
80
+ # Sometimes rails logging messages contain invalid utf-8 characters
81
+ # generating various standard errors. Let's fallback to a barebones
82
+ # event with just a cleaned up message for these cases.
83
+ JSON.generate({
84
+ severity: @data[:severity],
85
+ message: @data.fetch(:message, '').encode('utf-8', invalid: :replace, undef: :replace, replace: ''),
86
+ })
79
87
  end
80
88
 
81
89
  def format(*args)
@@ -18,7 +18,7 @@ module Betterlog
18
18
  when :format
19
19
  format_pattern(format: format)
20
20
  else
21
- @event.to_json
21
+ JSON.generate(@event)
22
22
  end
23
23
  ensure
24
24
  Term::ANSIColor.coloring = old_coloring
@@ -36,7 +36,7 @@ module Betterlog
36
36
  event[:location] = [ l.absolute_path, l.lineno ] * ?:
37
37
  end
38
38
  program and event[:program] = program
39
- message = event.to_json
39
+ message = JSON.generate(event)
40
40
  end
41
41
  end
42
42
  rescue => e
@@ -1,6 +1,6 @@
1
1
  module Betterlog
2
2
  # Betterlog version
3
- VERSION = '0.15.1'
3
+ VERSION = '0.15.2'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -26,6 +26,17 @@ describe Betterlog::Log do
26
26
  end
27
27
  end
28
28
 
29
+ describe 'Log::Event.to_json' do
30
+ it 'can be called' do
31
+ expect(event.to_json).to be_present
32
+ end
33
+
34
+ it 'can handle invalid UTF-8 characters' do
35
+ event = Log::Event.ify("foo\xCEbar")
36
+ expect(event.to_json).to eq(JSON(severity: "DEBUG", message: 'foobar'))
37
+ end
38
+ end
39
+
29
40
  describe '.parse' do
30
41
  it 'can parse an event as a JSON document' do
31
42
  expect(Log::Event.parse(event.to_json)).to eq event
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: betterlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - betterplace Developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-07 00:00:00.000000000 Z
11
+ date: 2021-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubygems_version: 3.1.4
284
+ rubygems_version: 3.2.5
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: Structured logging support for bp