rookout 0.1.0 → 0.1.56
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/rookout/atfork.rb +73 -0
- data/lib/rookout/augs/actions/action_run_processor.rb +4 -3
- data/lib/rookout/augs/aug.rb +33 -91
- data/lib/rookout/augs/aug_factory.rb +94 -27
- data/lib/rookout/augs/aug_rate_limiter.rb +50 -47
- data/lib/rookout/augs/augs_manager.rb +3 -1
- data/lib/rookout/augs/conditions/condition.rb +4 -2
- data/lib/rookout/augs/limits_manager.rb +32 -0
- data/lib/rookout/augs/locations/location.rb +75 -1
- data/lib/rookout/augs/locations/location_exception_handler.rb +22 -0
- data/lib/rookout/augs/locations/location_file_line.rb +21 -5
- data/lib/rookout/com_ws/agent_com_ws.rb +97 -58
- data/lib/rookout/com_ws/backoff.rb +5 -10
- data/lib/rookout/com_ws/command_handler.rb +1 -1
- data/lib/rookout/com_ws/envelope_wrapper.rb +68 -0
- data/lib/rookout/com_ws/git.rb +1 -1
- data/lib/rookout/com_ws/information.rb +95 -4
- data/lib/rookout/com_ws/output.rb +69 -21
- data/lib/rookout/com_ws/pinger.rb +41 -0
- data/lib/rookout/com_ws/websocket_client.rb +173 -0
- data/lib/rookout/commit.rb +3 -0
- data/lib/rookout/config.rb +94 -18
- data/lib/rookout/exceptions.rb +147 -12
- data/lib/rookout/interface.rb +95 -32
- data/lib/rookout/logger.rb +39 -10
- data/lib/rookout/processor/namespace_serializer.rb +2 -2
- data/lib/rookout/processor/namespace_serializer2.rb +331 -0
- data/lib/rookout/processor/namespaces/container_namespace.rb +5 -0
- data/lib/rookout/processor/namespaces/frame_namespace.rb +20 -17
- data/lib/rookout/processor/namespaces/namespace.rb +3 -2
- data/lib/rookout/processor/namespaces/noop_namespace.rb +4 -8
- data/lib/rookout/processor/namespaces/ruby_object_namespace.rb +39 -22
- data/lib/rookout/processor/namespaces/ruby_object_serializer.rb +15 -12
- data/lib/rookout/processor/namespaces/ruby_utils_namespace.rb +0 -4
- data/lib/rookout/processor/namespaces/stack_namespace.rb +6 -4
- data/lib/rookout/processor/namespaces/traceback_namespace.rb +13 -9
- data/lib/rookout/processor/operations/set_operation.rb +6 -1
- data/lib/rookout/processor/paths/arithmetic_path.rb +5 -3
- data/lib/rookout/processor/paths/canopy/actions.rb +5 -1
- data/lib/rookout/processor/paths/canopy/consts.rb +6 -4
- data/lib/rookout/processor/paths/canopy/maps.rb +286 -286
- data/lib/rookout/processor/paths/canopy/markers.rb +35 -4
- data/lib/rookout/processor/processor_factory.rb +0 -2
- data/lib/rookout/processor/rook_error.rb +6 -1
- data/lib/rookout/protobuf/controller_info_pb.rb +1 -0
- data/lib/rookout/protobuf/messages_pb.rb +54 -0
- data/lib/rookout/protobuf/variant2_pb.rb +42 -0
- data/lib/rookout/protobuf/variant_pb.rb +22 -0
- data/lib/rookout/rookout_singleton.rb +23 -5
- data/lib/rookout/sanitizer.rb +22 -0
- data/lib/rookout/services/position.rb +92 -75
- data/lib/rookout/services/tracer.rb +30 -16
- data/lib/rookout/start.rb +12 -0
- data/lib/rookout/trigger_services.rb +2 -2
- data/lib/rookout/user_warnings.rb +2 -0
- data/lib/rookout/utils.rb +34 -0
- data/lib/rookout/version.rb +1 -2
- data/lib/rookout.rb +4 -0
- metadata +77 -51
data/lib/rookout/exceptions.rb
CHANGED
@@ -11,9 +11,6 @@ module Rookout
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class RookInterfaceException < ToolException
|
14
|
-
def initialize message
|
15
|
-
super message
|
16
|
-
end
|
17
14
|
end
|
18
15
|
|
19
16
|
class RookVersionNotSupported < ToolException
|
@@ -31,7 +28,7 @@ module Rookout
|
|
31
28
|
|
32
29
|
class RookAttributeNotFound < ToolException
|
33
30
|
def initialize attribute
|
34
|
-
super "Failed to get attribute #{attribute}", { attribute
|
31
|
+
super "Failed to get attribute #{attribute}", { "attribute" => attribute }
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
@@ -84,37 +81,68 @@ module Rookout
|
|
84
81
|
|
85
82
|
class RookNonPrimitiveObjectType < ToolException
|
86
83
|
def initialize path
|
87
|
-
super "Object
|
84
|
+
super "Object #{path} must be of primitive type, such as: string, int, long etc",
|
85
|
+
{ "path" => path }
|
88
86
|
end
|
89
87
|
end
|
90
88
|
|
91
89
|
class RookMessageSizeExceeded < ToolException
|
92
90
|
def initialize message_size, max_message_size
|
93
91
|
super "Message size of #{message_size} exceeds max size limit of #{max_message_size}. " \
|
94
|
-
|
95
|
-
|
96
|
-
{ message_size
|
92
|
+
"Change the depth of collection or change the default by setting ROOKOUT_MAX_MESSAGE_SIZE " \
|
93
|
+
"as environment variable or system property",
|
94
|
+
{ "message_size" => message_size, "max_message_size" => max_message_size }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
class RookOutputQueueFull < ToolException
|
99
|
+
def initialize
|
100
|
+
super "Breakpoint triggered but output queue is full. " \
|
101
|
+
"Data collection will be disabled until the queue has emptied."
|
97
102
|
end
|
98
103
|
end
|
99
104
|
|
100
|
-
class
|
105
|
+
class RookRuleAugRateLimited < ToolException
|
101
106
|
def initialize
|
102
107
|
super "Breakpoint was disabled due to rate-limiting. " \
|
103
|
-
|
108
|
+
"For more information: https://docs.rookout.com/docs/breakpoints-tasks.html#rate-limiting"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class RookRuleGlobalRateLimited < ToolException
|
113
|
+
def initialize
|
114
|
+
super "Breakpoint was disabled due to global rate-limiting. " \
|
115
|
+
"For more information: https://docs.rookout.com/docs/breakpoints-tasks.html#rate-limiting"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class RookRuleRateLimited
|
120
|
+
def self.create
|
121
|
+
if Rookout::Config.using_global_rate_limiter
|
122
|
+
return RookRuleGlobalRateLimited.new
|
123
|
+
end
|
124
|
+
RookRuleAugRateLimited.new
|
104
125
|
end
|
105
126
|
end
|
106
127
|
|
107
128
|
class RookInvalidToken < ToolException
|
108
|
-
def initialize token
|
129
|
+
def initialize token = ""
|
109
130
|
super "The Rookout token supplied #{token[0..6]} is not valid; please check the token and try again",
|
110
131
|
{ token: token[0...6] }
|
111
132
|
end
|
112
133
|
end
|
113
134
|
|
135
|
+
class RookWebSocketError < ToolException
|
136
|
+
def initialize http_status
|
137
|
+
super "Received HTTP status #{http_status} from the controller," \
|
138
|
+
"Please make sure WebSocket is enabled on the load balancer."
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
114
142
|
class RookSourceFilePathSuggestion < ToolException
|
115
143
|
def initialize wanted_path, matching_path
|
116
144
|
super "Rookout found alternative file path: #{matching_path}",
|
117
|
-
{ wanted_path
|
145
|
+
{ "wanted_path" => wanted_path, "matching_path" => matching_path }
|
118
146
|
end
|
119
147
|
end
|
120
148
|
|
@@ -125,6 +153,13 @@ module Rookout
|
|
125
153
|
end
|
126
154
|
end
|
127
155
|
|
156
|
+
class RookInvalidPositionException < ToolException
|
157
|
+
def initialize filename, line
|
158
|
+
super "Invalid code position for TracePoint: #{filename}:#{line}",
|
159
|
+
{ filename: filename, line: line }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
128
163
|
class RookObjectCannotBeSerialized < ToolException
|
129
164
|
def initialize object, message
|
130
165
|
super message, { "class" => object.class.to_s }
|
@@ -136,5 +171,105 @@ module Rookout
|
|
136
171
|
super "No Rookout token was supplied. Make sure to pass the Rookout Token when starting the rook"
|
137
172
|
end
|
138
173
|
end
|
174
|
+
|
175
|
+
class RookInvalidOptions < ToolException
|
176
|
+
end
|
177
|
+
|
178
|
+
class RookInvalidLabel < ToolException
|
179
|
+
def initialize label_name
|
180
|
+
super "Invalid label: must not start with the '$' character (#{label_name})"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
class RookCrcMismatchException < ToolException
|
185
|
+
def initialize filepath, expected, calculated
|
186
|
+
super "Line CRC32s do not match! path: #{filepath}, expected: #{expected}, calculated:#{calculated}",
|
187
|
+
{
|
188
|
+
"filepath" => filepath,
|
189
|
+
"expected" => expected,
|
190
|
+
"calculated" => calculated
|
191
|
+
}
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
class RookLineMoved < ToolException
|
196
|
+
def initialize filepath, old_line_no, new_line_no
|
197
|
+
super "Line has moved! path: #{filepath}, original line no: #{old_line_no}, new line no: #{new_line_no}",
|
198
|
+
{
|
199
|
+
"filepath" => filepath,
|
200
|
+
"old_line_no" => old_line_no,
|
201
|
+
"new_line_no" => new_line_no
|
202
|
+
}
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
class RookCommunicationException < ToolException
|
207
|
+
def initialize
|
208
|
+
super "Failed to connect to the controller - will continue attempting in the background"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
class RookWebsocketException < ToolException
|
213
|
+
def initialize error
|
214
|
+
super "Error from Websocket #{error}", { "error" => error }
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
class RookProxyException < ToolException
|
219
|
+
def initialize error
|
220
|
+
super "Error from proxy #{error}", { "error" => error }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
class RookBadProtobuf < ToolException
|
225
|
+
def initialize
|
226
|
+
super 'Bad protobuf version. Please execute "bundle config force_ruby_platform true" before "bundler install".'
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
class RookBadProtobufPlatform < ToolException
|
231
|
+
def initialize platform
|
232
|
+
super "Bad protobuf platform: #{platform}"
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class RookObjectNameMissing < ToolException
|
237
|
+
def initialize configuration
|
238
|
+
super "Failed to find object name",
|
239
|
+
{
|
240
|
+
"configuration" => configuration
|
241
|
+
}
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
class RookUnsupportedLocation < ToolException
|
246
|
+
def initialize location
|
247
|
+
super "Unsupported aug location was specified: #{location}",
|
248
|
+
{
|
249
|
+
"location" => location
|
250
|
+
}
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class RookInvalidRateLimitConfiguration < ToolException
|
255
|
+
def initialize config
|
256
|
+
super "Invalid rate limit configuration: #{config}",
|
257
|
+
{
|
258
|
+
"config" => config
|
259
|
+
}
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
class RookUnsupportedLiveLogger < ToolException
|
264
|
+
def initialize
|
265
|
+
super "Live Logger is not supported. Try using Rookout Live Debugger instead."
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
class RookLocalsUnavailable < ToolException
|
270
|
+
def initialize
|
271
|
+
super "Can't collect local variables up the stack"
|
272
|
+
end
|
273
|
+
end
|
139
274
|
end
|
140
275
|
end
|
data/lib/rookout/interface.rb
CHANGED
@@ -4,10 +4,18 @@ module Rookout
|
|
4
4
|
include Singleton
|
5
5
|
|
6
6
|
require_relative "config"
|
7
|
+
require_relative "utils"
|
7
8
|
require_relative "exceptions"
|
9
|
+
include Exceptions
|
8
10
|
|
9
11
|
def initialize
|
10
12
|
@rook = nil
|
13
|
+
@start_options = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def print_debug_messages
|
17
|
+
puts "[Rookout] Running in debug mode"
|
18
|
+
puts "[Rookout] Rookout SDK for ruby: #{Config.rookout_version}"
|
11
19
|
end
|
12
20
|
|
13
21
|
def start options = {}
|
@@ -15,28 +23,31 @@ module Rookout
|
|
15
23
|
throw_errors = options[:throw_errors] == true
|
16
24
|
Config.debug = evaluate_flag options[:debug], "ROOKOUT_DEBUG"
|
17
25
|
|
18
|
-
|
19
|
-
require_relative "rookout_singleton"
|
20
|
-
|
21
|
-
configure_logging options
|
22
|
-
labels = options[:labels] || parse_labels(ENV["ROOKOUT_LABELS"])
|
23
|
-
validate_labels labels
|
26
|
+
print_debug_messages if Config.debug
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
com = configure_com options
|
28
|
+
begin
|
29
|
+
verify_env
|
28
30
|
|
29
|
-
|
30
|
-
fork = evaluate_flag options[:fork], "ROOKOUT_ENABLE_FORK"
|
31
|
+
require_relative "rookout_singleton"
|
31
32
|
|
32
|
-
|
33
|
+
configure options
|
33
34
|
|
34
35
|
rook = RookoutSingleton.instance
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
@start_options[throw_errors: throw_errors]
|
37
|
+
rook.connect(**@start_options)
|
38
|
+
rescue LoadError
|
39
|
+
raise if throw_errors
|
40
|
+
$stderr.puts "[Rookout] Failed to load Rookout. Please make sure to force build native extensions by setting" \
|
41
|
+
"'bundle config force_ruby_platform true'"
|
42
|
+
rescue RookMissingToken, RookInvalidToken, RookInvalidOptions,
|
43
|
+
RookVersionNotSupported, RookBadProtobuf, RookWebSocketError => e
|
44
|
+
raise if throw_errors
|
45
|
+
$stderr.puts "[Rookout] Failed to start Rookout: #{e.message}"
|
46
|
+
rescue RookCommunicationException => e
|
47
|
+
raise if throw_errors
|
48
|
+
Logger.instance.warning "[Rookout] #{e.message}"
|
38
49
|
rescue Exception => e
|
39
|
-
puts e.full_message if Config.debug
|
50
|
+
$stderr.puts e.full_message if Config.debug
|
40
51
|
raise if throw_errors
|
41
52
|
end
|
42
53
|
end
|
@@ -56,10 +67,42 @@ module Rookout
|
|
56
67
|
|
57
68
|
TRUE_VALUE = [true, "y", "Y", "yes", "Yes", "YES", "true", "True", "TRUE", "1"].freeze
|
58
69
|
|
59
|
-
def
|
70
|
+
def configure options
|
71
|
+
# If we are running post fork, use previous start_options
|
72
|
+
if options[:post_fork]
|
73
|
+
# Don't re-enable the fork handler
|
74
|
+
@start_options[:fork] = false
|
75
|
+
else
|
76
|
+
configure_globals options
|
77
|
+
|
78
|
+
@start_options = configure_start_options options
|
79
|
+
print_config @start_options
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def verify_env
|
84
|
+
# Only test alpine
|
85
|
+
return unless File.exist? "/etc/alpine-release"
|
86
|
+
|
87
|
+
# Make sure protobuf is built from source
|
88
|
+
protobuf = Gem::Specification.find_by_path "google/protobuf"
|
89
|
+
$stderr.puts RookBadProtobuf.new.message if protobuf.nil?
|
90
|
+
return unless protobuf.platform != "ruby"
|
91
|
+
|
92
|
+
error = RookBadProtobufPlatform.new protobuf.platform
|
93
|
+
$stderr.puts error.message
|
94
|
+
end
|
95
|
+
|
96
|
+
def configure_scm options
|
97
|
+
Config.user_git_origin = options[:git_origin] if options[:git_origin]
|
98
|
+
Config.user_git_commit = options[:git_commit] if options[:git_commit]
|
99
|
+
Config.user_git_sources = options[:git_sources] if options[:git_sources] && options[:git_sources].is_a?(Hash)
|
100
|
+
end
|
101
|
+
|
102
|
+
def configure_globals options
|
60
103
|
if Config.debug
|
61
104
|
log_to_stderr = true
|
62
|
-
log_level =
|
105
|
+
log_level = :DEBUG
|
63
106
|
else
|
64
107
|
log_to_stderr = evaluate_flag options[:log_to_stderr], "ROOKOUT_LOG_TO_STDERR"
|
65
108
|
log_level = options[:log_level] || ENV["ROOKOUT_LOG_FILE"]
|
@@ -70,23 +113,30 @@ module Rookout
|
|
70
113
|
Config.logger_log_to_stderr = log_to_stderr unless log_to_stderr.nil?
|
71
114
|
Config.logger_filename = log_file unless log_file.nil?
|
72
115
|
Config.logger_log_level = log_level unless log_level.nil?
|
73
|
-
end
|
74
116
|
|
75
|
-
|
76
|
-
Config.user_git_origin = options[:git_origin] if options[:git_origin]
|
77
|
-
Config.user_git_commit = options[:git_commit] if options[:git_commit]
|
117
|
+
configure_scm options
|
78
118
|
end
|
79
119
|
|
80
|
-
def
|
120
|
+
def configure_start_options options
|
81
121
|
host = evaluate_config options[:host], "ROOKOUT_CONTROLLER_HOST", "wss://control.rookout.com"
|
82
122
|
port = evaluate_config options[:port], "ROOKOUT_CONTROLLER_PORT", 443
|
83
123
|
proxy = evaluate_config options[:proxy], "ROOKOUT_PROXY"
|
84
124
|
token = evaluate_config options[:token], "ROOKOUT_TOKEN"
|
85
125
|
|
86
|
-
raise
|
126
|
+
raise RookMissingToken if token.nil? && !(host_specified options)
|
87
127
|
verify_token token if token
|
88
128
|
|
89
|
-
|
129
|
+
labels = stringify_labels(options[:labels]) || parse_labels(ENV["ROOKOUT_LABELS"])
|
130
|
+
validate_labels labels
|
131
|
+
|
132
|
+
async_start = true? ENV["ROOKOUT_ASYNC_START"]
|
133
|
+
fork = evaluate_flag options[:fork], "ROOKOUT_ENABLE_FORK"
|
134
|
+
|
135
|
+
{ host: host, port: port, proxy: proxy, token: token, labels: labels, async_start: async_start, fork: fork }
|
136
|
+
end
|
137
|
+
|
138
|
+
def host_specified options
|
139
|
+
!options[:host].nil? || !ENV["ROOKOUT_CONTROLLER_HOST"].nil? || !ENV["ROOKOUT_AGENT_HOST"].nil?
|
90
140
|
end
|
91
141
|
|
92
142
|
def evaluate_flag argument, env_var_name
|
@@ -104,6 +154,18 @@ module Rookout
|
|
104
154
|
default
|
105
155
|
end
|
106
156
|
|
157
|
+
def stringify_labels labels
|
158
|
+
return nil unless labels
|
159
|
+
|
160
|
+
stringified_labels = {}
|
161
|
+
|
162
|
+
labels.each do |label_name, label_value|
|
163
|
+
stringified_labels[label_name.to_s] = label_value.to_s
|
164
|
+
end
|
165
|
+
|
166
|
+
stringified_labels
|
167
|
+
end
|
168
|
+
|
107
169
|
def parse_labels raw_labels
|
108
170
|
labels = {}
|
109
171
|
return labels if raw_labels.nil?
|
@@ -120,21 +182,22 @@ module Rookout
|
|
120
182
|
def validate_labels labels
|
121
183
|
labels.each do |label_name, _|
|
122
184
|
if label_name.start_with? "$"
|
123
|
-
raise
|
185
|
+
raise RookInvalidLabel, label_name
|
124
186
|
end
|
125
187
|
end
|
126
188
|
end
|
127
189
|
|
128
190
|
def verify_token token
|
129
|
-
raise
|
130
|
-
raise
|
131
|
-
raise
|
191
|
+
raise RookInvalidOptions, "Rookout token should be a String" unless token.is_a? String
|
192
|
+
raise RookInvalidOptions, "Rookout token should be 64 characters" unless token.length == 64
|
193
|
+
raise RookInvalidOptions, "Rookout token must consist of only hexadecimal characters" unless
|
132
194
|
token.match(/^[0-9a-zA-Z]{0,64}$/)
|
133
195
|
end
|
134
196
|
|
135
|
-
def print_config
|
136
|
-
|
137
|
-
|
197
|
+
def print_config options
|
198
|
+
return unless Config.debug
|
199
|
+
|
200
|
+
puts "[Rookout] Start Options: #{options}"
|
138
201
|
end
|
139
202
|
end
|
140
203
|
end
|
data/lib/rookout/logger.rb
CHANGED
@@ -11,6 +11,15 @@ module Rookout
|
|
11
11
|
LOG_LEVELS = [:DEBUG, :INFO, :WARNING, :ERROR].freeze
|
12
12
|
|
13
13
|
def initialize
|
14
|
+
# Detect unit tests
|
15
|
+
if (Config.debug ||
|
16
|
+
$PROGRAM_NAME.end_with?("minitest_runner.rb") ||
|
17
|
+
$PROGRAM_NAME.end_with?("tunit_or_minitest_in_folder_runner.rb")) &&
|
18
|
+
Dir.pwd.end_with?("ruby-sdk")
|
19
|
+
Config.logger_log_level = :DEBUG
|
20
|
+
Config.logger_log_to_stderr = true
|
21
|
+
end
|
22
|
+
|
14
23
|
@verbosity = LOG_LEVELS.index(Config.logger_log_level) || LOG_LEVELS.index(:INFO)
|
15
24
|
|
16
25
|
@output = nil
|
@@ -43,7 +52,6 @@ module Rookout
|
|
43
52
|
end
|
44
53
|
|
45
54
|
def exception message, exc
|
46
|
-
# TODO: REVIEW HOW TO REPORT EXCEPTIONS
|
47
55
|
error message, exc
|
48
56
|
end
|
49
57
|
|
@@ -54,12 +62,25 @@ module Rookout
|
|
54
62
|
@level = level
|
55
63
|
@time = Time.new
|
56
64
|
@message = message
|
57
|
-
@formatted_message = message % arguments
|
65
|
+
@formatted_message = @message % arguments
|
66
|
+
|
67
|
+
arguments.each do |argument|
|
68
|
+
if argument.is_a? Exception
|
69
|
+
@formatted_message += "\n#{argument.message}\n#{argument.backtrace.join "\n\t"}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
58
73
|
@arguments = arguments
|
59
74
|
set_caller
|
60
75
|
end
|
61
76
|
|
62
|
-
attr_reader :level
|
77
|
+
attr_reader :level
|
78
|
+
attr_reader :time
|
79
|
+
attr_reader :filename
|
80
|
+
attr_reader :lineno
|
81
|
+
attr_reader :message
|
82
|
+
attr_reader :formatted_message
|
83
|
+
attr_reader :arguments
|
63
84
|
|
64
85
|
def format
|
65
86
|
"#{@time} #{Process.pid}:#{Thread.current.name}-" \
|
@@ -84,6 +105,7 @@ module Rookout
|
|
84
105
|
end
|
85
106
|
end
|
86
107
|
|
108
|
+
# rubocop:disable Style/RescueStandardError
|
87
109
|
def log level, message, args
|
88
110
|
level_no = LOG_LEVELS.index level
|
89
111
|
if level_no.nil?
|
@@ -95,11 +117,18 @@ module Rookout
|
|
95
117
|
|
96
118
|
record = LogRecord.new level, message, args
|
97
119
|
@handlers.each { |handler| handler.call record }
|
120
|
+
rescue
|
121
|
+
# Log may never throw
|
122
|
+
nil
|
98
123
|
end
|
124
|
+
# rubocop:enable Style/RescueStandardError
|
99
125
|
|
100
126
|
def build_handlers
|
101
|
-
|
102
|
-
|
127
|
+
if Config.logger_log_to_stderr
|
128
|
+
@handlers.push new_file_handler unless Config.logger_filename.nil? || Config.logger_filename.empty?
|
129
|
+
@handlers.push new_stderr_handler
|
130
|
+
end
|
131
|
+
|
103
132
|
@handlers.push new_remote_handler
|
104
133
|
end
|
105
134
|
|
@@ -114,19 +143,19 @@ module Rookout
|
|
114
143
|
file = nil
|
115
144
|
|
116
145
|
if Config.debug
|
117
|
-
|
118
|
-
|
146
|
+
$stderr.puts "[Rookout] Failed to open log file: #{log_file_path}"
|
147
|
+
$stderr.puts e.backtrace
|
119
148
|
end
|
120
149
|
end
|
121
150
|
|
122
|
-
->(record) { file.write record.format
|
151
|
+
->(record) { file.write "#{record.format}\n" if file }
|
123
152
|
end
|
124
153
|
|
125
154
|
def calculate_log_file_path
|
126
155
|
return Config.logger_filename if absolute_path? Config.logger_filename
|
127
156
|
|
128
157
|
if RUBY_PLATFORM.include? "darwin"
|
129
|
-
File.join
|
158
|
+
File.join Dir.home, Config.logger_filename
|
130
159
|
elsif RUBY_PLATFORM.match?(/cygwin|mswin|mingw|bccwin|wince|emx/)
|
131
160
|
File.join ENV["USERPROFILE"], Config.logger_filename
|
132
161
|
else
|
@@ -135,7 +164,7 @@ module Rookout
|
|
135
164
|
end
|
136
165
|
|
137
166
|
def new_stderr_handler
|
138
|
-
->(record) {
|
167
|
+
->(record) { $stderr.puts record.format }
|
139
168
|
end
|
140
169
|
|
141
170
|
def new_remote_handler
|
@@ -7,7 +7,7 @@ module Rookout
|
|
7
7
|
|
8
8
|
module_function
|
9
9
|
|
10
|
-
def dump namespace, log_errors
|
10
|
+
def dump namespace, log_errors
|
11
11
|
namespace.dump log_errors
|
12
12
|
rescue StandardError => e
|
13
13
|
message = "Failed to serialize namespace"
|
@@ -17,7 +17,7 @@ module Rookout
|
|
17
17
|
Logger.instance.exception message, e
|
18
18
|
|
19
19
|
error = RookError.new e, message
|
20
|
-
variant = error.dumps
|
20
|
+
variant.error_value = error.dumps
|
21
21
|
end
|
22
22
|
variant
|
23
23
|
end
|