Created
October 13, 2016 07:30
-
-
Save skreutzberger/cc24addedc71392f86c5e7e7acdf0961 to your computer and use it in GitHub Desktop.
SwiftyBeaver Vapor Example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Vapor | |
import SwiftyBeaverVapor | |
import SwiftyBeaver | |
// set-up SwiftyBeaver logging destinations (console, file, cloud, ...) | |
let console = ConsoleDestination() // log to Xcode Console in color | |
let file = FileDestination() // log to file | |
file.logFileURL = URL(string: "file:///tmp/VaporLogs.log")! // set log file | |
// add SwiftyBeaver destination instances to SwiftyBeaver Logging Provider | |
let sbProvider = SwiftyBeaverProvider(destinations: [console, file]) | |
// create Droplet | |
let app = Droplet(initializedProviders: [sbProvider]) | |
let log = app.log.self // to avoid writing app.log all the time | |
app.get("/") { request in | |
log.verbose("not so important") | |
log.debug("something to debug") | |
log.info("a nice information") | |
log.warning("oh no, that won’t be good") | |
log.error("ouch, an error did occur!") | |
return "welcome!" | |
} | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment