class Google::Cloud::Logging::Entry::SourceLocation

# SourceLocation

Additional information about the source code location that produced the log entry.

See also {Google::Cloud::Logging::Entry#source_location}.

Attributes

file[RW]

Source file name. Depending on the runtime environment, this might be a simple name or a fully-qualified name. Optional.

function[RW]

Human-readable name of the function or method being invoked, with optional context such as the class or package name. This information may be used in contexts such as the logs viewer, where a file and line number are less meaningful. Optional.

line[RW]

Line within the source file. 1-based; `0` indicates no line number available. Optional.

Public Class Methods

from_grpc(grpc) click to toggle source

@private New Google::Cloud::Logging::Entry::SourceLocation from a Google::Cloud::Logging::V2::LogEntrySourceLocation object.

# File lib/google/cloud/logging/entry/source_location.rb, line 74
def self.from_grpc grpc
  return new if grpc.nil?
  new.tap do |o|
    o.file       = grpc.file
    o.line       = grpc.line
    o.function   = grpc.function
  end
end
new() click to toggle source

@private Create an empty SourceLocation object.

# File lib/google/cloud/logging/entry/source_location.rb, line 31
def initialize
end

Public Instance Methods

empty?() click to toggle source

@private Determines if the SourceLocation has any data.

# File lib/google/cloud/logging/entry/source_location.rb, line 53
def empty?
  file.nil? &&
    line.nil? &&
    function.nil?
end
to_grpc() click to toggle source

@private Exports the SourceLocation to a Google::Cloud::Logging::V2::LogEntrySourceLocation object.

# File lib/google/cloud/logging/entry/source_location.rb, line 62
def to_grpc
  return nil if empty?
  Google::Cloud::Logging::V2::LogEntrySourceLocation.new(
    file:     file.to_s,
    line:     line,
    function: function.to_s
  )
end