module Listen::Thread

def new(name, &block)

rubocop:disable Style/MultilineBlockChain
Any exceptions raised by the thread will be logged with the thread name and complete backtrace.
Creates a new thread with the given name.
def new(name, &block)
  thread_name = "listen-#{name}"
  caller_stack = caller
  ::Thread.new do
    rescue_and_log(thread_name, caller_stack: caller_stack, &block)
  end.tap do |thread|
    thread.name = thread_name
  end
end