Module: Neo4j::Core::Logging

Defined in:
lib/neo4j/core/logging.rb

Constant Summary collapse

NEO4J_CORE_GEM_ROOT =
File.expand_path('../../..', __dir__) + '/'

Class Method Summary collapse

Class Method Details

.active_support_gem_pathObject



36
37
38
39
40
# File 'lib/neo4j/core/logging.rb', line 36

def active_support_gem_path
  return if !defined?(::ActiveSupport::Notifications)

  @active_support_gem_path ||= File.expand_path('../../..', ActiveSupport::Notifications.method(:subscribe).source_location[0])
end

.first_external_path_and_line(callstack) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/neo4j/core/logging.rb', line 6

def first_external_path_and_line(callstack)
  line = callstack.find do |frame|
    frame.absolute_path && !ignored_callstack(frame.absolute_path)
  end

  offending_line = line || callstack.first

  [offending_line.path,
   offending_line.lineno]
end

.ignored_callstack(path) ⇒ Object



19
20
21
# File 'lib/neo4j/core/logging.rb', line 19

def ignored_callstack(path)
  paths_to_ignore.any?(&path.method(:start_with?))
end

.neo4j_gem_pathObject



30
31
32
33
34
# File 'lib/neo4j/core/logging.rb', line 30

def neo4j_gem_path
  return if !defined?(::Rails.root)

  @neo4j_gem_path ||= File.expand_path('../../..', Neo4j::ActiveBase.method(:current_session).source_location[0])
end

.paths_to_ignoreObject



23
24
25
26
27
28
# File 'lib/neo4j/core/logging.rb', line 23

def paths_to_ignore
  @paths_to_ignore ||= [NEO4J_CORE_GEM_ROOT,
                        RbConfig::CONFIG['rubylibdir'],
                        neo4j_gem_path,
                        active_support_gem_path].compact
end