gitlab-labkit 0.29.0 → 0.30.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
  SHA256:
3
- metadata.gz: 959c572170b2eacd0d0886603f9bac07fea6e85d45b12a66f8048a822d0ac2f8
4
- data.tar.gz: 8e63111f0c1fb923f482a68845a2c92f550323e63f048a633f06ef7b5dd63135
3
+ metadata.gz: b1307834ccc43bf7c67a2869284eb88596f8bc179aa23ffc54850c3094cb1e92
4
+ data.tar.gz: bf1e7c8464a5d6412673b98e957e7d725fce091408f9e79ab0eebead46afd432
5
5
  SHA512:
6
- metadata.gz: e6a475fa4b31747f731ddffc6fe0439795f060c7aa2e743d214ec9629708ecfd8c03abfd2532a6482a5ef5259f121333c113253fb13860487de1e345fbc75a30
7
- data.tar.gz: 7f30c1a8cfb9a36313045bc2d1beed7df127bd97dd01deba6880eba4e7c6f82bd2705cb30d2759dd6f01579dd46652e4d07e1eef67a792f7087f6e3d4f451f26
6
+ metadata.gz: 668d57c1c15b3e54dda7fa7906de490494725d07854d6ae60118a2973b2c51034a35e12765ab66a805d73d5e664c866574ae3e0d4c247b97355c87caabe25954
7
+ data.tar.gz: 04cde34debf83ad8fe76bf3207c99a8f83bbee367e0c9636f717f710286b4423ef66894e4803a99f21c0843518a49fc222e554389decd3348f7aea9a392eab22
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.4
1
+ 2.7.7
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.7
@@ -6,6 +6,19 @@ require "json"
6
6
  module Labkit
7
7
  module Logging
8
8
  class JsonLogger < ::Logger
9
+ # We should also reject log keys coming from Labkit::Context, but we cannot
10
+ # do this without breaking clients currently. This is tracked in
11
+ # https://gitlab.com/gitlab-org/ruby/gems/labkit-ruby/-/issues/35
12
+ RESERVED_LOG_KEYS = [
13
+ :environment,
14
+ :host,
15
+ :shard,
16
+ :stage,
17
+ :subcomponent,
18
+ :tier,
19
+ :type,
20
+ ].freeze
21
+
9
22
  def self.log_level(fallback: ::Logger::DEBUG)
10
23
  ENV.fetch("GITLAB_LOG_LEVEL", fallback)
11
24
  end
@@ -24,6 +37,7 @@ module Labkit
24
37
  when String
25
38
  data[:message] = message
26
39
  when Hash
40
+ reject_reserved_log_keys!(message)
27
41
  data.merge!(message)
28
42
  end
29
43
 
@@ -39,6 +53,16 @@ module Labkit
39
53
  def dump_json(data)
40
54
  JSON.generate(data)
41
55
  end
56
+
57
+ def reject_reserved_log_keys!(hash)
58
+ return if ENV["RAILS_ENV"] == "production"
59
+
60
+ reserved_keys_used = hash.transform_keys(&:to_sym).slice(*RESERVED_LOG_KEYS)
61
+ if reserved_keys_used.any?
62
+ raise "The following log keys used are reserved: #{reserved_keys_used.keys.join(", ")}" +
63
+ "\n\nUse key names that are descriptive e.g. by using a prefix."
64
+ end
65
+ end
42
66
  end
43
67
  end
44
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-labkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.30.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newdigate
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-25 00:00:00.000000000 Z
11
+ date: 2023-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -372,6 +372,7 @@ files:
372
372
  - ".rubocop_todo.yml"
373
373
  - ".ruby-version"
374
374
  - ".rufo"
375
+ - ".tool-versions"
375
376
  - CONTRIBUTING.md
376
377
  - Dangerfile
377
378
  - Gemfile