nexus_semantic_logger 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/lib/nexus_semantic_logger/appender_filter.rb +77 -0
- data/lib/nexus_semantic_logger/application.rb +14 -6
- data/lib/nexus_semantic_logger/version.rb +2 -2
- data/lib/nexus_semantic_logger.rb +1 -0
- data/nexus_semantic_logger.gemspec +4 -3
- metadata +16 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f12150f394b0f2c56570a19a1979c3f8cf0f58f3c622d6d2886ed6925041825
|
4
|
+
data.tar.gz: 7fc2853cb92631be96b8bc17f07d97eff6057091170704d28ef0280b673ac370
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd9b6db086b0b1bb5f8cb760577d87a8603ae892aeeb8e01249081911f3b83068e96357ad0c13a8fa184e96a63efb9f55241bbcc1baa7aa4e513021dd713689b
|
7
|
+
data.tar.gz: '084c137b346270f171132a5de282a3a2019be85fe5a83de3677cedf26290f6f7b1ced55c2ede9cbd57afe9daa6ed9d5d58ddf60ce5e7954d6e3b937753302e30'
|
data/.rubocop.yml
CHANGED
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'rails_semantic_logger'
|
3
|
+
|
4
|
+
module NexusSemanticLogger
|
5
|
+
class AppenderFilter
|
6
|
+
def self.filter_lambda
|
7
|
+
-> (log) {
|
8
|
+
# log API see https://logger.rocketjob.io/log_struct.html
|
9
|
+
# and lib/semantic_logger/levels.rb
|
10
|
+
# level: :trace=>0, :debug=>1, :info=>2, :warn=>3, :error=>4, :fatal=>5
|
11
|
+
current_log_level = SemanticLogger::Levels.index(env_names_default_level)
|
12
|
+
|
13
|
+
# Names allow overriding the level that will be appended,
|
14
|
+
# else the global level is used to determine appending.
|
15
|
+
append = false
|
16
|
+
if log.name.in?(env_names_trace)
|
17
|
+
append = true
|
18
|
+
elsif log.name.in?(env_names_debug)
|
19
|
+
append = log.level_index >= 1
|
20
|
+
elsif log.name.in?(env_names_info)
|
21
|
+
append = log.level_index >= 2
|
22
|
+
elsif log.name.in?(env_names_warn)
|
23
|
+
append = log.level_index >= 3
|
24
|
+
elsif log.name.in?(env_names_error)
|
25
|
+
append = log.level_index >= 4
|
26
|
+
elsif log.name.in?(env_names_fatal)
|
27
|
+
append = log.level_index >= 5
|
28
|
+
else
|
29
|
+
append = log.level_index >= current_log_level
|
30
|
+
end
|
31
|
+
append
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.env_names_default_level
|
36
|
+
@@names_default_level ||= ENV.fetch('LOG_NAMES_DEFAULT_LEVEL', Rails.application.config.log_level)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.env_names_trace
|
40
|
+
@@names_trace ||= fetch_env_names('LOG_NAMES_TRACE')
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.env_names_debug
|
44
|
+
@@names_debug ||= fetch_env_names('LOG_NAMES_DEBUG')
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.env_names_info
|
48
|
+
@@names_info ||= fetch_env_names('LOG_NAMES_INFO')
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.env_names_warn
|
52
|
+
@@names_warn ||= fetch_env_names('LOG_NAMES_WARN')
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.env_names_error
|
56
|
+
@@names_error ||= fetch_env_names('LOG_NAMES_ERROR')
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.env_names_fatal
|
60
|
+
@@names_fatal ||= fetch_env_names('LOG_NAMES_FATAL')
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.flush
|
64
|
+
@@names_default_level = nil
|
65
|
+
@@names_trace = nil
|
66
|
+
@@names_debug = nil
|
67
|
+
@@names_info = nil
|
68
|
+
@@names_warn = nil
|
69
|
+
@@names_error = nil
|
70
|
+
@@names_fatal = nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.fetch_env_names(var)
|
74
|
+
ENV.fetch(var, '').split(',').to_set
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require '
|
2
|
+
require 'rails_semantic_logger'
|
3
3
|
|
4
4
|
module NexusSemanticLogger
|
5
5
|
class Application
|
@@ -33,7 +33,8 @@ module NexusSemanticLogger
|
|
33
33
|
# Default logging is stdout in datadog compatible JSON.
|
34
34
|
config.rails_semantic_logger.format = NexusSemanticLogger::DatadogFormatter.new(service)
|
35
35
|
config.rails_semantic_logger.add_file_appender = false
|
36
|
-
config.semantic_logger.add_appender(io: $stdout, formatter: config.rails_semantic_logger.format)
|
36
|
+
dd_appender = config.semantic_logger.add_appender(io: $stdout, formatter: config.rails_semantic_logger.format)
|
37
|
+
dd_appender.filter = NexusSemanticLogger::AppenderFilter.filter_lambda
|
37
38
|
|
38
39
|
logger.info('SemanticLogger initialised.', level: config.log_level)
|
39
40
|
end
|
@@ -44,13 +45,19 @@ module NexusSemanticLogger
|
|
44
45
|
|
45
46
|
# Change default logging to coloured logging on stdout.
|
46
47
|
config.semantic_logger.clear_appenders!
|
47
|
-
config.semantic_logger.add_appender(io: $stdout, formatter: :color)
|
48
|
+
color_appender = config.semantic_logger.add_appender(io: $stdout, formatter: :color)
|
49
|
+
color_appender.filter = NexusSemanticLogger::AppenderFilter.filter_lambda
|
50
|
+
|
48
51
|
if ENV['DD_AGENT_HOST'].present? && ENV['DD_AGENT_PORT'].present?
|
49
52
|
# Development logs can be sent to datadog via a TCP logging endpoint on a local agent.
|
50
53
|
# Each port is assigned a particular service.
|
51
54
|
# See https://logger.rocketjob.io/appenders.html
|
52
|
-
config.semantic_logger.add_appender(
|
53
|
-
|
55
|
+
dd_appender = config.semantic_logger.add_appender(
|
56
|
+
appender: :tcp,
|
57
|
+
server: "#{ENV['DD_AGENT_HOST']}:#{ENV['DD_AGENT_PORT']}",
|
58
|
+
formatter: config.rails_semantic_logger.format
|
59
|
+
)
|
60
|
+
dd_appender.filter = NexusSemanticLogger::AppenderFilter.filter_lambda
|
54
61
|
end
|
55
62
|
|
56
63
|
logger.info('SemanticLogger initialised in development.', level: config.log_level)
|
@@ -59,7 +66,8 @@ module NexusSemanticLogger
|
|
59
66
|
def self.test(config)
|
60
67
|
# Use human readable coloured output for logs when running tests.
|
61
68
|
config.semantic_logger.clear_appenders!
|
62
|
-
config.semantic_logger.add_appender(io: $stdout, formatter: :color)
|
69
|
+
color_appender = config.semantic_logger.add_appender(io: $stdout, formatter: :color)
|
70
|
+
color_appender.filter = NexusSemanticLogger::AppenderFilter.filter_lambda
|
63
71
|
end
|
64
72
|
end
|
65
73
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module NexusSemanticLogger
|
3
|
-
# Leave this as 1.
|
4
|
-
VERSION = '1.
|
3
|
+
# Leave this as 1.1.0 in order for CI process to replace with the tagged version.
|
4
|
+
VERSION = '1.1.0'
|
5
5
|
end
|
@@ -13,7 +13,8 @@ Gem::Specification.new do |spec|
|
|
13
13
|
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
14
14
|
end
|
15
15
|
spec.require_paths = ['lib']
|
16
|
-
spec.add_dependency('amazing_print')
|
17
|
-
spec.add_dependency('rails_semantic_logger')
|
18
|
-
spec.add_dependency('net_tcp_client') # For TCP logging.
|
16
|
+
spec.add_dependency('amazing_print', '~> 1.4.0')
|
17
|
+
spec.add_dependency('rails_semantic_logger', '~> 4.10.0')
|
18
|
+
spec.add_dependency('net_tcp_client', '~> 2.2.0') # For TCP logging.
|
19
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
19
20
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexus_semantic_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johnathon Harris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.4.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails_semantic_logger
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.10.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 4.10.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: net_tcp_client
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.2.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.2.0
|
55
55
|
description:
|
56
56
|
email: john.harris@nexusmods.com
|
57
57
|
executables: []
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- Gemfile
|
64
64
|
- README.md
|
65
65
|
- lib/nexus_semantic_logger.rb
|
66
|
+
- lib/nexus_semantic_logger/appender_filter.rb
|
66
67
|
- lib/nexus_semantic_logger/application.rb
|
67
68
|
- lib/nexus_semantic_logger/datadog_formatter.rb
|
68
69
|
- lib/nexus_semantic_logger/version.rb
|
@@ -78,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
79
|
requirements:
|
79
80
|
- - ">="
|
80
81
|
- !ruby/object:Gem::Version
|
81
|
-
version:
|
82
|
+
version: 2.7.0
|
82
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
84
|
requirements:
|
84
85
|
- - ">="
|