lsslog 0.1.7 → 0.1.7.1
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/services/v2.rb +64 -0
- data/lib/lsslog/v2/log.rb +64 -0
- data/lib/lsslog/version.rb +1 -1
- data/lsslog-0.1.7.gem +0 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24b6c0d3edd020f2d9d8527691fed2e5cb7a820a26243a0cc1c8438dd97a900d
|
4
|
+
data.tar.gz: 2f6451ed62719c71a9981c335916ac79a369114b1c3b4be8cfdec5787bc7a1e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e329ef42a2419c148a35e3f2fd976b9ac8c6fbacf102eb3e99e39527340dfb861f7e045136bd5c3d57e640b733e946c4707ca03dbff4aa682b522084766a5fd
|
7
|
+
data.tar.gz: b149a28e7aa28712cfbfbe0919c66ad8e814deb28e1b4a0f2daf04bc749374b9ab5168ac60c5069c0fa876e65a1195b5889828d90923b0d9b3a444be96f444a1
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'grpc'
|
2
|
+
require 'lsslog_services_pb'
|
3
|
+
|
4
|
+
module Lsslog
|
5
|
+
module Services
|
6
|
+
class V2
|
7
|
+
def initialize
|
8
|
+
@stub = Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
|
9
|
+
end
|
10
|
+
|
11
|
+
def log(message_h:, severity:, component: '', api: '')
|
12
|
+
message_struct = hash_to_struct(message_h)
|
13
|
+
|
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
|
+
)
|
21
|
+
|
22
|
+
Rails.logger.info("Sending LSS log. Message:[#{message_h}]")
|
23
|
+
|
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
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def lss_host
|
34
|
+
@lss_host ||= ::Lsslog.configuration.lss_host
|
35
|
+
raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
|
36
|
+
|
37
|
+
@lss_host
|
38
|
+
end
|
39
|
+
|
40
|
+
def hash_to_struct(hash)
|
41
|
+
Google::Protobuf::Struct.new(fields: hash.transform_values { |v| to_proto_value(v) })
|
42
|
+
end
|
43
|
+
|
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)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'grpc'
|
2
|
+
require 'lsslog_services_pb'
|
3
|
+
|
4
|
+
module Lsslog
|
5
|
+
module V2
|
6
|
+
class Service
|
7
|
+
def initialize
|
8
|
+
@stub = Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
|
9
|
+
end
|
10
|
+
|
11
|
+
def log(message_h:, severity:, component: '', api: '')
|
12
|
+
message_struct = hash_to_struct(message_h)
|
13
|
+
|
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
|
+
)
|
21
|
+
|
22
|
+
Rails.logger.info("Sending LSS log. Message:[#{message_h}]")
|
23
|
+
|
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
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def lss_host
|
34
|
+
@lss_host ||= ::Lsslog.configuration.lss_host
|
35
|
+
raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
|
36
|
+
|
37
|
+
@lss_host
|
38
|
+
end
|
39
|
+
|
40
|
+
def hash_to_struct(hash)
|
41
|
+
Google::Protobuf::Struct.new(fields: hash.transform_values { |v| to_proto_value(v) })
|
42
|
+
end
|
43
|
+
|
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)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/lsslog/version.rb
CHANGED
data/lsslog-0.1.7.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lsslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.7
|
4
|
+
version: 0.1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thanh Ngo
|
@@ -101,8 +101,10 @@ files:
|
|
101
101
|
- lib/lsslog/services/remove_lss_config.rb
|
102
102
|
- lib/lsslog/services/set_lss_config.rb
|
103
103
|
- lib/lsslog/services/set_trans_exp_time.rb
|
104
|
+
- lib/lsslog/services/v2.rb
|
104
105
|
- lib/lsslog/services/write_log.rb
|
105
106
|
- lib/lsslog/services/write_prod_transaction.rb
|
107
|
+
- lib/lsslog/v2/log.rb
|
106
108
|
- lib/lsslog/version.rb
|
107
109
|
- lib/lsslog_pb.rb
|
108
110
|
- lib/lsslog_services_pb.rb
|
@@ -112,6 +114,7 @@ files:
|
|
112
114
|
- lsslog-0.1.3.pre.rc1.gem
|
113
115
|
- lsslog-0.1.5.gem
|
114
116
|
- lsslog-0.1.6.gem
|
117
|
+
- lsslog-0.1.7.gem
|
115
118
|
- lsslog.gemspec
|
116
119
|
- proto/README.md
|
117
120
|
- proto/lsslog.proto
|