schemaless_rest_api 0.4.2 → 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: e95a3b730fded817e63c9d7d95ba4f658d22a1ed55b2d324b2dfe325d3624108
4
- data.tar.gz: bb0514bb042bbcd277e6ceb240a4fe2f9f2b4ab72df7d881158c13ff53073e47
3
+ metadata.gz: 8cd0875a0972ff3b33119a209a1e0a4a338e89cc52949c3014f12e9193315fbc
4
+ data.tar.gz: 5a15b247ae28b9ec1329637dac2649bc6104425d4f576a77d0ca4725b3a1ae0d
5
5
  SHA512:
6
- metadata.gz: 85a359eb6004862d9c2c85a78391635c3219e374779bbbc1a6276066c6886e39ccfde7841764fc1eae9bf175d4aa3ee4abcfe13ea5884deceddc1213d4bcefac
7
- data.tar.gz: 5f832458ee8abe08bd102b106ab08204aeacc83dd8d90f171a4d297d7cdf96106bd08150f9bcedfc2adf5fd88f7921c92108eb51aa39e7bcbe788745e143fe1c
6
+ metadata.gz: da922d8ce69b812d26fa7f6887e604190a22c4f9924a9fb2d33a93c5de4a52aca09c92c0b172674d51970704abb09fec1e26851d8254009ba96f56df4e8966be
7
+ data.tar.gz: 3aeb83be262190ef8273dc1fcf521b11ee637f6ccbb7e389b7e379be528fc3a593cdb31497652016225484b222af2a4e1cd539ab2d301af798c7893061041baa
@@ -1,22 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # typed: true
3
+ # typed: false
4
4
 
5
+ # Helper methods added to RestServer
5
6
  module ServerUtils
6
7
  def log(messages)
7
- if SchemalessRestApi.log_type == :ougai
8
- log_msg = {
9
- method: request.request_method,
10
- path: request.fullpath,
11
- correlationId: @request_id
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
- end
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
@@ -3,5 +3,5 @@
3
3
  # typed: true
4
4
 
5
5
  module SchemalessRestApi
6
- VERSION = "0.4.2"
6
+ VERSION = "0.5.0"
7
7
  end
@@ -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"] == 'structured'
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.2
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-12 00:00:00.000000000 Z
11
+ date: 2024-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo