lsslog 0.1.7 → 0.1.7.2
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.
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: 3a0eab5077c472f231fb51ad183d18b2390f23fc96183b05d48097b9fad272b7
|
|
4
|
+
data.tar.gz: d2309d95f7866ddc83ab185a4b6fcabc221f11e2053aed9b7ac453a16ec42993
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b37594cb3c3ebb9194f02171927f8e7ecae0c0e808d7632bd8700bac152fe3cc3a7d2fc480780e08654b9492f11926c50c0f825b15b1323c029d2a26e360b11
|
|
7
|
+
data.tar.gz: 897bae41d0ad1d17ce87c92696266d81b1f1278022518f9432a1c8affe617da2058eb2fd8ff6c2eaf0b4f7f953c49f4a28b180f8f9b9dc765e7f74983fc3ab9c
|
|
@@ -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 Log
|
|
7
|
+
def initialize
|
|
8
|
+
@stub = Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.call(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.2
|
|
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
|