Skip to content

Instantly share code, notes, and snippets.

@skreutzberger
Created October 13, 2016 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skreutzberger/cc24addedc71392f86c5e7e7acdf0961 to your computer and use it in GitHub Desktop.
Save skreutzberger/cc24addedc71392f86c5e7e7acdf0961 to your computer and use it in GitHub Desktop.
SwiftyBeaver Vapor Example 1
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