Skip to content

Context

Egor Badmaev edited this page Dec 5, 2022 · 2 revisions

Context

An object that defines details about log's calling.

Declaration

struct Context

Properties

Private

  • let file: String: The name of the file and module in which it appears.
  • let function: String: The name of the declaration in which it appears.
  • let line: Int: The line number on which it appears.

Internal

  • var description: String: Description of the log context. It is a computed property, that returns string:
    var description: String {
        return "In \(file): \(function) method on line \(line)"
    }

Init

Initializes structure with full properties. All properties are optional to simplify creation using memberwise initializer in unit-tests.

#fileID, #function and #line are Literal Expressions.

init(file: String = #fileID,
    function: String = #function,
    line: Int = #line) {
    self.file = file
    self.function = function
    self.line = line
}
Clone this wiki locally