LogChannel
public struct LogChannel
LogChannel instances provide the high-level interface for accepting log
messages.
They are responsible for converting log requests into LogEntry instances
that they then pass along to their associated LogReceptacles to perform the
actual logging.
LogChannels are provided as a convenience, exposed as static properties
through Log. Use of LogChannels and the Log is not required for logging;
you can also perform logging by creating LogEntry instances manually and
passing them along to a LogReceptacle.
-
The
LogSeverityof thisLogChannel, which determines the severity of theLogEntryinstances it creates.Declaration
Swift
public let severity: LogSeverity -
The
LogReceptacleinto which thisLogChannelwill deposit theLogEntryinstances it creates.Declaration
Swift
public let receptacle: LogReceptacle -
Initializes a new
LogChannelinstance.Declaration
Swift
public init(severity: LogSeverity, receptacle: LogReceptacle)Parameters
severityThe
LogSeverityto use for eachLogEntrycreated by the channel.receptacleThe
LogReceptacleto be used for depositing theLogEntryinstances created by the channel. -
Sends program execution trace information to the log using the receiver’s severity. This information includes source-level call site information as well as the stack frame signature of the caller.
Declaration
Swift
public func trace(_ function: String = #function, filePath: String = #file, fileLine: Int = #line)Parameters
functionThe default value provided for this parameter captures the signature of the calling function. You should not provide a value for this parameter.
filePathThe default value provided for this parameter captures the file path of the code issuing the call to this function. You should not provide a value for this parameter.
fileLineThe default value provided for this parameter captures the line number issuing the call to this function. You should not provide a value for this parameter.
-
Sends a message string to the log using the receiver’s severity.
Declaration
Swift
public func message(_ msg: String, function: String = #function, filePath: String = #file, fileLine: Int = #line)Parameters
msgThe message to send to the log.
functionThe default value provided for this parameter captures the signature of the calling function. You should not provide a value for this parameter.
filePathThe default value provided for this parameter captures the file path of the code issuing the call to this function. You should not provide a value for this parameter.
fileLineThe default value provided for this parameter captures the line number issuing the call to this function. You should not provide a value for this parameter.
-
Sends an arbitrary value to the log using the receiver’s severity.
Declaration
Swift
public func value(_ value: Any?, function: String = #function, filePath: String = #file, fileLine: Int = #line)Parameters
valueThe value to send to the log. Determining how (and whether) arbitrary values are captured and represented will be handled by the
LogRecorderimplementation(s) that are ultimately called upon to record the log entry.functionThe default value provided for this parameter captures the signature of the calling function. You should not provide a value for this parameter.
filePathThe default value provided for this parameter captures the file path of the code issuing the call to this function. You should not provide a value for this parameter.
fileLineThe default value provided for this parameter captures the line number issuing the call to this function. You should not provide a value for this parameter.
View on GitHub
LogChannel Struct Reference