schemaless_rest_api 0.4.1 → 0.5.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd0875a0972ff3b33119a209a1e0a4a338e89cc52949c3014f12e9193315fbc
|
4
|
+
data.tar.gz: 5a15b247ae28b9ec1329637dac2649bc6104425d4f576a77d0ca4725b3a1ae0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da922d8ce69b812d26fa7f6887e604190a22c4f9924a9fb2d33a93c5de4a52aca09c92c0b172674d51970704abb09fec1e26851d8254009ba96f56df4e8966be
|
7
|
+
data.tar.gz: 3aeb83be262190ef8273dc1fcf521b11ee637f6ccbb7e389b7e379be528fc3a593cdb31497652016225484b222af2a4e1cd539ab2d301af798c7893061041baa
|
@@ -1,22 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# typed:
|
3
|
+
# typed: false
|
4
4
|
|
5
|
+
# Helper methods added to RestServer
|
5
6
|
module ServerUtils
|
6
7
|
def log(messages)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
messages.each do |key, value|
|
14
|
-
log_msg[key] = value
|
15
|
-
end
|
16
|
-
SchemalessRestApi.logger.info(log_msg)
|
17
|
-
else
|
18
|
-
message = messages.values.join(", ")
|
19
|
-
SchemalessRestApi.logger.info "#{message}, #{request.request_method} #{request.fullpath}, CorrelationId: #{@request_id}"
|
20
|
-
end
|
8
|
+
if SchemalessRestApi.log_type == :ougai
|
9
|
+
log_structured(messages)
|
10
|
+
else
|
11
|
+
message = messages.values.join(", ")
|
12
|
+
SchemalessRestApi.logger.info "#{message}, #{request.request_method} #{request.fullpath}, CorrelationId: #{@request_id}"
|
13
|
+
end
|
21
14
|
end
|
22
|
-
|
15
|
+
|
16
|
+
private def log_structured(messages)
|
17
|
+
log_msg = {
|
18
|
+
method: request.request_method,
|
19
|
+
path: request.fullpath,
|
20
|
+
correlationId: @request_id
|
21
|
+
}
|
22
|
+
messages.each do |key, value|
|
23
|
+
log_msg[key] = value
|
24
|
+
end
|
25
|
+
SchemalessRestApi.logger.info(log_msg)
|
26
|
+
end
|
27
|
+
end
|
data/lib/schemaless_rest_api.rb
CHANGED
@@ -11,16 +11,18 @@ require "ougai"
|
|
11
11
|
require "json"
|
12
12
|
require "securerandom"
|
13
13
|
|
14
|
+
ENV["APP_ENV"] ||= "production"
|
15
|
+
|
14
16
|
# Global params for Schemalass REST API
|
15
17
|
module SchemalessRestApi
|
16
|
-
if ENV["Log"] ==
|
18
|
+
if ENV["Log"] == "structured"
|
17
19
|
@logger = Ougai::Logger.new($stdout)
|
18
20
|
@log_type = :ougai
|
19
21
|
else
|
20
22
|
@logger = Logger.new($stdout)
|
21
23
|
@log_type = :basic
|
22
24
|
end
|
23
|
-
|
25
|
+
|
24
26
|
class << self
|
25
27
|
# @return Logger
|
26
28
|
attr_accessor :logger
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schemaless_rest_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garratt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongo
|