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 +4 -4
- data/lib/on_strum/logs/configuration.rb +6 -12
- data/lib/on_strum/logs/logger/default.rb +1 -2
- data/lib/on_strum/logs/version.rb +1 -1
- data/lib/on_strum/logs.rb +1 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ecbe6a25ee37ba18625810f3c21d555a0b5ae11a35883167438e4368576311e
|
4
|
+
data.tar.gz: d6604a0734775516a73bcc5a5ffbe63f9741cf86f40f69e5e2a6d3a3b47aba3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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[
|
38
|
+
@log_attributes_order ||= OnStrum::Logs::Configuration::SETTERS[2..5].map do |field_name_getter|
|
46
39
|
public_send(field_name_getter)
|
47
|
-
end +
|
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
|
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
|
-
|
43
|
-
service_version: configuration.service_version,
|
42
|
+
**configuration.root_fields,
|
44
43
|
**log_data
|
45
44
|
)
|
46
45
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2024-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|