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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1a573d8c1b9f662b10579d8d01acc4f231b7af96d0f0ae27e1f3e86a684396b
4
- data.tar.gz: '093c2473b85281b5da27fb1b19acf75c23ccf82fedf529fe404f16b22d82a07d'
3
+ metadata.gz: 62b597731a526635002f05d2c12bd7a47992bad26ec2718e0fc5cfa9048ed856
4
+ data.tar.gz: a032f4272f7a1bd326c6ae62784d7ff68e5c1cd64af67bddac750f1770d3bed0
5
5
  SHA512:
6
- metadata.gz: 3688e7175ff82e4057681aabacbd6337e80bc874700c48259be630d38007d2e773a0527680e99b5fa949a780b66ec8e06162952f6ae6851592731508114d8281
7
- data.tar.gz: 840d0cfa01334cb3348cdf740db7dc16258a65517b198c46da5b5f9a9f89828323e06547c3650cededc62c1b42b9229741464b8748fe84f58f157bc5652c7f5b
6
+ metadata.gz: '09dd455c9ea23edb7371b50973cb599cbc5f45c876df95799536fe7c2d36a6db7cf55669b44734743489453d1d247847a0b9cf62617a87781c16a833c2f512d6'
7
+ data.tar.gz: 47071f03bfb054bc6b58df26b71d8a57502a0ed2e2e5b7ad30011f5eb8d205cbf9b8adbfeed67d22840cdda0f6a6d7c7c89fb4d3a0fdd0ded6ef2ae57127ef32
@@ -1,6 +1,17 @@
1
1
  version: 2
2
2
  updates:
3
- - package-ecosystem: 'bundler'
4
- directory: '/'
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
5
  schedule:
6
- interval: 'weekly'
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"
@@ -10,12 +10,12 @@ jobs:
10
10
 
11
11
  steps:
12
12
  - name: Checkout current code
13
- uses: actions/checkout@v2
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.1'
18
+ ruby-version: '3.3'
19
19
  bundler-cache: true
20
20
  cache-version: 1
21
21
 
@@ -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.1', '3.0', '2.7', '2.6']
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@v1
30
+ - uses: actions/checkout@v4
31
31
 
32
32
  - name: Set up Ruby
33
33
  uses: ruby/setup-ruby@v1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.4.0 / 2024-07-24
2
+
3
+ * Customized cloud stdout logstash logger
4
+ * Update development dependencies (rake, rspec, standard)
5
+
1
6
  ## 0.3.1 / 2022-07-27
2
7
 
3
8
  * Update homepage url in gemspec file
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
 
@@ -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.0"
21
- spec.add_development_dependency "rspec", "~> 3.11"
22
- spec.add_development_dependency "standard", "~> 1.14"
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
@@ -22,7 +22,7 @@ class EventHub::Components::MultiLogger
22
22
  end
23
23
  end
24
24
 
25
- def respond_to_missing?(method)
25
+ def respond_to_missing?(*args)
26
26
  true
27
27
  end
28
28
  end
@@ -49,11 +49,11 @@ class EventHub::Components::StructuredDataLogger
49
49
 
50
50
  private
51
51
 
52
- def method_missing(method, *args, &block)
53
- target.send(method, *args, &block)
52
+ def method_missing(...)
53
+ target.send(...)
54
54
  end
55
55
 
56
- def respond_to_missing?(method)
56
+ def respond_to_missing?(*args)
57
57
  true
58
58
  end
59
59
 
@@ -1,5 +1,5 @@
1
1
  module EventHub
2
2
  module Components
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -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.3.1
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: 2022-07-27 00:00:00.000000000 Z
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.0'
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.0'
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.11'
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.11'
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.14'
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.14'
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.3.7
147
+ rubygems_version: 3.5.11
147
148
  signing_key:
148
149
  specification_version: 4
149
150
  summary: Additional eventhub components