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
Logis 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
OptionSetwith 4 basic values:debug,warning,error,severeand additionallyallandnoneLogger
You can create and register your own loggers, just implement the
Loggerprotocol and add an instance to theloggersstatic property of theLogclass. TheLoggerprotocol defines a couple of properties,levelandformatter, and four functions:debug, warn, errorandseverethat 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
Formatterprotocol and assign it to the logger