You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A logger protocol that provides a common logging interface for different kinds of loggers. In addition, a class with a set of static functions for logging within your code is provided.
Kitura uses this API throughout its implementation when logging.
Prerequisites
Swift
Swift Open Source swift-5.1-RELEASE toolchain (Minimum REQUIRED for latest release)
Swift Open Source swift-5.4-RELEASE toolchain (Recommended)
Swift toolchain included in Xcode Version 11.0 or higher.
Usage
Add dependencies
Add the LoggerAPI package to the dependencies within your application’s Package.swift file. Substitute "x.x.x" with the latest LoggerAPIrelease:
Log.warning("This is a warning.")Log.error("This is an error.")
Define a logger
You need to define a logger in order to output these messages. You may wish to write your own Logger implementation, or you can use HeliumLogger that writes to standard output:
If both logger and swiftLogger are set, then log messages will be sent to both logging backends. The log level configured for a LoggerAPI Logger and a swift-log Logger are independent, so may be used to log at different levels.
Note that because the hierarchy of log levels defined by LoggerAPI and swift-log is slightly different, a mapping is defined between the levels. See the documentation for Log.isLogging() for details.