google_cloud_logging_extension 0.1.2 → 0.1.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c4364ae0366f10cd54af70bfe275f3e6416d6b03c4aebe8c65e46396152f89f
|
4
|
+
data.tar.gz: 235fe8d2d14da9de75fd949d4d7e43414a8bc2b1dc14e7e2f6f0083a0b1aed48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71ba0bd59b1ef7243a1310995045d607b9f7e19c096e38d92b1211ca7b8598e8673bce1d370e447643113947dfb84372c8c16c4b1b4a55a7f423ae3799c0ba1d
|
7
|
+
data.tar.gz: 062d8a386fe74ff109c4b8cef5010361319b9c97f7b332b059e1e485d44f098a7a53a2bc6ba73615ceb5aaf15dcbe9aeed837535231f9e0c513e6b0d7fa93293
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
google_cloud_logging_extension (0.1.
|
4
|
+
google_cloud_logging_extension (0.1.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -83,7 +83,7 @@ GEM
|
|
83
83
|
kramdown (~> 2.0)
|
84
84
|
memoist (0.16.2)
|
85
85
|
multi_json (1.15.0)
|
86
|
-
multipart-post (2.
|
86
|
+
multipart-post (2.2.0)
|
87
87
|
nokogiri (1.13.6-arm64-darwin)
|
88
88
|
racc (~> 1.4)
|
89
89
|
os (1.1.4)
|
@@ -137,7 +137,7 @@ GEM
|
|
137
137
|
tilt (2.0.10)
|
138
138
|
unicode-display_width (2.1.0)
|
139
139
|
webrick (1.7.0)
|
140
|
-
yard (0.9.
|
140
|
+
yard (0.9.28)
|
141
141
|
webrick (~> 1.7.0)
|
142
142
|
|
143
143
|
PLATFORMS
|
@@ -8,13 +8,16 @@ module Google
|
|
8
8
|
module Convert
|
9
9
|
class << self
|
10
10
|
# @param [Exception] exception
|
11
|
-
def exception_to_hash(exception)
|
12
|
-
{
|
11
|
+
def exception_to_hash(exception, root: false)
|
12
|
+
hash = {
|
13
13
|
class: exception.class.name,
|
14
|
-
message: exception.
|
14
|
+
message: exception.full_message(highlight: false),
|
15
|
+
summary: exception.message,
|
15
16
|
backtrace: exception.backtrace,
|
16
17
|
cause: exception.cause.is_a?(Exception) ? exception_to_hash(exception.cause) : exception.cause
|
17
18
|
}
|
19
|
+
hash['@type'] = 'type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent' if root
|
20
|
+
hash
|
18
21
|
end
|
19
22
|
|
20
23
|
alias object_to_value_default object_to_value
|
@@ -30,6 +33,8 @@ module Google
|
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
36
|
+
DEFAULT_REDIRECTS = []
|
37
|
+
|
33
38
|
def self.create(log_name, resource_type = 'gce_project', **labels)
|
34
39
|
logging = Google::Cloud::Logging.new
|
35
40
|
writer = logging.async_writer(max_queue_size: 1000)
|
@@ -38,16 +43,55 @@ module Google
|
|
38
43
|
level = labels[:level]
|
39
44
|
labels.delete(:level)
|
40
45
|
end
|
46
|
+
if labels.key?(:redirects)
|
47
|
+
redirects = labels[:redirects]
|
48
|
+
labels.delete(:redirects)
|
49
|
+
redirects = [redirects] unless redirects.is_a?(Array)
|
50
|
+
redirects.compact!
|
51
|
+
end
|
52
|
+
unless DEFAULT_REDIRECTS.empty?
|
53
|
+
if redirects
|
54
|
+
redirects += DEFAULT_REDIRECTS
|
55
|
+
else
|
56
|
+
redirects = DEFAULT_REDIRECTS.dup
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
41
60
|
logger = Google::Cloud::Logging::Logger.new(writer, log_name, resource, labels)
|
42
61
|
logger.level = level if level
|
62
|
+
|
63
|
+
if redirects
|
64
|
+
redirects.map! do |e|
|
65
|
+
case e
|
66
|
+
when :stdout
|
67
|
+
::Logger.new($stdout, progname: labels[:module] || log_name, level: logger.level)
|
68
|
+
when :stderr
|
69
|
+
::Logger.new($stderr, progname: labels[:module] || log_name, level: logger.level)
|
70
|
+
else
|
71
|
+
e
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
logger.instance_variable_set(:@redirects, redirects)
|
76
|
+
end
|
77
|
+
|
43
78
|
logger
|
44
79
|
end
|
45
80
|
|
81
|
+
class Logger
|
82
|
+
alias add_default add
|
83
|
+
def add(severity, message = nil, progname = nil)
|
84
|
+
derived_severity = derive_severity(severity) || ::Logger::UNKNOWN
|
85
|
+
@redirects&.each {|e| e.add(derived_severity, message, progname)}
|
86
|
+
add_default(severity, message, progname)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
46
90
|
class Entry
|
47
91
|
def payload=(payload)
|
48
92
|
@payload = case payload
|
49
93
|
when Exception
|
50
|
-
Google::Cloud::Logging::Convert.exception_to_hash(payload)
|
94
|
+
Google::Cloud::Logging::Convert.exception_to_hash(payload, root: true)
|
51
95
|
else
|
52
96
|
payload
|
53
97
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_cloud_logging_extension
|
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
|
- Ishotihadus
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Extension of google-cloud-logging-gem.
|
14
14
|
email:
|