class Google::Logging::SourceLocation
An object representing a source location as used by Google Logging.
#
def self.for_caller locations: nil, extra_depth: 0, omit_files: nil
-
(SourceLocation, nil)
- The SourceLocation, or nil if none found.
Parameters:
-
omit_files
(Array
) -- File paths to omit. -
extra_depth
(Integer
) -- Optional extra steps backwards to walk. -
locations
(Array
) -- The caller stack
def self.for_caller locations: nil, extra_depth: 0, omit_files: nil in_file = true omit_files = [__FILE__] + Array(omit_files) (locations || self.caller_locations).each do |loc| if in_file next if omit_files.any? { |pat| pat === loc.absolute_path } in_file = false end extra_depth -= 1 next unless extra_depth.negative? return new file: loc.path, line: loc.lineno.to_s, function: loc.base_label end nil end
def == other
- Private: -
def == other return false unless other.is_a? SourceLocation file == other.file && line == other.line && function == other.function end
def hash
- Private: -
def hash [file, line, function].hash end
def initialize file:, line:, function:
-
function
(String
) -- Name of the calling function. -
line
(String
) -- Line number as a string. -
file
(String
) -- Path to the source file.
def initialize file:, line:, function: @file = file.to_s @line = line.to_s @function = function.to_s end
def to_h
- Private: -
def to_h { file: @file, line: @line, function: @function } end