Log
public struct Log
For logging messages on console.
The log format is <tag><Level> <message> [with error <error>]:
Examples:
[MapCache][DEBUG] Welcome to MapCache
[MapCache][ERROR] Could not download file with error Unknown address
-
The tag [MapCache]
Declaration
Swift
fileprivate static let tag: String -
Log Levels
See moreDeclaration
Swift
fileprivate enum Level : String -
The actual method that prints.
Declaration
Swift
fileprivate static func log(_ level: Level, _ message: @autoclosure () -> String, _ error: Error? = nil)Parameters
levellog level to show
messagemessage to show
errorerror to show if any on addition to the message. Uses the pattern
{message} with error {error} -
For displaying messages. Useful during development of this package.
Example:
Log.debug("Hello world") // prints: [MapCache][DEBUG] Hello wordThese messages are displayed only if DEBUG is defined.
Declaration
Swift
static func debug(message: @autoclosure () -> String, error: Error? = nil)Parameters
messagemessage to display
errorerror to display if any.
-
These messages are displayed independently of the debug mode. Used to provide useful information on exceptional situations to library users. Example:
Log.error("Could not download tile", error) // prints: [MapCache][ERROR] Could not download tile with error No internet connection.Declaration
Swift
static func error(message: @autoclosure () -> String, error: Error? = nil)Parameters
messagemessage to display
errorerror to display
View on GitHub
Log Structure Reference