minato_logger 0.1.13.pre.2 → 0.1.13.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/minato_logger/configuration.rb +21 -0
- data/lib/minato_logger/formatters/fluent_bit.rb +7 -14
- data/lib/minato_logger/middleware.rb +15 -0
- data/lib/minato_logger/rails.rb +2 -0
- data/lib/minato_logger/version.rb +1 -1
- data/lib/minato_logger.rb +22 -4
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8912274da7dd77fae6f70e2236079b5ed24df2aef0326ef1cd0467aed0cd2dcc
|
4
|
+
data.tar.gz: 9fe88a71c8273fa4945b74d3d640761b6fc8bfb2c2bca0ae63e25cfb3b82fc2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7974899c02eee1e4f366b3391fbbb3c386dbbea2870ce4bc2f61396e4baf495c8b8bac7c32d9239e5b588e8646128e9a8b3f495c3897a5ce19592091a922ec7
|
7
|
+
data.tar.gz: 604ff2aabe0ee95c8f7f748026baa9b9abda1ad6bea00ac698550c686a6d4bc73d962902c30b2d77e0000e7f19f6b1e2e664d7535e46183c1712891ccd7107b6
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MinatoLogger
|
4
|
+
class Configuration
|
5
|
+
attr_reader :middleware
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@middleware = MinatoLogger::Middleware.new
|
9
|
+
|
10
|
+
yield(self) if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.default
|
14
|
+
@default ||= Configuration.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def configure
|
18
|
+
yield(self) if block_given?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "active_support/tagged_logging"
|
4
|
-
require "json"
|
5
4
|
require "google/cloud/trace"
|
6
|
-
require "
|
5
|
+
require "json"
|
7
6
|
|
8
7
|
module MinatoLogger
|
9
8
|
module Formatters
|
@@ -12,25 +11,19 @@ module MinatoLogger
|
|
12
11
|
|
13
12
|
def call(severity, timestamp, _progname, message)
|
14
13
|
log = add_message_to_logs({ severity: severity, time: timestamp }, message)
|
15
|
-
log =
|
14
|
+
log = apply_middlewares(log)
|
16
15
|
|
17
16
|
"#{log.to_json}\n"
|
18
17
|
end
|
19
18
|
|
20
19
|
private
|
21
20
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
_trace_client = Google::Cloud::Trace.new
|
27
|
-
trace_result = Google::Cloud::Trace.get
|
28
|
-
return log if trace_result.nil?
|
29
|
-
|
30
|
-
trace_log = "projects/#{trace_result.trace.project_id}/traces/#{trace_result.trace.trace_id}"
|
21
|
+
def apply_middlewares(log)
|
22
|
+
MinatoLogger.config.middleware.middlewares.each do |middleware|
|
23
|
+
log = middleware.new.call(log)
|
24
|
+
end
|
31
25
|
|
32
|
-
log
|
33
|
-
"logging.googleapis.com/spanId": trace_result.span_id.to_s })
|
26
|
+
log
|
34
27
|
end
|
35
28
|
|
36
29
|
def add_message_to_logs(log, message)
|
data/lib/minato_logger/rails.rb
CHANGED
data/lib/minato_logger.rb
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
require "minato_logger/version"
|
4
|
+
require "minato_logger/middleware"
|
5
|
+
require "minato_logger/configuration"
|
6
|
+
require "minato_logger/formatters"
|
7
|
+
require "minato_logger/logger"
|
8
|
+
require "minato_logger/rails" if defined? Rails::Railtie
|
9
|
+
|
10
|
+
module MinatoLogger
|
11
|
+
class << self
|
12
|
+
def configure
|
13
|
+
if block_given?
|
14
|
+
yield(Configuration.default)
|
15
|
+
else
|
16
|
+
Configuration.default
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def config
|
21
|
+
@config ||= Configuration.default
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minato_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.13.pre.
|
4
|
+
version: 0.1.13.pre.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferreri
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -70,10 +70,12 @@ files:
|
|
70
70
|
- Rakefile
|
71
71
|
- compose.yml
|
72
72
|
- lib/minato_logger.rb
|
73
|
+
- lib/minato_logger/configuration.rb
|
73
74
|
- lib/minato_logger/formatters.rb
|
74
75
|
- lib/minato_logger/formatters/base_formatter.rb
|
75
76
|
- lib/minato_logger/formatters/fluent_bit.rb
|
76
77
|
- lib/minato_logger/logger.rb
|
78
|
+
- lib/minato_logger/middleware.rb
|
77
79
|
- lib/minato_logger/rails.rb
|
78
80
|
- lib/minato_logger/version.rb
|
79
81
|
- minato_logger.gemspec
|