SwiftBoxLogging
Logging system for Swift/Vapor.
Official https://github.com/apple/swift-log package should be used instead, this package is deprecated.

General
Usage
1. Import
import SwiftBoxLogging
2. Bootstrap
Logging should be bootstrapped before use (it defaults to PrintLogger
).
Bootstrap requires one parameter which is the logger factory.
Logger factory must return Logger
from Console/Logging
package.
Logging.bootstrap({ name in Logger2(name) })
2. Usage
Create a logger instance:
fileprivate var logger = Logging.make(#file)
Log a message:
logger.verbose("verbose")
logger.debug("debug")
logger.info("info")
logger.warning("warning")
logger.error("error")
logger.fatal("fatal")
Custom Loggers
To create custom loggers your class must conform to Logger
protocol from Console/Logging
package.
Vapor
You can use same logging in Vapor and logging package:
private func configureLogging(_ config: inout Config, _ env: inout Environment, _ services: inout Services) {
/// Register Logger2
services.register(Logger2.self)
switch env {
case .production:
config.prefer(Logger2.self, for: Logger.self)
Logging.bootstrap({ name in Logger2(name) })
default:
config.prefer(PrintLogger.self, for: Logger.self)
Logging.bootstrap({ _ in PrintLogger() })
}
}
SwiftBoxLogging
Logging system for Swift/Vapor. Official https://github.com/apple/swift-log package should be used instead, this package is deprecated.
General
Usage
1. Import
2. Bootstrap
Logging should be bootstrapped before use (it defaults to
PrintLogger
). Bootstrap requires one parameter which is the logger factory. Logger factory must returnLogger
fromConsole/Logging
package.2. Usage
Create a logger instance:
Log a message:
Custom Loggers
To create custom loggers your class must conform to
Logger
protocol fromConsole/Logging
package.Vapor
You can use same logging in Vapor and logging package: