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 LogReceptacle
s to perform the
actual logging.
LogChannel
s are provided as a convenience, exposed as static properties
through Log
. Use of LogChannel
s 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
LogSeverity
of thisLogChannel
, which determines the severity of theLogEntry
instances it creates.Declaration
Swift
public let severity: LogSeverity
-
The
LogReceptacle
into which thisLogChannel
will deposit theLogEntry
instances it creates.Declaration
Swift
public let receptacle: LogReceptacle
-
Initializes a new
LogChannel
instance.Declaration
Swift
public init(severity: LogSeverity, receptacle: LogReceptacle)
Parameters
severity
The
LogSeverity
to use for eachLogEntry
created by the channel.receptacle
The
LogReceptacle
to be used for depositing theLogEntry
instances 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
function
The default value provided for this parameter captures the signature of the calling function. You should not provide a value for this parameter.
filePath
The 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.
fileLine
The 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
msg
The message to send to the log.
function
The default value provided for this parameter captures the signature of the calling function. You should not provide a value for this parameter.
filePath
The 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.
fileLine
The 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
value
The value to send to the log. Determining how (and whether) arbitrary values are captured and represented will be handled by the
LogRecorder
implementation(s) that are ultimately called upon to record the log entry.function
The default value provided for this parameter captures the signature of the calling function. You should not provide a value for this parameter.
filePath
The 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.
fileLine
The 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.