A Swifty logging interface
--
This library is meant to offer a common interface to logging systems, simple or sophisticated. To be able to start light, integrate later good logging facilities, and even later changes the logging facilities, without changing all the code.
In your module you define one logger. And in the rest of your code use that logger to record messages and informations.
// Logger.swift
import Gazooee
let logger = Logger(subsystem: "MyLibrary")
// MyClass.swift
class MyClass {
func foo() {
logger.error("Huston, we've got a problem")
}
}
If you develop an App, you'll certainly want to configure how to treat logs: filter them, direct some logs to the console, or to another destination, etc… Those settings will apply to your code and your dependencies.
By default it logs everything, and simply print
it.
// main.swift
import GazooeeConfig
masterDestination = Filter(above: .warn, destination: ConsoleNSLog())
There is 1 main point of extension: you can implement new Destination
s to redirect logs to another system of logging (like, say, SwiftyBeaver), or managing routing in a different way.
You can also implement Formatter
to format a logs in your own way.
See the sample targets in the project.
For Swift Package Manager add the following to your dependencies, in your Package.swift
file:
.Package(url: "https://github.com/Nelyus/Gazooee.git", majorVersion: 0, minor: 3)
For exemple:
let package = Package(
name: "MyPackage",
dependencies: [.Package(url: "https://github.com/Nelyus/Gazooee.git", majorVersion: 0, minor: 3)]
)
There is currently 4 levels of logging: error, warn, info, debug.
A record consist of an arbitrary value, the level, the subsystem (eg: the module), the file, the line and the function