lsslog 0.1.7.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lsslog/services/v2/base.rb +35 -0
- data/lib/lsslog/services/v2/log.rb +11 -0
- data/lib/lsslog/version.rb +1 -1
- data/lib/lsslog.rb +3 -0
- data/lsslog.gemspec +3 -1
- data/proto/lsslog.proto +15 -15
- metadata +4 -5
- data/lib/lsslog/services/v2.rb +0 -64
- data/lib/lsslog/v2/log.rb +0 -68
- data/lsslog-0.1.7.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c54ea01fcda20826706329171d37135a08c73ae0190f1b402897e8229dca69e0
|
4
|
+
data.tar.gz: c4dbafeec49895ca9a66beead4e733ded235299c7532189e260beac05c95e80e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f0ccd031ff62377ec36f27e849f948ae6009b2e8279d0b7517fc1676af20c1601fbcb72fd55c519f32e7213f0256ae045442183a39f0ef14ad10891427c4c2b
|
7
|
+
data.tar.gz: e5f335ae47adabf3079f91fb2117c401f049b4b6c496c3bcd78b9b5621d97b1e47d7b3b19c9d97a2b321d295599aca9867c2369b1f1aeb4147b490fac9a76a96
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'grpc'
|
2
|
+
require "lsslog_services_pb"
|
3
|
+
|
4
|
+
module Lsslog
|
5
|
+
module Services
|
6
|
+
module V2
|
7
|
+
class Base
|
8
|
+
attr_reader :client
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@client = ::Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.call(*args)
|
15
|
+
response = new.call(*args)
|
16
|
+
|
17
|
+
Lsslog.logger.info "#{self.name.demodulize}: #{response.to_json}"
|
18
|
+
|
19
|
+
response
|
20
|
+
rescue GRPC::BadStatus => e
|
21
|
+
Lsslog.logger.info "ERROR: #{e.message}"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def lss_host
|
27
|
+
@lss_host ||= ::Lsslog.configuration.lss_host
|
28
|
+
raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
|
29
|
+
|
30
|
+
@lss_host
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/lsslog/version.rb
CHANGED
data/lib/lsslog.rb
CHANGED
@@ -10,6 +10,9 @@ require 'lsslog/services/set_lss_config'
|
|
10
10
|
require 'lsslog/services/set_trans_exp_time'
|
11
11
|
require 'lsslog/services/write_log'
|
12
12
|
|
13
|
+
require 'lsslog/services/v2/base'
|
14
|
+
require 'lsslog/services/v2/log'
|
15
|
+
|
13
16
|
module Lsslog
|
14
17
|
class Error < StandardError; end
|
15
18
|
|
data/lsslog.gemspec
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
|
1
2
|
lib = File.expand_path("../lib", __FILE__)
|
2
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
4
|
require "lsslog/version"
|
4
5
|
|
6
|
+
|
5
7
|
Gem::Specification.new do |spec|
|
6
8
|
spec.name = "lsslog"
|
7
9
|
spec.version = Lsslog::VERSION
|
@@ -24,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
24
26
|
# Specify which files should be added to the gem when it is released.
|
25
27
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
26
28
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
27
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/})
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
30
|
end
|
29
31
|
spec.bindir = "exe"
|
30
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
data/proto/lsslog.proto
CHANGED
@@ -96,6 +96,19 @@ message ProdTransaction {
|
|
96
96
|
int64 created_at = 7;
|
97
97
|
}
|
98
98
|
|
99
|
+
message LogVer2 {
|
100
|
+
string severity = 1;
|
101
|
+
string timestamp = 2;
|
102
|
+
string api = 3;
|
103
|
+
string component = 4;
|
104
|
+
google.protobuf.Struct message = 5;
|
105
|
+
}
|
106
|
+
|
107
|
+
message LogResponseVer2 {
|
108
|
+
string id = 1;
|
109
|
+
uint32 timestamp = 2;
|
110
|
+
}
|
111
|
+
|
99
112
|
service LssLogService {
|
100
113
|
rpc WriteLog(LssLog) returns (LssRes) {};
|
101
114
|
rpc GetVersion(EmptyIn) returns (VersionOut) {};
|
@@ -106,19 +119,6 @@ service LssLogService {
|
|
106
119
|
rpc WriteProdTransaction(ProdTransaction) returns (LssRes) {};
|
107
120
|
}
|
108
121
|
|
109
|
-
message LogVer2 {
|
110
|
-
string severity = 1;
|
111
|
-
string timestamp = 2;
|
112
|
-
string api = 3;
|
113
|
-
string component = 4;
|
114
|
-
google.protobuf.Struct message = 5;
|
115
|
-
}
|
116
|
-
|
117
|
-
message LogResponseVer2 {
|
118
|
-
string id = 1;
|
119
|
-
uint32 timestamp = 2;
|
120
|
-
}
|
121
|
-
|
122
122
|
service V2 {
|
123
|
-
|
124
|
-
}
|
123
|
+
rpc Log(LogVer2) returns (LogResponseVer2) {};
|
124
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lsslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thanh Ngo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -101,10 +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
|
+
- lib/lsslog/services/v2/base.rb
|
105
|
+
- lib/lsslog/services/v2/log.rb
|
105
106
|
- lib/lsslog/services/write_log.rb
|
106
107
|
- lib/lsslog/services/write_prod_transaction.rb
|
107
|
-
- lib/lsslog/v2/log.rb
|
108
108
|
- lib/lsslog/version.rb
|
109
109
|
- lib/lsslog_pb.rb
|
110
110
|
- lib/lsslog_services_pb.rb
|
@@ -114,7 +114,6 @@ files:
|
|
114
114
|
- lsslog-0.1.3.pre.rc1.gem
|
115
115
|
- lsslog-0.1.5.gem
|
116
116
|
- lsslog-0.1.6.gem
|
117
|
-
- lsslog-0.1.7.gem
|
118
117
|
- lsslog.gemspec
|
119
118
|
- proto/README.md
|
120
119
|
- proto/lsslog.proto
|
data/lib/lsslog/services/v2.rb
DELETED
@@ -1,64 +0,0 @@
|
|
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
|
data/lib/lsslog/v2/log.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'grpc'
|
2
|
-
require 'lsslog_services_pb'
|
3
|
-
|
4
|
-
module Lsslog
|
5
|
-
module V2
|
6
|
-
class Logger
|
7
|
-
def initialize
|
8
|
-
Rails.logger.info("Initialize")
|
9
|
-
@stub = Lsslog::V2::Stub.new(lss_host, :this_channel_is_insecure)
|
10
|
-
end
|
11
|
-
|
12
|
-
def log(message_h:, severity:, component: '', api: '')
|
13
|
-
Rails.logger.info("Begin log function")
|
14
|
-
message_struct = hash_to_struct(message_h)
|
15
|
-
|
16
|
-
log_ver2 = Lsslog::LogVer2.new(
|
17
|
-
severity: severity,
|
18
|
-
timestamp: Time.now.utc.iso8601,
|
19
|
-
api: api,
|
20
|
-
component: component,
|
21
|
-
message: message_struct
|
22
|
-
)
|
23
|
-
|
24
|
-
Rails.logger.info("Sending LSS log. Message:[#{message_h}]")
|
25
|
-
|
26
|
-
response = @stub.log(log_ver2, deadline: Time.now + 5)
|
27
|
-
response
|
28
|
-
rescue GRPC::BadStatus => e
|
29
|
-
Rails.logger.error("Error sending LSS log: #{e.message}")
|
30
|
-
nil
|
31
|
-
rescue StandardError => e
|
32
|
-
Rails.logger.info("#{e.backtrace}, #{e.message}")
|
33
|
-
end
|
34
|
-
|
35
|
-
def lss_host
|
36
|
-
@lss_host ||= ::Lsslog.configuration.lss_host
|
37
|
-
raise 'Lsslog.configuration.lss_host is missing' unless @lss_host
|
38
|
-
|
39
|
-
@lss_host
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def hash_to_struct(hash)
|
45
|
-
Google::Protobuf::Struct.new(fields: hash.transform_values { |v| to_proto_value(v) })
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_proto_value(value)
|
49
|
-
case value
|
50
|
-
when String
|
51
|
-
Google::Protobuf::Value.new(string_value: value)
|
52
|
-
when Numeric
|
53
|
-
Google::Protobuf::Value.new(number_value: value)
|
54
|
-
when TrueClass, FalseClass
|
55
|
-
Google::Protobuf::Value.new(bool_value: value)
|
56
|
-
when Hash
|
57
|
-
Google::Protobuf::Value.new(struct_value: hash_to_struct(value))
|
58
|
-
when Array
|
59
|
-
Google::Protobuf::Value.new(list_value: Google::Protobuf::ListValue.new(values: value.map { |v| to_proto_value(v) }))
|
60
|
-
when NilClass
|
61
|
-
Google::Protobuf::Value.new(null_value: :NULL_VALUE)
|
62
|
-
else
|
63
|
-
Google::Protobuf::Value.new(string_value: value.to_s)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lsslog-0.1.7.gem
DELETED
Binary file
|