Protocol
LoggerFragment
A fragment of a log message.
protocol LoggerFragment : Sendable
Mentioned in
Topics
Instance Methods
func and<T>(T) -> AndFragment<Self, T>Combine the current fragment with another, which will be written after the current fragment finishes.func hasContent(record: inout LogRecord) -> BoolIndicates whether the fragment will write anything tooutputwhenwrite(_:to:)is called.func maxLevel(Logger.Level) -> IfMaxLevelFragment<Self>Make the current fragment conditional, only calling itsoutputmethod if the record’sloggerLevelismaxLevelor lowerfunc prefixed(String) -> AndFragment<LiteralFragment, Self>Add a literal prefix to the current fragment.func separated(String) -> SeparatorFragment<Self>Appends the given separator text to the output beforeself’s output, as long as a separator is needed.func suffixed(String) -> AndFragment<Self, LiteralFragment>Add a literal suffix to the current fragment.func write(inout LogRecord, to: inout FragmentOutput)Add this fragment’s output to the console text.
Type Properties
static var `default`: DefaultLoggerFragmentTypeALoggerFragmentwhich implements the default logger message format.
Type Methods
static func timestampDefault(timestampSource: some TimestampSource) -> some LoggerFragmentALoggerFragmentwhich implements the default logger message format with a timestamp at the front.
Relationships
Inherits From
Swift.SendableSwift.SendableMetatype
Conforming Types
See Also
Logger Fragments
enum LoggerFragmentBuilderA result builder for creating logger fragments in a declarative way.struct FragmentOutputThe output of aLoggerFragment, including some intermediary state used for things like deduplicating separators.struct IfMaxLevelFragmentMake the current fragment conditional, only calling itsoutputmethod if the record’sloggerLevelismaxLevelor lowerstruct AndFragmentCombine the current fragment with another, which will be written after the current fragment finishes.struct OptionalFragmentA fragment that conditionally includes another fragment.struct ArrayFragmentA fragment that combines multiple fragments of the same type.struct LabelFragmentWrites the label of the logger, and requests a separator for the next fragment.struct LevelFragmentWrites the level of the logged message, and requests a separator for the next fragment.struct LiteralFragmentWrites the given text to the output.struct SeparatorFragmentstruct SpacedFragmentA fragment that wraps another fragment, automatically separating its components with spaces.struct MessageFragmentWrites the logged message to the output, and requests a separator for the next fragment.struct MetadataFragmentWrites the combined metadata to the output, and requests a separator for the next fragment only if the metadata was not empty.struct SourceLocationFragmentWrites the file location of the logged message, including the line.struct LoggerSourceFragmentWrites the source of the logged message.