Module: Concurrently::Debug

Defined in:
lib/all/concurrently/debug.rb

Overview

With Concurrently::Debug the locations where concurrent procs are entered, suspended, resumed and exited at can be logged. The log shows the subsequent order in which concurrent procs are executed.

It looks like:

.---- BEGIN 94khk test/CRuby/event_loop_spec.rb:16
'-> SUSPEND 94khk lib/all/concurrently/proc/evaluation.rb:86:in `__suspend__'
... [other entries] ...
.--- RESUME 94khk lib/all/concurrently/proc/evaluation.rb:86:in `__suspend__'
'-----> END 94khk test/CRuby/event_loop_spec.rb:16

This log section indicates that the concurrent proc defined at test/CRuby/event_loop_spec.rb:16 has been started to be evaluated. It is assigned the id 94khk. The code of the proc is evaluated until it is suspended at lib/all/concurrently/proc/evaluation.rb:86. After other concurrent procs where scheduled to run, proc 94khk is resumed again and from there on is evaluated until its end.

Next to END, there are two other variations how the evaluation of a concurrent proc can be marked as concluded. These are

The id of an evaluation may (and very likely will) be reused after the evaluation was concluded.

Since:

  • 1.2.0

Class Method Summary collapse

Class Method Details

.enable(logger, filter = false) ⇒ true

Enables debugging

Examples:

require 'logger'
Concurrently::Debug.enable Logger.new(STDOUT), ['file2']

# Assuming the stacktrace when resuming/suspending looks like:
#   /path/to/file1.rb
#   /path/to/file2.rb
#   /path/to/file3.rb
#
# Then, the logged location will be /path/to/file2.rb

Parameters:

  • logger (Logger)
  • filter (Array<String>) (defaults to: false)

    An array of strings to filter stacktrace locations by. The first location in a stacktrace containing one of the given strings will be used in the log message. If no filter is given, the first location is logged.

Returns:

  • (true)

Since:

  • 1.2.0



58
59
60
61
62
63
64
# File 'lib/all/concurrently/debug.rb', line 58

def enable(logger, filter = false)
  @logger = logger
  @filter = filter
  @log_concurrently_gem = filter && filter.any?{ |f| f.include? @concurrently_path }
  @overwrites.each{ |overwrite| overwrite.call }
  true
end