minato_logger 0.1.13.pre.3 → 0.1.13.pre.5
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/base_formatter.rb +1 -0
- data/lib/minato_logger/formatters/fluent_bit.rb +20 -9
- data/lib/minato_logger/middleware.rb +15 -0
- data/lib/minato_logger/rails.rb +2 -6
- data/lib/minato_logger/version.rb +1 -1
- data/lib/minato_logger.rb +17 -13
- 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: 7673fcdba540e6485a39fccf31e2bd4ede8239b07ba7d0555c972f8dcb56f77e
|
4
|
+
data.tar.gz: a338ab6a4d99d3ba5efdbf706d2c68f2641adaca413d0517cfab57864c84578e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45f4a901a5be41467bc4a94138a743fbd2775dcc518ef1bdfc72b171b8ee9d6b7663e11f5b3615247e016361487d54f4555df7077c413d372953ae84ed666ea1
|
7
|
+
data.tar.gz: 6d4537ff78aaeba4aab55a963a5ddf5860dfe9870a60c935c244513a70ec2b3c006ec52342aef4d762840b60d5c74a582ba3a42448745588c580365ec034a1be
|
@@ -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,27 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "active_support/tagged_logging"
|
4
|
-
require "google/cloud/trace"
|
5
3
|
require "json"
|
6
4
|
|
7
5
|
module MinatoLogger
|
8
6
|
module Formatters
|
9
7
|
class FluentBit < BaseFormatter
|
10
|
-
include ActiveSupport::TaggedLogging::Formatter
|
11
|
-
|
12
8
|
def call(severity, timestamp, _progname, message)
|
13
|
-
|
14
|
-
log =
|
9
|
+
tagged_message = add_tags_to_message(message)
|
10
|
+
log = add_message_to_logs({ severity: severity, time: timestamp }, tagged_message)
|
11
|
+
log = apply_middlewares(log)
|
15
12
|
|
16
13
|
"#{log.to_json}\n"
|
17
14
|
end
|
18
15
|
|
19
16
|
private
|
20
17
|
|
21
|
-
def
|
22
|
-
|
18
|
+
def apply_middlewares(log)
|
19
|
+
MinatoLogger.config.middleware.middlewares.each do |middleware|
|
20
|
+
log = middleware.new.call(log)
|
21
|
+
end
|
23
22
|
|
24
|
-
|
23
|
+
log
|
25
24
|
end
|
26
25
|
|
27
26
|
def add_message_to_logs(log, message)
|
@@ -29,6 +28,18 @@ module MinatoLogger
|
|
29
28
|
|
30
29
|
log.merge({ message: message, ruby_version: RUBY_VERSION })
|
31
30
|
end
|
31
|
+
|
32
|
+
def add_tags_to_message(msg)
|
33
|
+
return msg unless tags_text.present?
|
34
|
+
|
35
|
+
if msg.is_a?(Hash)
|
36
|
+
msg["message"] = "#{tags_text} #{msg["message"]}"
|
37
|
+
else
|
38
|
+
msg = "#{tags_text} #{msg}"
|
39
|
+
end
|
40
|
+
|
41
|
+
msg
|
42
|
+
end
|
32
43
|
end
|
33
44
|
end
|
34
45
|
end
|
data/lib/minato_logger/rails.rb
CHANGED
@@ -2,14 +2,10 @@
|
|
2
2
|
|
3
3
|
module MinatoLogger
|
4
4
|
class Railtie < ::Rails::Railtie
|
5
|
-
config.minato_logger =
|
5
|
+
config.minato_logger = MinatoLogger::Configuration.default
|
6
6
|
|
7
7
|
config.after_initialize do |app|
|
8
|
-
app.config.colorize_logging = false
|
9
|
-
|
10
|
-
MinatoLogger.configure do |config|
|
11
|
-
config.trace_logs = app.config.minato_logger.trace_logs
|
12
|
-
end
|
8
|
+
app.config.colorize_logging = false if Rails.env.production?
|
13
9
|
end
|
14
10
|
end
|
15
11
|
end
|
data/lib/minato_logger.rb
CHANGED
@@ -1,20 +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
|
7
9
|
|
8
10
|
module MinatoLogger
|
9
|
-
class
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
class << self
|
12
|
+
def configure
|
13
|
+
if block_given?
|
14
|
+
yield(Configuration.default)
|
15
|
+
else
|
16
|
+
Configuration.default
|
17
|
+
end
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
20
|
+
def config
|
21
|
+
@config ||= Configuration.default
|
22
|
+
end
|
19
23
|
end
|
20
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferreri
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-01 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
|