Each logger has a property named level that you can customize:
let consoleLogger = Log.loggers.first
consoleLogger?.level = [.debug, .warning]
The level is an OptionSet with 4 basic values: debug, warning, error, severe and additionally all and none
Logger
You can create and register your own loggers, just implement the Logger protocol and add an instance to the loggers static property of the Log class. The Logger protocol defines a couple of properties, level and formatter, and four functions: debug, warn, error and severe that correspond to the log levels
Formatter
You can create your own formatter and use it with the loggers you want, just create a class that implements the Formatter protocol and assign it to the logger
let consoleLogger = Log.loggers.first
consoleLogger?.formatter = CustomFormatter()
A logging framework for swift
Usage
Prints:
Configuration
Log
is the class that dispatch the messages to all the loggers, you can configure this loggers modifying the loggers static property:Each logger has a property named level that you can customize:
The level is an
OptionSet
with 4 basic values:debug
,warning
,error
,severe
and additionallyall
andnone
Logger
You can create and register your own loggers, just implement the
Logger
protocol and add an instance to theloggers
static property of theLog
class. TheLogger
protocol defines a couple of properties,level
andformatter
, and four functions:debug, warn, error
andsevere
that correspond to the log levelsFormatter
You can create your own formatter and use it with the loggers you want, just create a class that implements the
Formatter
protocol and assign it to the logger