eventhub-components 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -3
- data/.github/workflows/cd.yml +2 -2
- data/.github/workflows/ci.yml +3 -3
- data/CHANGELOG.md +5 -0
- data/README.md +3 -3
- data/eventhub-components.gemspec +3 -3
- data/lib/eventhub/components/logger.rb +19 -0
- data/lib/eventhub/components/multi_logger.rb +1 -1
- data/lib/eventhub/components/structured_data_logger.rb +3 -3
- data/lib/eventhub/components/version.rb +1 -1
- data/spec/components/log_formatter_spec.rb +8 -0
- data/spec/components/multi_logger_spec.rb +15 -0
- data/spec/components/structured_data_logger_spec.rb +11 -0
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62b597731a526635002f05d2c12bd7a47992bad26ec2718e0fc5cfa9048ed856
|
4
|
+
data.tar.gz: a032f4272f7a1bd326c6ae62784d7ff68e5c1cd64af67bddac750f1770d3bed0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09dd455c9ea23edb7371b50973cb599cbc5f45c876df95799536fe7c2d36a6db7cf55669b44734743489453d1d247847a0b9cf62617a87781c16a833c2f512d6'
|
7
|
+
data.tar.gz: 47071f03bfb054bc6b58df26b71d8a57502a0ed2e2e5b7ad30011f5eb8d205cbf9b8adbfeed67d22840cdda0f6a6d7c7c89fb4d3a0fdd0ded6ef2ae57127ef32
|
data/.github/dependabot.yml
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
version: 2
|
2
2
|
updates:
|
3
|
-
- package-ecosystem:
|
4
|
-
directory:
|
3
|
+
- package-ecosystem: "bundler"
|
4
|
+
directory: "/"
|
5
5
|
schedule:
|
6
|
-
interval:
|
6
|
+
interval: "weekly"
|
7
|
+
day: "saturday"
|
8
|
+
time: "04:05"
|
9
|
+
timezone: "Europe/Zurich"
|
10
|
+
|
11
|
+
- package-ecosystem: "github-actions"
|
12
|
+
directory: "/"
|
13
|
+
schedule:
|
14
|
+
interval: "weekly"
|
15
|
+
day: "saturday"
|
16
|
+
time: "04:05"
|
17
|
+
timezone: "Europe/Zurich"
|
data/.github/workflows/cd.yml
CHANGED
@@ -10,12 +10,12 @@ jobs:
|
|
10
10
|
|
11
11
|
steps:
|
12
12
|
- name: Checkout current code
|
13
|
-
uses: actions/checkout@
|
13
|
+
uses: actions/checkout@v4
|
14
14
|
|
15
15
|
- name: Set up Ruby
|
16
16
|
uses: ruby/setup-ruby@v1
|
17
17
|
with:
|
18
|
-
ruby-version: '3.
|
18
|
+
ruby-version: '3.3'
|
19
19
|
bundler-cache: true
|
20
20
|
cache-version: 1
|
21
21
|
|
data/.github/workflows/ci.yml
CHANGED
@@ -10,7 +10,7 @@ on:
|
|
10
10
|
- "*"
|
11
11
|
|
12
12
|
schedule:
|
13
|
-
- cron: 0 2 * *
|
13
|
+
- cron: 0 2 * * 3,6
|
14
14
|
|
15
15
|
# Allows you to run this workflow manually from the Actions tab
|
16
16
|
workflow_dispatch:
|
@@ -23,11 +23,11 @@ jobs:
|
|
23
23
|
strategy:
|
24
24
|
fail-fast: false
|
25
25
|
matrix:
|
26
|
-
ruby: [ '3.
|
26
|
+
ruby: [ '3.3', '3.2', '3.1', '3.0']
|
27
27
|
|
28
28
|
name: Ruby ${{ matrix.ruby }}
|
29
29
|
steps:
|
30
|
-
- uses: actions/checkout@
|
30
|
+
- uses: actions/checkout@v4
|
31
31
|
|
32
32
|
- name: Set up Ruby
|
33
33
|
uses: ruby/setup-ruby@v1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,10 +11,10 @@ Incldues logging, exception writing and pid file facilities for event hub proces
|
|
11
11
|
|
12
12
|
Currently supported and tested ruby versions are:
|
13
13
|
|
14
|
+
- 3.3
|
15
|
+
- 3.2
|
14
16
|
- 3.1
|
15
|
-
- 3.0
|
16
|
-
- 2.7
|
17
|
-
- 2.6
|
17
|
+
- 3.0 (EOL April 23 2024, is not part of CI anymore)
|
18
18
|
|
19
19
|
## Installation
|
20
20
|
|
data/eventhub-components.gemspec
CHANGED
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_development_dependency "bundler", "~> 2.1"
|
20
|
-
spec.add_development_dependency "rake", "~> 13.
|
21
|
-
spec.add_development_dependency "rspec", "~> 3.
|
22
|
-
spec.add_development_dependency "standard", "~> 1.
|
20
|
+
spec.add_development_dependency "rake", "~> 13.2"
|
21
|
+
spec.add_development_dependency "rspec", "~> 3.13"
|
22
|
+
spec.add_development_dependency "standard", "~> 1.39"
|
23
23
|
spec.add_development_dependency "simplecov", "~> 0.21"
|
24
24
|
|
25
25
|
spec.add_runtime_dependency "logstash-logger", "~> 0.26"
|
@@ -18,4 +18,23 @@ class EventHub::Components::Logger
|
|
18
18
|
end
|
19
19
|
LogStashLogger.new([{type: :file, path: "logs/ruby/#{processor_name}.log", sync: true}])
|
20
20
|
end
|
21
|
+
|
22
|
+
def self.logstash_cloud(processor_name, environment)
|
23
|
+
# configure logstash with custom fields
|
24
|
+
LogStashLogger.configure do |config|
|
25
|
+
config.customize_event do |event|
|
26
|
+
# renaming default fields to be eventhub cloud compatible
|
27
|
+
event["time"] = event.remove("@timestamp")
|
28
|
+
event["msg"] = event.remove("message")
|
29
|
+
event["level"] = event.remove("severity")
|
30
|
+
event["host"] = event.remove("host") # reordering
|
31
|
+
event.remove("@version") # not needed
|
32
|
+
|
33
|
+
# additional fields
|
34
|
+
event["app"] = processor_name
|
35
|
+
event["env"] = environment
|
36
|
+
end
|
37
|
+
end
|
38
|
+
LogStashLogger.new([{type: :stdout}])
|
39
|
+
end
|
21
40
|
end
|
@@ -49,11 +49,11 @@ class EventHub::Components::StructuredDataLogger
|
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
-
def method_missing(
|
53
|
-
target.send(
|
52
|
+
def method_missing(...)
|
53
|
+
target.send(...)
|
54
54
|
end
|
55
55
|
|
56
|
-
def respond_to_missing?(
|
56
|
+
def respond_to_missing?(*args)
|
57
57
|
true
|
58
58
|
end
|
59
59
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative "../spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe EventHub::Components::StructuredDataLogger do
|
4
|
+
let!(:logger) { EventHub::Components::LogFormatter.new }
|
5
|
+
it "formats logs" do
|
6
|
+
expect(logger.call("ERROR", Time.now, "rspec", "just a message")).to match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d+\t\d+\tERROR\tjust a message\n$/)
|
7
|
+
end
|
8
|
+
end
|
@@ -56,5 +56,20 @@ RSpec.describe EventHub::Components::StructuredDataLogger do
|
|
56
56
|
logger.info("Yes, it works2!")
|
57
57
|
expect(File.read("logs/ruby/processor.log")).to match(/Yes, it works2!/)
|
58
58
|
end
|
59
|
+
|
60
|
+
it "response to an unknown method" do
|
61
|
+
expect(logger.respond_to?(:whatever)).to eq(true)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "logs json to standard output" do
|
65
|
+
pattern = /\{"time":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{2}:\d{2}","msg":"hello","level":"(INFO|WARN|ERROR|DEBUG|FATAL)","host":"[^\"]+","app":"processor","env":"development"\}/
|
66
|
+
|
67
|
+
logger.add_device(EventHub::Components::Logger.logstash_cloud("processor", "development"))
|
68
|
+
expect { logger.info("hello") }.to output(pattern).to_stdout_from_any_process
|
69
|
+
expect { logger.warn("hello") }.to output(pattern).to_stdout_from_any_process
|
70
|
+
expect { logger.error("hello") }.to output(pattern).to_stdout_from_any_process
|
71
|
+
expect { logger.debug("hello") }.to output(pattern).to_stdout_from_any_process
|
72
|
+
expect { logger.fatal("hello") }.to output(pattern).to_stdout_from_any_process
|
73
|
+
end
|
59
74
|
end
|
60
75
|
end
|
@@ -86,4 +86,15 @@ RSpec.describe EventHub::Components::StructuredDataLogger do
|
|
86
86
|
expect(logger[:fatal]).to eq(expectation)
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
context "unknown methods" do
|
91
|
+
let(:logger) { EventHub::Components::StructuredDataLogger.new("something not nil", "app_name" => "an app", "env" => "test") }
|
92
|
+
it "response to an unknown method" do
|
93
|
+
expect(logger.respond_to?(:whatever)).to eq(true)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "can call an unknown method" do
|
97
|
+
expect { logger.size }.not_to raise_error
|
98
|
+
end
|
99
|
+
end
|
89
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventhub-components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steiner, Thomas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,42 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '13.
|
33
|
+
version: '13.2'
|
34
34
|
type: :development
|
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: '13.
|
40
|
+
version: '13.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.13'
|
48
48
|
type: :development
|
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: '3.
|
54
|
+
version: '3.13'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: standard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.39'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.39'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/eventhub/components/structured_data_logger.rb
|
121
121
|
- lib/eventhub/components/version.rb
|
122
122
|
- spec/components/exception_writer_spec.rb
|
123
|
+
- spec/components/log_formatter_spec.rb
|
123
124
|
- spec/components/multi_logger_spec.rb
|
124
125
|
- spec/components/pid_file_spec.rb
|
125
126
|
- spec/components/structured_data_logger_spec.rb
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
requirements: []
|
146
|
-
rubygems_version: 3.
|
147
|
+
rubygems_version: 3.5.11
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: Additional eventhub components
|