lsslog 0.1.7.3 → 0.1.7.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of lsslog might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/lsslog/v2/log.rb +45 -47
- data/lib/lsslog/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45af497aead3a63d0421a1232f375324d58e76efce648b857682d1ae68e186bb
|
4
|
+
data.tar.gz: cb82998326af48c6ce3169e4c82f1a77d760cf5455f9a5e0960c62fee00f3042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cf6cd3ace2d9f2c14a2b3c6ad6e35a3833d52320cc5447039a640f6b8ed838a72cb75b4eea214d19d1e41b5cb00baccff2d4be62554b90900b7dcf463b374e1
|
7
|
+
data.tar.gz: 6653e1f22e72010afd43c82f931e586102c6b24c220fcdd85785d41bddff2d31425f8a99dfd501f3d2f183ce26a539b81ad76178ecdb45216ad71cb227868161
|
data/lib/lsslog/v2/log.rb
CHANGED
@@ -3,62 +3,60 @@ require 'lsslog_services_pb'
|
|
3
3
|
|
4
4
|
module Lsslog
|
5
5
|
module V2
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
6
|
+
class Service
|
7
|
+
def initialize
|
8
|
+
@stub = Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
def log(message_h:, severity:, component: '', api: '')
|
12
|
+
message_struct = hash_to_struct(message_h)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
log_ver2 = Lsslog::LogVer2.new(
|
15
|
+
severity: severity,
|
16
|
+
timestamp: Time.now.utc.iso8601,
|
17
|
+
api: api,
|
18
|
+
component: component,
|
19
|
+
message: message_struct
|
20
|
+
)
|
22
21
|
|
23
|
-
|
22
|
+
Rails.logger.info("Sending LSS log. Message:[#{message_h}]")
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
response = @stub.log(log_ver2, deadline: Time.now + 5)
|
25
|
+
response
|
26
|
+
rescue GRPC::BadStatus => e
|
27
|
+
Rails.logger.error("Error sending LSS log: #{e.message}")
|
28
|
+
nil
|
29
|
+
end
|
31
30
|
|
32
|
-
|
31
|
+
private
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
def lss_host
|
34
|
+
@lss_host ||= ::Lsslog.configuration.lss_host
|
35
|
+
raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
|
37
36
|
|
38
|
-
|
39
|
-
|
37
|
+
@lss_host
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
def hash_to_struct(hash)
|
41
|
+
Google::Protobuf::Struct.new(fields: hash.transform_values { |v| to_proto_value(v) })
|
42
|
+
end
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
44
|
+
def to_proto_value(value)
|
45
|
+
case value
|
46
|
+
when String
|
47
|
+
Google::Protobuf::Value.new(string_value: value)
|
48
|
+
when Numeric
|
49
|
+
Google::Protobuf::Value.new(number_value: value)
|
50
|
+
when TrueClass, FalseClass
|
51
|
+
Google::Protobuf::Value.new(bool_value: value)
|
52
|
+
when Hash
|
53
|
+
Google::Protobuf::Value.new(struct_value: hash_to_struct(value))
|
54
|
+
when Array
|
55
|
+
Google::Protobuf::Value.new(list_value: Google::Protobuf::ListValue.new(values: value.map { |v| to_proto_value(v) }))
|
56
|
+
when NilClass
|
57
|
+
Google::Protobuf::Value.new(null_value: :NULL_VALUE)
|
58
|
+
else
|
59
|
+
Google::Protobuf::Value.new(string_value: value.to_s)
|
62
60
|
end
|
63
61
|
end
|
64
62
|
end
|
data/lib/lsslog/version.rb
CHANGED