gitlab-labkit 0.29.0 → 0.30.0

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: b4b144027d3b759c387a532a28c949d4551e6af5bc058d886d8a0f15f7156ddd
4
+ data.tar.gz: 40650117c553316ffb3260ddde7c50005287856ded9dec86339dc33b8c4b73d6
5
5
  SHA512:
6
- metadata.gz: e6a475fa4b31747f731ddffc6fe0439795f060c7aa2e743d214ec9629708ecfd8c03abfd2532a6482a5ef5259f121333c113253fb13860487de1e345fbc75a30
7
- data.tar.gz: 7f30c1a8cfb9a36313045bc2d1beed7df127bd97dd01deba6880eba4e7c6f82bd2705cb30d2759dd6f01579dd46652e4d07e1eef67a792f7087f6e3d4f451f26
6
+ metadata.gz: 19bf82ef843b8bc1ec633d50065c674d95f9ade7c0b3bcc2e9a9764972b650c4497f5741dffb95c9e30df0b5a7b7d68af601007f27396aa875bfe85573df6e26
7
+ data.tar.gz: 957be0fe6bcc5a00f8565c9c2e55de978032586fc6749ab4b0b2fc1a8ca5a1e92ff547b2a3ea2d489d28c54f77b39eef97ae54eb2e0419afe2b3be04e4e091a5
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,17 @@ require "json"
6
6
  module Labkit
7
7
  module Logging
8
8
  class JsonLogger < ::Logger
9
+ INTERNAL_LOG_KEYS = Labkit::Context::RAW_KEYS + [Labkit::Context::LOG_KEY]
10
+ RESERVED_LOG_KEYS = INTERNAL_LOG_KEYS.map(&:to_sym) + [
11
+ :environment,
12
+ :host,
13
+ :shard,
14
+ :stage,
15
+ :subcomponent,
16
+ :tier,
17
+ :type,
18
+ ].freeze
19
+
9
20
  def self.log_level(fallback: ::Logger::DEBUG)
10
21
  ENV.fetch("GITLAB_LOG_LEVEL", fallback)
11
22
  end
@@ -24,6 +35,7 @@ module Labkit
24
35
  when String
25
36
  data[:message] = message
26
37
  when Hash
38
+ reject_reserved_log_keys!(message)
27
39
  data.merge!(message)
28
40
  end
29
41
 
@@ -39,6 +51,16 @@ module Labkit
39
51
  def dump_json(data)
40
52
  JSON.generate(data)
41
53
  end
54
+
55
+ def reject_reserved_log_keys!(hash)
56
+ return if ENV["RAILS_ENV"] == "production"
57
+
58
+ reserved_keys_used = hash.transform_keys(&:to_sym).slice(*RESERVED_LOG_KEYS)
59
+ if reserved_keys_used.any?
60
+ raise "The following log keys used are reserved: #{reserved_keys_used.keys.join(", ")}" +
61
+ "\n\nUse key names that are descriptive e.g. by using a prefix."
62
+ end
63
+ end
42
64
  end
43
65
  end
44
66
  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.0
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-09 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