ruby_rabbitmq_janus 2.6.0.pre.247 → 2.6.0.pre.258
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/bin/ruby_rabbitmq_janus +6 -2
- data/config/default.md +5 -0
- data/config/default.yml +19 -0
- data/lib/rrj/binary.rb +1 -7
- data/lib/rrj/errors/error.rb +5 -9
- data/lib/rrj/errors/tools/gem/config.rb +30 -0
- data/lib/rrj/errors/tools/tools.rb +0 -1
- data/lib/rrj/init.rb +5 -0
- data/lib/rrj/janus/messages/message.rb +2 -2
- data/lib/rrj/janus/processus/concurrency.rb +2 -2
- data/lib/rrj/janus/processus/keepalive/keepalive_thread.rb +17 -12
- data/lib/rrj/janus/transactions/handle.rb +1 -1
- data/lib/rrj/janus/transactions/transaction.rb +3 -3
- data/lib/rrj/models/concerns/janus_instance_callbacks.rb +4 -4
- data/lib/rrj/rabbit/connect.rb +4 -48
- data/lib/rrj/rabbit/connect_fake.rb +68 -0
- data/lib/rrj/rabbit/listener/base.rb +4 -4
- data/lib/rrj/rabbit/propertie.rb +1 -1
- data/lib/rrj/rabbit/rabbit.rb +2 -0
- data/lib/rrj/rails.rb +2 -2
- data/lib/rrj/task.rb +0 -1
- data/lib/rrj/tools/bin/config.rb +3 -2
- data/lib/rrj/tools/bin/init.rb +2 -29
- data/lib/rrj/tools/bin/model.rb +8 -3
- data/lib/rrj/tools/gem/config/gem.rb +74 -0
- data/lib/rrj/tools/gem/config/janus.rb +31 -0
- data/lib/rrj/tools/gem/config/queues.rb +47 -0
- data/lib/rrj/tools/gem/config/rabbit.rb +45 -0
- data/lib/rrj/tools/gem/config.rb +13 -106
- data/lib/rrj/tools/gem/log.rb +48 -122
- data/lib/rrj/tools/gem/option.rb +5 -2
- data/lib/rrj/tools/gem/requests.rb +1 -1
- data/lib/rrj/tools/replaces/admin.rb +2 -2
- data/lib/rrj/tools/replaces/handle.rb +3 -3
- data/lib/rrj/tools/replaces/replace.rb +3 -3
- data/lib/rrj/tools/replaces/session.rb +2 -2
- data/lib/rrj/tools/tools.rb +0 -1
- data/spec/ruby_rabbitmq_janus/tools/{log_spec.rb → logger_spec.rb} +2 -1
- data/spec/spec_helper.rb +7 -1
- metadata +9 -6
- data/lib/rrj/tools/bin/arguments.rb +0 -21
- data/lib/rrj/tools/bin/environment.rb +0 -18
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyRabbitmqJanus
|
4
|
+
module Tools
|
5
|
+
# Subclass for Config
|
6
|
+
#
|
7
|
+
# Options about Gem
|
8
|
+
#
|
9
|
+
# @see RubyRabbitmqJanus::Tools::Config
|
10
|
+
module ConfigGem
|
11
|
+
# @return [Boolean] Read option file for a janus cluster section
|
12
|
+
def cluster
|
13
|
+
@options['gem']['cluster']['enabled'].to_s.match?('true') ? true : false
|
14
|
+
rescue => exception
|
15
|
+
p "[cluster] #{exception}"
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [Symbol] read configuration for log level used in this gem
|
19
|
+
def log_level
|
20
|
+
@options['gem']['log']['level'].upcase.to_sym || :INFO
|
21
|
+
rescue => exception
|
22
|
+
p "[log_level] #{exception}"
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [Symbol] Read level to log
|
26
|
+
def log_type
|
27
|
+
@options['gem']['log']['type'].downcase.to_sym || :stdout
|
28
|
+
rescue => exception
|
29
|
+
p "[log_type] #{exception}"
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [String] read configuration for log option
|
33
|
+
def log_option
|
34
|
+
option = @options['gem']['log']['option']
|
35
|
+
option.empty? ? nil : option
|
36
|
+
rescue => exception
|
37
|
+
p "[log_option] #{exception}"
|
38
|
+
end
|
39
|
+
|
40
|
+
# @return [String] Get path to classes in project calling this gem.
|
41
|
+
def listener_path
|
42
|
+
@options['gem']['listener']['path'].to_s ||
|
43
|
+
'app/ruby_rabbitmq_janus/action_events'
|
44
|
+
rescue => exception
|
45
|
+
p "[listener_path] #{exception}"
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String] Environment gem executed.
|
49
|
+
def environment
|
50
|
+
@options['gem']['environment'].to_s || 'development'
|
51
|
+
rescue => exception
|
52
|
+
p "[environment] #{exception}"
|
53
|
+
end
|
54
|
+
|
55
|
+
# @return [String] Get orm used (mongoid or active_record)
|
56
|
+
def object_relational_mapping
|
57
|
+
@options['gem']['orm'].to_s || 'mongoid'
|
58
|
+
rescue => exception
|
59
|
+
p "[orm] #{exception}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [String] Get program name or GEM_NAME
|
63
|
+
def program_name
|
64
|
+
@options['gem']['program_name'].to_s || RubyRabbitmqJanus::GEM_NAME
|
65
|
+
rescue => exception
|
66
|
+
p "[program_name] #{exception}"
|
67
|
+
end
|
68
|
+
|
69
|
+
alias env environment
|
70
|
+
alias orm object_relational_mapping
|
71
|
+
alias pg program_name
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyRabbitmqJanus
|
4
|
+
module Tools
|
5
|
+
# Subclass for Config
|
6
|
+
#
|
7
|
+
# Options about Janus
|
8
|
+
#
|
9
|
+
# @see RubyRabbitmqJanus::Tools::Config
|
10
|
+
module ConfigJanus
|
11
|
+
# @return [Integer]
|
12
|
+
# read configuration for janus time to live for keepalive messages
|
13
|
+
def time_to_live
|
14
|
+
@options['janus']['session']['keepalive'].to_i || 50
|
15
|
+
rescue => exception
|
16
|
+
p "[time_to_live] #{exception}"
|
17
|
+
end
|
18
|
+
|
19
|
+
# @param [Fixnum] index determine what field is readint in array plugins
|
20
|
+
# in configuration file
|
21
|
+
# @return [String] read configuration for plugin with index
|
22
|
+
def plugin_at(index = 0)
|
23
|
+
@options['janus']['plugins'][index].to_s
|
24
|
+
rescue => exception
|
25
|
+
p "[plugin_at] #{exception}"
|
26
|
+
end
|
27
|
+
|
28
|
+
alias ttl time_to_live
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyRabbitmqJanus
|
4
|
+
module Tools
|
5
|
+
# Subclass for Config
|
6
|
+
#
|
7
|
+
# Options about Queues
|
8
|
+
#
|
9
|
+
# @see RubyRabbitmqJanus::Tools::Config
|
10
|
+
module ConfigQueues
|
11
|
+
# @return [String] Get to name queue_from (pattern)
|
12
|
+
def queue_from
|
13
|
+
@options['queues']['standard']['from'].to_s
|
14
|
+
rescue => exception
|
15
|
+
p "[queue_from] #{exception}"
|
16
|
+
end
|
17
|
+
|
18
|
+
# @return [String] Get to name queue_to (pattern)
|
19
|
+
def queue_to
|
20
|
+
@options['queues']['standard']['to'].to_s
|
21
|
+
rescue => exception
|
22
|
+
p "[queue_to] #{exception}"
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] Get to name queue_admin_from (pattern)
|
26
|
+
def queue_admin_from
|
27
|
+
@options['queues']['admin']['from'].to_s
|
28
|
+
rescue => exception
|
29
|
+
p "[queue_admin_from] #{exception}"
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [String] Get to name queue_admin_from (pattern)
|
33
|
+
def queue_admin_to
|
34
|
+
@options['queues']['admin']['to'].to_s
|
35
|
+
rescue => exception
|
36
|
+
p "[queue_admin_to] #{exception}"
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [String] Get to name queue JanusInstance
|
40
|
+
def queue_janus_instance
|
41
|
+
@options['queues']['instance'].to_s
|
42
|
+
rescue => exception
|
43
|
+
p "[queue_janus_instances] #{exception}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :reek:FeatureEnvy
|
4
|
+
|
5
|
+
module RubyRabbitmqJanus
|
6
|
+
module Tools
|
7
|
+
# Subclass for Config
|
8
|
+
#
|
9
|
+
# Options about bunny
|
10
|
+
#
|
11
|
+
# @see RubyRabbitmqJanus::Tools::Config
|
12
|
+
module ConfigRabbit
|
13
|
+
# @return [String] read configuration fir queue admin
|
14
|
+
def admin_pass
|
15
|
+
@options['rabbit']['admin_pass'].to_s
|
16
|
+
rescue => exception
|
17
|
+
p "[admin_pass] #{exception}"
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Symbol] read configuration for bunny log level
|
21
|
+
def log_level_rabbit
|
22
|
+
@options['rabbit']['level'].upcase.to_sym || :INFO
|
23
|
+
rescue => exception
|
24
|
+
p "[log_level_rabbit] #{exception}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Boolean] read configuration for bunny execution
|
28
|
+
def tester?
|
29
|
+
@options['rabbit']['test'].to_s.match?('true') ? true : false
|
30
|
+
rescue => exception
|
31
|
+
p "[tester] #{exception}"
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Hash] Format hash for bunny settings
|
35
|
+
def server_settings
|
36
|
+
Hash[%w[host port pass user vhost log_level].map do |value|
|
37
|
+
[
|
38
|
+
value.to_sym,
|
39
|
+
@options['rabbit'][value.eql?('log_level') ? 'level' : value]
|
40
|
+
]
|
41
|
+
end]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/rrj/tools/gem/config.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'singleton'
|
4
|
+
require 'rrj/errors/error'
|
5
|
+
require 'yaml'
|
6
|
+
require 'erb'
|
7
|
+
require 'rrj/tools/gem/config/gem'
|
8
|
+
require 'rrj/tools/gem/config/rabbit'
|
9
|
+
require 'rrj/tools/gem/config/queues'
|
10
|
+
require 'rrj/tools/gem/config/janus'
|
4
11
|
|
5
12
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
6
13
|
module RubyRabbitmqJanus
|
@@ -16,6 +23,10 @@ module RubyRabbitmqJanus
|
|
16
23
|
# @return [String] Path to configuration file used
|
17
24
|
class Config
|
18
25
|
include Singleton
|
26
|
+
include RubyRabbitmqJanus::Tools::ConfigGem
|
27
|
+
include RubyRabbitmqJanus::Tools::ConfigRabbit
|
28
|
+
include RubyRabbitmqJanus::Tools::ConfigQueues
|
29
|
+
include RubyRabbitmqJanus::Tools::ConfigJanus
|
19
30
|
|
20
31
|
attr_reader :options, :configuration
|
21
32
|
|
@@ -37,116 +48,12 @@ module RubyRabbitmqJanus
|
|
37
48
|
@options = @configuration = nil
|
38
49
|
loading_configuration_customize
|
39
50
|
loading_configuration_default
|
40
|
-
Tools::Log.instance.save_level(log_level)
|
41
|
-
rescue
|
42
|
-
raise Errors::Tools::Config::Initialize
|
43
|
-
end
|
44
|
-
|
45
|
-
# Get to name queue_from (pattern)
|
46
|
-
#
|
47
|
-
# @return [String] read configuration for queue `from`
|
48
|
-
def queue_from
|
49
|
-
@options['queues']['standard']['from'].to_s
|
50
|
-
rescue
|
51
|
-
raise Errors::Tools::Config::QueueFrom
|
52
|
-
end
|
53
|
-
|
54
|
-
# Get to name queue_to (pattern)
|
55
|
-
#
|
56
|
-
# @return [String] read configuration for queue `to`
|
57
|
-
def queue_to
|
58
|
-
@options['queues']['standard']['to'].to_s
|
59
|
-
rescue
|
60
|
-
raise Errors::Tools::Config::QueueTo
|
61
|
-
end
|
62
|
-
|
63
|
-
# Get to name queue_admin_from (pattern)
|
64
|
-
#
|
65
|
-
# @return [String] read configuration for queue admin `from`
|
66
|
-
def queue_admin_from
|
67
|
-
@options['queues']['admin']['from'].to_s
|
68
|
-
rescue
|
69
|
-
raise Errors::Tools::Config::QueueAdminFrom
|
70
|
-
end
|
71
|
-
|
72
|
-
# Get to name queue_admin_from (pattern)
|
73
|
-
#
|
74
|
-
# @return [String] read configuration for queue admin `to`
|
75
|
-
def queue_admin_to
|
76
|
-
@options['queues']['admin']['to'].to_s
|
77
|
-
rescue
|
78
|
-
raise Errors::Tools::Config::QueueAdminTo
|
79
|
-
end
|
80
|
-
|
81
|
-
# Get to name queue JanusInstance
|
82
|
-
#
|
83
|
-
# @return [String] read configuration for queue janus instance
|
84
|
-
def queue_janus_instance
|
85
|
-
@options['queues']['instance'].to_s
|
86
|
-
rescue
|
87
|
-
raise Errors::Tools::Config::QueueJanusInstance
|
88
|
-
end
|
89
|
-
|
90
|
-
# @return [Symbol] read configuration for log level used in this gem
|
91
|
-
def log_level
|
92
|
-
@options['gem']['log']['level'].upcase.to_sym || :INFO
|
93
|
-
rescue
|
94
|
-
raise Errors::Tools::Config::LogLevel
|
95
|
-
end
|
96
|
-
|
97
|
-
# @return [Symbol] read configuration for bunny log level
|
98
|
-
def log_level_rabbit
|
99
|
-
@options['rabbit']['level'].upcase.to_sym || :INFO
|
100
|
-
rescue
|
101
|
-
raise Errors::Tools::Config::LogLevelRabbit
|
102
|
-
end
|
103
|
-
|
104
|
-
# @return [Boolean] read configuration for bunny execution
|
105
|
-
def tester?
|
106
|
-
@options['rabbit']['test'].to_s.match?('true') ? true : false
|
107
|
-
rescue
|
108
|
-
raise Errors::Tools::Config::RabbitTester
|
109
|
-
end
|
110
|
-
|
111
|
-
# @return [String] read configuration fir queue admin
|
112
|
-
def admin_pass
|
113
|
-
@options['rabbit']['admin_pass'].to_s
|
114
|
-
rescue
|
115
|
-
raise Errors::Tools::Config::AdminPassword
|
116
|
-
end
|
117
|
-
|
118
|
-
# @return [Integer]
|
119
|
-
# read configuration for janus time to live for keepalive messages
|
120
|
-
def time_to_live
|
121
|
-
@options['janus']['session']['keepalive'].to_i || 50
|
122
|
-
rescue
|
123
|
-
raise Errors::Tools::Config::TimeToLive
|
124
|
-
end
|
125
|
-
|
126
|
-
alias ttl time_to_live
|
127
|
-
|
128
|
-
# @param [Fixnum] index determine what field is readint in array plugins
|
129
|
-
# in configuration file
|
130
|
-
# @return [String] read configuration for plugin with index
|
131
|
-
def plugin_at(index = 0)
|
132
|
-
@options['janus']['plugins'][index].to_s
|
133
|
-
rescue
|
134
|
-
raise Errors::Tools::Config::PluginAt, index
|
135
|
-
end
|
136
|
-
|
137
|
-
# @return [Boolean] Read option file for a janus cluster section
|
138
|
-
def cluster
|
139
|
-
@options['gem']['cluster']['enabled'].to_s.match?('true') ? true : false
|
140
|
-
rescue
|
141
|
-
raise Errors::Tools::Config::Cluster
|
142
51
|
end
|
143
52
|
|
144
53
|
private
|
145
54
|
|
146
55
|
def load_configuration
|
147
|
-
|
148
|
-
Tools::Log.instance.info(log_message)
|
149
|
-
YAML.safe_load(ERB.new(File.read(@configuration)).result)
|
56
|
+
::YAML.safe_load(ERB.new(File.read(@configuration)).result)
|
150
57
|
end
|
151
58
|
|
152
59
|
def loading_configuration_customize
|
data/lib/rrj/tools/gem/log.rb
CHANGED
@@ -1,157 +1,83 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'logger'
|
4
|
+
require 'rrj/info'
|
5
|
+
require 'rrj/tools/gem/config'
|
4
6
|
|
5
7
|
module RubyRabbitmqJanus
|
6
8
|
module Tools
|
7
9
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
8
|
-
|
10
|
+
# @since 2.6.0
|
11
|
+
#
|
9
12
|
# # Manage log in this gem
|
10
13
|
#
|
11
|
-
#
|
14
|
+
# Create module for managing logger in many level.
|
15
|
+
# In Thread process.
|
16
|
+
# In rails apps (final app use this gem).
|
12
17
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
WARN: Logger::WARN,
|
23
|
-
ERROR: Logger::ERROR,
|
24
|
-
FATAL: Logger::FATAL,
|
25
|
-
UNKNOWN: Logger::UNKNOWN
|
26
|
-
}.freeze
|
27
|
-
|
28
|
-
# Sensitive data hiding to logger
|
29
|
-
SENSITIVES = %i[admin_secret apisecret].freeze
|
30
|
-
|
31
|
-
attr_reader :level
|
32
|
-
|
33
|
-
# Returns a new instance to Log and use `Tag` element for each line
|
34
|
-
# writing in log with name to gem.
|
35
|
-
#
|
36
|
-
# @see http://api.rubyonrails.org/classes/ActiveSupport/TaggedLogging.html
|
37
|
-
def initialize
|
38
|
-
logs = defined?(Rails) ? logger_rails : logger_develop
|
39
|
-
logs.progname = 'RRJ' if ENV['PROGRAM_NAME'].eql?('ruby_rabbitmq_janus')
|
40
|
-
logs.level = LEVELS[:DEBUG]
|
41
|
-
logs.info('### Start gem Ruby Rabbit Janus ###')
|
42
|
-
@level = logs.level
|
43
|
-
@logs = ActiveSupport::TaggedLogging.new(logs)
|
18
|
+
# Prepare different output :
|
19
|
+
# STDOUT
|
20
|
+
# RemoteSyslogger (for papertrail)
|
21
|
+
# File
|
22
|
+
module Logger
|
23
|
+
def self.start
|
24
|
+
Log.info '### Start bin Ruby Rabbit Janus ###'
|
25
|
+
Log.info "RRJ Version : #{RubyRabbitmqJanus::VERSION}"
|
26
|
+
Log.info "\r\n#{RubyRabbitmqJanus::BANNER}"
|
44
27
|
end
|
45
28
|
|
46
|
-
|
47
|
-
|
48
|
-
# @param message [String] Message writing in warning level in log
|
49
|
-
def unknown(message)
|
50
|
-
write_tag { @logs.unknown(filter(message)) }
|
51
|
-
rescue
|
52
|
-
raise Errors::Tools::Log::Unknown
|
53
|
-
end
|
29
|
+
def self.create
|
30
|
+
@config = RubyRabbitmqJanus::Tools::Config.instance
|
54
31
|
|
55
|
-
|
56
|
-
|
57
|
-
# @param message [String] Message writing in warning level in log
|
58
|
-
def fatal(message)
|
59
|
-
write_tag { @logs.fatal(filter(message)) } if test_level?(Logger::FATAL)
|
60
|
-
rescue
|
61
|
-
raise Errors::Tools::Log::Fatal
|
62
|
-
end
|
32
|
+
@log = initialize_logger
|
33
|
+
@log.level = @config.log_level
|
63
34
|
|
64
|
-
|
65
|
-
#
|
66
|
-
# @param message [String] Message writing in warning level in log
|
67
|
-
def error(message)
|
68
|
-
write_tag { @logs.error(filter(message)) } if test_level?(Logger::ERROR)
|
69
|
-
rescue
|
70
|
-
raise Errors::Tools::Log::Error
|
35
|
+
@log
|
71
36
|
end
|
72
37
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
# Write a message in log with a `INFO` level
|
82
|
-
#
|
83
|
-
# @param message [String] Message writing in info level in log
|
84
|
-
def info(message)
|
85
|
-
write_tag { @logs.info(filter(message)) } if test_level?(Logger::INFO)
|
86
|
-
rescue
|
87
|
-
raise Errors::Tools::Log::Info
|
88
|
-
end
|
89
|
-
|
90
|
-
# Write a message in log with a `DEBUG` level
|
91
|
-
#
|
92
|
-
# @param message [String] Message writing in debug level in log
|
93
|
-
def debug(message)
|
94
|
-
write_tag { @logs.debug(filter(message)) } if test_level?(Logger::DEBUG)
|
95
|
-
rescue
|
96
|
-
raise Errors::Tools::Log::Debug
|
38
|
+
def self.initialize_logger
|
39
|
+
case @config.log_type
|
40
|
+
when :stdout then logger_stdout
|
41
|
+
when :file then logger_file
|
42
|
+
when :rails then logger_rails
|
43
|
+
when :remote then logger_remote
|
44
|
+
end
|
97
45
|
end
|
98
46
|
|
99
|
-
|
100
|
-
|
101
|
-
@logs
|
102
|
-
rescue
|
103
|
-
raise Errors::Tools::Log::Logger
|
47
|
+
def self.logger_stdout
|
48
|
+
::Logger.new(STDOUT)
|
104
49
|
end
|
105
50
|
|
106
|
-
|
107
|
-
|
108
|
-
@logs.instance_variable_get(:'@logdev').filename
|
109
|
-
rescue
|
110
|
-
raise Errors::Tools::Log::Logdev
|
51
|
+
def self.logger_rails
|
52
|
+
Rails.logger
|
111
53
|
end
|
112
54
|
|
113
|
-
|
114
|
-
|
115
|
-
# @param [Symbol] gem_level Level used for log in this gem
|
116
|
-
def save_level(gem_level)
|
117
|
-
@level = LEVELS[gem_level]
|
118
|
-
rescue
|
119
|
-
raise Errors::Tools::Log::SaveLevel
|
55
|
+
def self.logger_file
|
56
|
+
::Logger.new('log/ruby-rabbitmq-janus.log')
|
120
57
|
end
|
121
58
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
59
|
+
def self.logger_remote
|
60
|
+
RemoteSyslogLogger.new(remote_url,
|
61
|
+
remote_port,
|
62
|
+
program: remote_program,
|
63
|
+
local_hostname: remote_hostname)
|
126
64
|
end
|
127
65
|
|
128
|
-
def
|
129
|
-
|
130
|
-
log.formatter = proc do |severity, _datetime, _progname, msg|
|
131
|
-
"#{severity[0, 1].upcase}, #{msg}\n"
|
132
|
-
end
|
133
|
-
log
|
66
|
+
def self.remote_url
|
67
|
+
@config.log_option.split(':').first
|
134
68
|
end
|
135
69
|
|
136
|
-
def
|
137
|
-
|
70
|
+
def self.remote_port
|
71
|
+
@config.log_option.split('@').first.split(':').last
|
138
72
|
end
|
139
73
|
|
140
|
-
def
|
141
|
-
@
|
74
|
+
def self.remote_program
|
75
|
+
@config.log_option.split('@').last.split(':').first
|
142
76
|
end
|
143
77
|
|
144
|
-
|
145
|
-
|
146
|
-
msg = log
|
147
|
-
SENSITIVES.each do |word|
|
148
|
-
msg = log.gsub(/\"#{word}\".*\".*\"/, "\"#{word}\":\"[FILTERED]\"") \
|
149
|
-
if log.include?(word.to_s)
|
150
|
-
end
|
151
|
-
msg
|
78
|
+
def self.remote_hostname
|
79
|
+
@config.log_option.split(':').last
|
152
80
|
end
|
153
|
-
|
154
|
-
alias filter filter_sensitive_data
|
155
81
|
end
|
156
82
|
end
|
157
83
|
end
|
data/lib/rrj/tools/gem/option.rb
CHANGED
@@ -3,7 +3,11 @@
|
|
3
3
|
require 'rrj/models/concerns/janus_instance_callbacks'
|
4
4
|
require 'rrj/models/concerns/janus_instance_methods'
|
5
5
|
require 'rrj/models/concerns/janus_instance_validations'
|
6
|
-
|
6
|
+
if RubyRabbitmqJanus::Tools::Config.instance.orm.eql?('mongoid')
|
7
|
+
require 'rrj/models/mongoid'
|
8
|
+
else
|
9
|
+
require 'rrj/models/active_record'
|
10
|
+
end
|
7
11
|
|
8
12
|
# :reek:FeatureEnvy
|
9
13
|
|
@@ -17,7 +21,6 @@ module RubyRabbitmqJanus
|
|
17
21
|
# instance. It's also used for testing session/handle used in request.
|
18
22
|
class Option
|
19
23
|
def initialize
|
20
|
-
Log.instance
|
21
24
|
Config.instance
|
22
25
|
Requests.instance
|
23
26
|
rescue => exception
|
@@ -23,7 +23,7 @@ module RubyRabbitmqJanus
|
|
23
23
|
# Load all requests in folder
|
24
24
|
def initialize
|
25
25
|
@requests = {}
|
26
|
-
|
26
|
+
::Log.info "Loading all requests in : #{PATH_REQUEST}"
|
27
27
|
Dir[File.join(PATH_REQUEST, '*')].count { |file| each_files(file) }
|
28
28
|
rescue
|
29
29
|
raise Errors::Tools::Request::Initializer
|
@@ -43,13 +43,13 @@ module RubyRabbitmqJanus
|
|
43
43
|
def replace_component(key)
|
44
44
|
request[key] = type.convert(key, opts)
|
45
45
|
rescue => exception
|
46
|
-
|
46
|
+
::Log.warn "Error replace #{key} : #{exception}"
|
47
47
|
end
|
48
48
|
|
49
49
|
def replace_admin
|
50
50
|
request['admin_secret'] = admin_pass
|
51
51
|
rescue => exception
|
52
|
-
|
52
|
+
::Log.warn "Error replace admin_secret : #{exception}"
|
53
53
|
end
|
54
54
|
|
55
55
|
def admin_pass
|
@@ -21,7 +21,7 @@ module RubyRabbitmqJanus
|
|
21
21
|
def replace_handle
|
22
22
|
request['handle_id'] = type.convert('handle_id', opts)
|
23
23
|
rescue => exception
|
24
|
-
|
24
|
+
::Log.warn "Error handle replace : #{exception}"
|
25
25
|
end
|
26
26
|
|
27
27
|
def replace_candidate
|
@@ -29,13 +29,13 @@ module RubyRabbitmqJanus
|
|
29
29
|
request[cdn[0]] = cdn[1]
|
30
30
|
delete_key_unless
|
31
31
|
rescue => exception
|
32
|
-
|
32
|
+
::Log.warn "Error candidate replace : #{exception}"
|
33
33
|
end
|
34
34
|
|
35
35
|
def replace_sdp
|
36
36
|
request['jsep']['sdp'] = type.convert('sdp', opts)
|
37
37
|
rescue => exception
|
38
|
-
|
38
|
+
::Log.warn "Error sdp replace : #{exception}"
|
39
39
|
end
|
40
40
|
|
41
41
|
def determine_key_candidate
|
@@ -53,14 +53,14 @@ module RubyRabbitmqJanus
|
|
53
53
|
values = @opts['replace']
|
54
54
|
running_hash(rewrite_key_to_string(values))
|
55
55
|
rescue => exception
|
56
|
-
|
56
|
+
::Log.warn "Error REPLACE other field : #{exception}"
|
57
57
|
end
|
58
58
|
|
59
59
|
def add_other
|
60
60
|
values = @opts['add']
|
61
61
|
@request['body'].merge!(values)
|
62
62
|
rescue => exception
|
63
|
-
|
63
|
+
::Log.warn "Error ADD other field : #{exception}"
|
64
64
|
end
|
65
65
|
|
66
66
|
def rewrite_key_to_string(node)
|
@@ -96,7 +96,7 @@ module RubyRabbitmqJanus
|
|
96
96
|
def replace_transaction
|
97
97
|
@request['transaction'] = @type.convert('transaction')
|
98
98
|
rescue => exception
|
99
|
-
|
99
|
+
::Log.warn "Error transaction replace : #{exception}"
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -20,13 +20,13 @@ module RubyRabbitmqJanus
|
|
20
20
|
def replace_session
|
21
21
|
request['session_id'] = type.convert('session_id', opts)
|
22
22
|
rescue => exception
|
23
|
-
|
23
|
+
::Log.warn "Error session replace : #{exception}"
|
24
24
|
end
|
25
25
|
|
26
26
|
def replace_plugin
|
27
27
|
request['plugin'] = type.convert('plugin')
|
28
28
|
rescue => exception
|
29
|
-
|
29
|
+
::Log.warn "Error plugin replace : #{exception}"
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|