unified_logger 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a0ea9e1937937ec836c644c3831302f34b27547cb06bb76a3ef4ccb089e98a90
|
|
4
|
+
data.tar.gz: d5534540295b6ee5521fe095322844e64ff5f3c9da528dec743e6919540f956e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e38c0618abb36baf5dfc6fbd308925f78e5dbabf9a5913072bf2fa116936b7ae9519406966db32aaa373efe97ac9a90d7210881a10d378f4efa1cc089b3e7fc0
|
|
7
|
+
data.tar.gz: cbf6d324fa0ce67b90313427c07234b1ec16864f365fbd2c287a5ecbabd4de993ba50a3d8d655e520f96d876c462aed2e2116f9cec9f12c8687334e3993fa36f
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require "English"
|
|
2
|
-
|
|
3
1
|
module UnifiedLogger
|
|
4
2
|
class JobLogger
|
|
5
3
|
DEFAULT_MAX_RETRIES = 5
|
|
@@ -29,16 +27,14 @@ module UnifiedLogger
|
|
|
29
27
|
}
|
|
30
28
|
log[:custom] = UnifiedLogger::Logger.fetch_and_reset_custom_logs if UnifiedLogger::Logger.custom_logs.any?
|
|
31
29
|
|
|
32
|
-
if
|
|
33
|
-
log[:exception] = UnifiedLogger::Logger.format_exception(
|
|
30
|
+
if $!
|
|
31
|
+
log[:exception] = UnifiedLogger::Logger.format_exception($!)
|
|
34
32
|
log[:status] = job.executions >= DEFAULT_MAX_RETRIES ? :error : :warn
|
|
35
33
|
else
|
|
36
34
|
log[:status] = :ok
|
|
37
35
|
end
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
UnifiedLogger.transform_job_log_callable&.call(custom)
|
|
41
|
-
log.merge!(custom)
|
|
37
|
+
UnifiedLogger.transform_job_log_callable&.call(log)
|
|
42
38
|
UnifiedLogger.current_logger.write(UnifiedLogger::Logger.format(log))
|
|
43
39
|
end
|
|
44
40
|
end
|
|
@@ -103,7 +103,7 @@ module UnifiedLogger
|
|
|
103
103
|
|
|
104
104
|
def format(log)
|
|
105
105
|
filtered_log = filter(log)
|
|
106
|
-
formatter = UnifiedLogger.
|
|
106
|
+
formatter = UnifiedLogger.format_log_callable
|
|
107
107
|
formatter.present? ? formatter.call(filtered_log) : filtered_log.to_json
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
require "English"
|
|
2
|
-
|
|
3
1
|
module UnifiedLogger
|
|
4
2
|
class RequestLogger
|
|
5
3
|
def initialize(app)
|
|
@@ -14,9 +12,7 @@ module UnifiedLogger
|
|
|
14
12
|
ensure
|
|
15
13
|
if UnifiedLogger.current_logger.is_a?(UnifiedLogger::Logger) && !silenced?(env["REQUEST_PATH"])
|
|
16
14
|
log = build_log(started, env, status, headers, response)
|
|
17
|
-
|
|
18
|
-
UnifiedLogger.transform_request_log_callable&.call(custom, env)
|
|
19
|
-
log.merge!(custom)
|
|
15
|
+
UnifiedLogger.transform_request_log_callable&.call(log, env)
|
|
20
16
|
UnifiedLogger.current_logger.write(UnifiedLogger::Logger.format(log))
|
|
21
17
|
end
|
|
22
18
|
end
|
|
@@ -59,7 +55,7 @@ module UnifiedLogger
|
|
|
59
55
|
process_id: Process.pid,
|
|
60
56
|
duration: started ? UnifiedLogger.current_time - started : 0
|
|
61
57
|
}
|
|
62
|
-
log[:exception] = UnifiedLogger::Logger.format_exception(
|
|
58
|
+
log[:exception] = UnifiedLogger::Logger.format_exception($!) if $!.present?
|
|
63
59
|
log[:custom] = UnifiedLogger::Logger.fetch_and_reset_custom_logs if UnifiedLogger::Logger.custom_logs.any?
|
|
64
60
|
|
|
65
61
|
log
|
data/lib/unified_logger.rb
CHANGED
|
@@ -34,7 +34,7 @@ module UnifiedLogger
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
class << self
|
|
37
|
-
attr_reader :transform_request_log_callable, :transform_job_log_callable, :
|
|
37
|
+
attr_reader :transform_request_log_callable, :transform_job_log_callable, :format_log_callable
|
|
38
38
|
|
|
39
39
|
def transform_request_log=(callable)
|
|
40
40
|
raise DoubleDefineError, "transform_request_log already defined" if @transform_request_log_callable
|
|
@@ -48,10 +48,10 @@ module UnifiedLogger
|
|
|
48
48
|
@transform_job_log_callable = callable
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def
|
|
52
|
-
raise DoubleDefineError, "
|
|
51
|
+
def format_log=(callable)
|
|
52
|
+
raise DoubleDefineError, "format_log already defined" if @format_log_callable
|
|
53
53
|
|
|
54
|
-
@
|
|
54
|
+
@format_log_callable = callable
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
delegate :trim, :format, :format_exception,
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unified_logger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Marcovecchio
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-03-
|
|
10
|
+
date: 2026-03-24 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|