google_cloud_logging_extension 0.1.1 → 0.1.4

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: 0b531e0aa67e857eef2b2d35905a937f4705ce9db98f87dc9a9931eb2d97290e
4
- data.tar.gz: 6b6b600fae4e9df160c5fde311c521a497e6c4b509e97ae915d0c730b6ec4124
3
+ metadata.gz: 74bb3c2a1f4a5a750b1c6879afc7539c0648a942bca0835cbe5cfa16cccea7f8
4
+ data.tar.gz: f95a3897eb396963d49c279ec8df360514b01477fb45918f8ff1855df0645001
5
5
  SHA512:
6
- metadata.gz: cbf33b877249a68db0980097ec856979c4201e97ace5e109d03e0ee2a9aca13ad8c2f884c9fd81f125bf0254d872cf17cecc109b31dd91456ebf6dbd084542eb
7
- data.tar.gz: 5a761abb9bcc6268218aafcd51a71a884040fc8f162d5cc6b788731a5383487942ed23b124bb59019271d88cea5244f3dcfbec3e87e6feeabbba3b3c907a3d01
6
+ metadata.gz: f901b1191fd5df3d049e39f52a12172a07fa923d38dfbef3fe7a2ffc9db2d0d8ac874af782d349fb5091ee06eacb947e465fac43acb3e4ae07b844f3bb89e60f
7
+ data.tar.gz: 2a93ebd65b37fc124774d1f193996fa46de73f1570bd53629210d3b60e9f2ff08def09cc5feccc1ca18882fe420615bcfa54abdaaf058976c9bd159aba9c4b86
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- google_cloud_logging_extension (0.1.0)
4
+ google_cloud_logging_extension (0.1.3)
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.1.1)
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.27)
140
+ yard (0.9.28)
141
141
  webrick (~> 1.7.0)
142
142
 
143
143
  PLATFORMS
@@ -1,18 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'google/cloud/logging'
4
+
3
5
  module Google
4
6
  module Cloud
5
7
  module Logging
6
8
  module Convert
7
9
  class << self
8
10
  # @param [Exception] exception
9
- def exception_to_hash(exception)
10
- {
11
+ def exception_to_hash(exception, root: false)
12
+ hash = {
11
13
  class: exception.class.name,
12
- message: exception.message,
14
+ message: exception.full_message(highlight: false),
15
+ summary: exception.message,
13
16
  backtrace: exception.backtrace,
14
17
  cause: exception.cause.is_a?(Exception) ? exception_to_hash(exception.cause) : exception.cause
15
18
  }
19
+ hash['@type'] = 'type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent' if root
20
+ hash
16
21
  end
17
22
 
18
23
  alias object_to_value_default object_to_value
@@ -36,16 +41,48 @@ module Google
36
41
  level = labels[:level]
37
42
  labels.delete(:level)
38
43
  end
44
+ if labels.key?(:redirects)
45
+ redirects = labels[:redirects]
46
+ labels.delete(:redirects)
47
+ end
39
48
  logger = Google::Cloud::Logging::Logger.new(writer, log_name, resource, labels)
40
49
  logger.level = level if level
50
+
51
+ if redirects
52
+ redirects = [redirects] unless redirects.is_a?(Array)
53
+ redirects.compact!
54
+
55
+ redirects.map! do |e|
56
+ case e
57
+ when :stdout
58
+ ::Logger.new($stdout, progname: labels[:module] || log_name, level: logger.level)
59
+ when :stderr
60
+ ::Logger.new($stderr, progname: labels[:module] || log_name, level: logger.level)
61
+ else
62
+ e
63
+ end
64
+ end
65
+
66
+ logger.instance_variable_set(:@redirects, redirects)
67
+ end
68
+
41
69
  logger
42
70
  end
43
71
 
72
+ class Logger
73
+ alias add_default add
74
+ def add(severity, message = nil, progname = nil)
75
+ derived_severity = derive_severity(severity) || ::Logger::UNKNOWN
76
+ @redirects&.each {|e| e.add(derived_severity, message, progname)}
77
+ add_default(severity, message, progname)
78
+ end
79
+ end
80
+
44
81
  class Entry
45
82
  def payload=(payload)
46
83
  @payload = case payload
47
84
  when Exception
48
- Google::Cloud::Logging::Convert.exception_to_hash(payload)
85
+ Google::Cloud::Logging::Convert.exception_to_hash(payload, root: true)
49
86
  else
50
87
  payload
51
88
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoogleCloudLoggingExtension
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.4'
5
5
  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.1
4
+ version: 0.1.4
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-02 00:00:00.000000000 Z
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: