on_strum-logs 0.3.0 → 1.0.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: 99be5f9f716a2f741e7707f7452d25f2c93de108427156d162a840740c802210
4
- data.tar.gz: bcfac9e566a8792d127a4c96d0a8c1e91462572095433bd13b85f102d5462653
3
+ metadata.gz: 2ecbe6a25ee37ba18625810f3c21d555a0b5ae11a35883167438e4368576311e
4
+ data.tar.gz: d6604a0734775516a73bcc5a5ffbe63f9741cf86f40f69e5e2a6d3a3b47aba3b
5
5
  SHA512:
6
- metadata.gz: 91c6788b1bb58b0a5880219f6f65ce467e0c311d9aa77e94f2c211a72549ccdb82e20b476caf095173c036c88549c17c6ed5c194e235cf7784f30e7c27799d00
7
- data.tar.gz: 0bde444c6e7be135857608604de67ae1cfcf30cbb1c9fb2029055f50ac0da4dc2628911cd356f336de9b0f79d0279f7237b6d1f64d2fefd7251aad8abc83b380
6
+ metadata.gz: '01390b62cd01dd39b8f49d0cf3d60a5e557cc37b6ef3543274f49173d25e1bb4666a04d3c89bd018f1d65a727e7c394fe8326642b763843c9b9adcc753c59114'
7
+ data.tar.gz: 645e4a74b4130d79400a49d7b75d73fcebccbff71a7d80b7a45545e364a411836554c747949f5b6ecb52b34ce2c7380b08872694ad1b8e3fbf99e4aeb3323322
@@ -3,11 +3,9 @@
3
3
  module OnStrum
4
4
  module Logs
5
5
  class Configuration
6
- INCOMPLETE_CONFIG = 'service_name, service_version are required parameters'
7
6
  SETTERS = %i[
8
7
  custom_formatter
9
- service_name
10
- service_version
8
+ root_fields
11
9
  field_name_level
12
10
  field_name_time
13
11
  field_name_message
@@ -32,19 +30,14 @@ module OnStrum
32
30
  end
33
31
  end
34
32
 
35
- def complete?
36
- !!(service_name && service_version)
37
- end
38
-
39
33
  def formatter
40
34
  custom_formatter || builded_formatter
41
35
  end
42
36
 
43
- # TODO: hardcoded fields will be removed in next release
44
37
  def log_attributes_order
45
- @log_attributes_order ||= OnStrum::Logs::Configuration::SETTERS[3..6].map do |field_name_getter|
38
+ @log_attributes_order ||= OnStrum::Logs::Configuration::SETTERS[2..5].map do |field_name_getter|
46
39
  public_send(field_name_getter)
47
- end + %i[service_name service_version]
40
+ end + root_fields.keys
48
41
  end
49
42
 
50
43
  private
@@ -52,6 +45,7 @@ module OnStrum
52
45
  def instance_initializer
53
46
  message_key = OnStrum::Logs::Configuration::BUILTIN_FIELDS_DEFAULT_NAMES[2]
54
47
  {
48
+ root_fields: {},
55
49
  field_name_level: OnStrum::Logs::Configuration::BUILTIN_FIELDS_DEFAULT_NAMES[0],
56
50
  field_name_time: OnStrum::Logs::Configuration::BUILTIN_FIELDS_DEFAULT_NAMES[1],
57
51
  field_name_message: message_key,
@@ -64,9 +58,9 @@ module OnStrum
64
58
  def valid_argument_type?(method_name, argument)
65
59
  argument.is_a?(
66
60
  case method_name
67
- when :service_name, :service_version then ::String
68
- when *OnStrum::Logs::Configuration::SETTERS[3..-1] then ::Symbol
61
+ when *OnStrum::Logs::Configuration::SETTERS[2..-1] then ::Symbol
69
62
  when :custom_formatter then ::Class
63
+ when :root_fields then ::Hash
70
64
  end
71
65
  )
72
66
  end
@@ -39,8 +39,7 @@ module OnStrum
39
39
  @formatter ||= proc do |_severity, datetime, _progname, log_data|
40
40
  configuration.formatter.call(
41
41
  configuration.field_name_time => datetime,
42
- service_name: configuration.service_name,
43
- service_version: configuration.service_version,
42
+ **configuration.root_fields,
44
43
  **log_data
45
44
  )
46
45
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OnStrum
4
4
  module Logs
5
- VERSION = '0.3.0'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
data/lib/on_strum/logs.rb CHANGED
@@ -9,10 +9,7 @@ module OnStrum
9
9
  @configuration ||= begin
10
10
  return unless block
11
11
 
12
- configuration = OnStrum::Logs::Configuration.new(&block)
13
- raise OnStrum::Logs::Error::Configuration, OnStrum::Logs::Configuration::INCOMPLETE_CONFIG unless configuration.complete?
14
-
15
- configuration
12
+ OnStrum::Logs::Configuration.new(&block)
16
13
  end
17
14
  end
18
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: on_strum-logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladislav Trotsenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print