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
level
log level to show
message
message to show
error
error 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 word
These messages are displayed only if DEBUG is defined.
Declaration
Swift
static func debug(message: @autoclosure () -> String, error: Error? = nil)
Parameters
message
message to display
error
error 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
message
message to display
error
error to display