zuora_connect 2.0.5x → 2.0.5y
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.
- checksums.yaml +4 -4
- data/lib/resque/plugins/custom_logger.rb +1 -1
- data/lib/zuora_connect.rb +51 -29
- data/lib/zuora_connect/configuration.rb +2 -1
- data/lib/zuora_connect/railtie.rb +1 -21
- data/lib/zuora_connect/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee905da43d4b965a647b9149ec7988f032c76afcc37dbffc934ac70eed7a8e2f
|
4
|
+
data.tar.gz: fc34629d958f8330fdabe0894f8e9d6c7af82b8b578ca3e2136b187c47dc3e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f686fd92b5118df058d1cfb25ab3c21496e6b31d0271de5173be08d7d4731b80a13f22d103af39e57f0ba2c24a84810bd2adc3df147ca6f02cce5ff1bfb0267b
|
7
|
+
data.tar.gz: 78744edba395438dbd76f94c68b1cdcacb5896e4f509e302267df5654ad5ef87356ef65cf17be9e0da594fed1d72dc7408c12428581ccc18fe7ec8870dfb6c57
|
@@ -7,7 +7,7 @@ module Resque
|
|
7
7
|
module Plugins
|
8
8
|
module CustomLogger
|
9
9
|
def before_perform(*args)
|
10
|
-
Rails.logger.with_fields = { trace_id: SecureRandom.uuid, name: "RailsWorker"} if Rails.logger.class.to_s == 'Ougai::Logger'
|
10
|
+
Rails.logger.with_fields = { trace_id: SecureRandom.uuid, name: "RailsWorker"} if Rails.logger.class.to_s == 'Ougai::Logger' && ZuoraConnect.configuration.json_logging
|
11
11
|
case args.class.to_s
|
12
12
|
when "Array"
|
13
13
|
if args.first.class == Hash
|
data/lib/zuora_connect.rb
CHANGED
@@ -31,24 +31,43 @@ module ZuoraConnect
|
|
31
31
|
#puts name + ' - ' + {Logger::WARN => 'Logger::WARN', Logger::ERROR => 'Logger::ERROR', Logger::DEBUG => 'Logger::DEBUG', Logger::INFO => 'Logger::INFO' }[level] + ' - '
|
32
32
|
if type == :ougai
|
33
33
|
require 'ougai'
|
34
|
+
require "ougai/formatters/customizable"
|
34
35
|
#logger = Ougai::Logger.new(MonoLogger.new(STDOUT))
|
35
36
|
logger = Ougai::Logger.new(STDOUT)
|
36
|
-
logger.formatter = Ougai::Formatters::ConnectFormatter.new(name)
|
37
37
|
logger.level = level
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
38
|
+
if ZuoraConnect.configuration.json_logging
|
39
|
+
logger.formatter = Ougai::Formatters::ConnectFormatter.new(name)
|
40
|
+
logger.before_log = lambda do |data|
|
41
|
+
data[:trace_id] = ZuoraConnect::RequestIdMiddleware.request_id if ZuoraConnect::RequestIdMiddleware.request_id.present?
|
42
|
+
data[:zuora_trace_id] = ZuoraConnect::RequestIdMiddleware.zuora_request_id if ZuoraConnect::RequestIdMiddleware.zuora_request_id.present?
|
43
|
+
#data[:traces] = {amazon_id: data[:trace_id], zuora_id: data[:zuora_trace_id]}
|
44
|
+
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool', 'Resque', 'Makara'].include?(name)
|
45
|
+
if Thread.current[:appinstance].present?
|
46
|
+
data[:app_instance_id] = Thread.current[:appinstance].id
|
47
|
+
logitems = Thread.current[:appinstance].logitems
|
48
|
+
if logitems.present? && logitems.class == Hash
|
49
|
+
data[:tenant_ids] = logitems[:tenant_ids] if logitems[:tenant_ids].present?
|
50
|
+
data[:organization] = logitems[:organization] if logitems[:organization].present?
|
51
|
+
end
|
49
52
|
end
|
50
53
|
end
|
51
54
|
end
|
55
|
+
else
|
56
|
+
logger.formatter = Ougai::Formatters::Customizable.new(
|
57
|
+
format_err: proc do |data|
|
58
|
+
next nil unless data.key?(:err)
|
59
|
+
err = data.delete(:err)
|
60
|
+
" #{err[:name]} (#{err[:message]})\n #{err[:stack]}"
|
61
|
+
end,
|
62
|
+
format_data: proc do |data|
|
63
|
+
format('%s %s: %s', 'DATA'.ljust(6), Time.now.strftime('%FT%T.%6NZ'), "#{data.to_json}") if data.present?
|
64
|
+
end,
|
65
|
+
format_msg: proc do |severity, datetime, _progname, data|
|
66
|
+
msg = data.delete(:msg)
|
67
|
+
format('%s %s: %s', severity.ljust(6), datetime, msg)
|
68
|
+
end
|
69
|
+
)
|
70
|
+
logger.formatter.datetime_format = '%FT%T.%6NZ'
|
52
71
|
end
|
53
72
|
else
|
54
73
|
logger = MonoLogger.new(STDOUT)
|
@@ -58,26 +77,29 @@ module ZuoraConnect
|
|
58
77
|
msg = JSON.parse(msg)
|
59
78
|
rescue JSON::ParserError => ex
|
60
79
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
80
|
+
if ZuoraConnect.configuration.json_logging
|
81
|
+
require 'json'
|
82
|
+
store = {
|
83
|
+
name: name,
|
84
|
+
level: serverity,
|
85
|
+
timestamp: datetime.strftime('%FT%T.%6NZ'),
|
86
|
+
pid: Process.pid,
|
87
|
+
message: name == "ActionMailer" ? msg.strip : msg
|
88
|
+
}
|
89
|
+
if !['ElasticAPM', 'ResqueScheduler', 'ResquePool','Resque', 'Makara'].include?(name)
|
90
|
+
if Thread.current[:appinstance].present?
|
91
|
+
store[:app_instance_id] = Thread.current[:appinstance].id
|
92
|
+
logitems = Thread.current[:appinstance].logitems
|
93
|
+
if logitems.present? && logitems.class == Hash
|
94
|
+
store[:tenant_ids] = logitems[:tenant_ids] if logitems[:tenant_ids].present?
|
95
|
+
store[:organization] = logitems[:organization] if logitems[:organization].present?
|
96
|
+
end
|
77
97
|
end
|
78
98
|
end
|
99
|
+
JSON.dump(store) + "\n"
|
100
|
+
else
|
101
|
+
format('%s %s: %s', serverity.ljust(6), datetime, msg) + "\n"
|
79
102
|
end
|
80
|
-
JSON.dump(store) + "\n"
|
81
103
|
end
|
82
104
|
end
|
83
105
|
return logger
|
@@ -7,7 +7,7 @@ module ZuoraConnect
|
|
7
7
|
|
8
8
|
attr_accessor :oauth_client_id, :oauth_client_secret, :oauth_client_redirect_uri
|
9
9
|
|
10
|
-
attr_accessor :dev_mode_logins, :dev_mode_options, :dev_mode_mode, :dev_mode_appinstance, :dev_mode_user, :dev_mode_pass, :dev_mode_admin, :dev_mode_secret_access_key,:dev_mode_access_key_id,:aws_region, :s3_bucket_name, :s3_folder_name
|
10
|
+
attr_accessor :dev_mode_logins, :dev_mode_options, :dev_mode_mode, :dev_mode_appinstance, :dev_mode_user, :dev_mode_pass, :dev_mode_admin, :dev_mode_secret_access_key,:dev_mode_access_key_id,:aws_region, :s3_bucket_name, :s3_folder_name, :json_logging
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@default_locale = :en
|
@@ -42,6 +42,7 @@ module ZuoraConnect
|
|
42
42
|
@aws_region = "us-west-2"
|
43
43
|
@s3_bucket_name = "rbm-apps"
|
44
44
|
@s3_folder_name = Rails.application.class.parent_name
|
45
|
+
@json_logging = Rails.env.to_s == 'development' ? false : true
|
45
46
|
end
|
46
47
|
|
47
48
|
def private_key
|
@@ -32,31 +32,11 @@ module ZuoraConnect
|
|
32
32
|
|
33
33
|
initializer(:rails_stdout_logging, before: :initialize_logger) do
|
34
34
|
require 'lograge'
|
35
|
-
|
36
|
-
require "ougai/formatters/customizable"
|
35
|
+
|
37
36
|
Rails.configuration.logger = ZuoraConnect.custom_logger(name: "Rails")
|
38
|
-
|
39
37
|
if Rails.env != 'development'
|
40
38
|
Rails.configuration.lograge.enabled = true
|
41
39
|
Rails.configuration.colorize_logging = false
|
42
|
-
else
|
43
|
-
Rails.configuration.logger.before_log = lambda do |data|
|
44
|
-
end
|
45
|
-
Rails.configuration.logger.formatter = Ougai::Formatters::Customizable.new(
|
46
|
-
format_err: proc do |data|
|
47
|
-
next nil unless data.key?(:err)
|
48
|
-
err = data.delete(:err)
|
49
|
-
" #{err[:name]} (#{err[:message]})\n #{err[:stack]}"
|
50
|
-
end,
|
51
|
-
format_data: proc do |data|
|
52
|
-
format('%s %s: %s', 'DATA'.ljust(6), Time.now.strftime('%FT%T.%6NZ'), "#{data.to_json}") if data.present?
|
53
|
-
end,
|
54
|
-
format_msg: proc do |severity, datetime, _progname, data|
|
55
|
-
msg = data.delete(:msg)
|
56
|
-
format('%s %s: %s', severity.ljust(6), datetime, msg)
|
57
|
-
end
|
58
|
-
)
|
59
|
-
Rails.configuration.logger.formatter.datetime_format = '%FT%T.%6NZ'
|
60
40
|
end
|
61
41
|
|
62
42
|
if Rails.configuration.lograge.enabled
|