# google-logging-utils - Class Google::Logging::SourceLocation (v0.2.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [0.2.0 (latest)](https://docs.cloud.google.com/ruby/docs/reference/google-logging-utils/latest/Google-Logging-SourceLocation)
- [0.1.0](https://docs.cloud.google.com/ruby/docs/reference/google-logging-utils/0.1.0/Google-Logging-SourceLocation)
Reference documentation and code samples for the google-logging-utils class Google::Logging::SourceLocation.

An object representing a source location as used by Google Logging.

## Inherits

- Object

## Methods

### .for_caller

    def self.for_caller(locations: nil, extra_depth: 0, omit_files: nil) -> SourceLocation, nil

Returns a SourceLocation corresponding to the caller.
This basically walks the stack trace backwards until it finds the
first entry not in the `google/logging/message.rb` source file or in
any of the other files optionally listed.
**Parameters**

- **locations** (Array\<Thread::Backtrace::Location\>) *(defaults to: nil)* --- The caller stack to search. Optional; defaults to the current stack.
- **extra_depth** (Integer) *(defaults to: 0)* --- Optional extra steps backwards to walk. Defaults to 0.
- **omit_files** (Array\<String,Regexp\>) *(defaults to: nil)* --- File paths to omit.
**Returns**

- ([SourceLocation](https://docs.cloud.google.com/ruby/docs/reference/google-logging-utils/latest/Google-Logging-SourceLocation), nil) --- The SourceLocation, or nil if none found.

### #file

    def file() -> String

**Returns**

- (String) --- Path to the source file.

### #function

    def function() -> String

**Returns**

- (String) --- Name of the calling function.

### #initialize

    def initialize(file:, line:, function:) -> SourceLocation

Low-level constructor.
**Parameters**

- **file** (String) --- Path to the source file.
- **line** (String) --- Line number as a string.
- **function** (String) --- Name of the calling function.
**Returns**

- ([SourceLocation](https://docs.cloud.google.com/ruby/docs/reference/google-logging-utils/latest/Google-Logging-SourceLocation)) --- a new instance of SourceLocation

### #line

    def line() -> String

**Returns**

- (String) --- Line number as a string.