https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor
SwiftyBeaver Logging Provider for Vapor, the server-side Swift web framework
https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor
Last synced: 5 months ago
JSON representation
SwiftyBeaver Logging Provider for Vapor, the server-side Swift web framework
- Host: GitHub
- URL: https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor
- Owner: SwiftyBeaver
- License: mit
- Created: 2016-09-01T07:33:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-06-17T08:32:00.000Z (almost 3 years ago)
- Last Synced: 2024-10-30T17:18:26.364Z (6 months ago)
- Language: Swift
- Homepage: https://swiftybeaver.com
- Size: 36.1 KB
- Stars: 97
- Watchers: 2
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-Swift-Packages - SwiftyBeaver-Vapor - SwiftyBeaver Logging Provider for Vapor, the server-side Swift web framework https://swiftybeaver.com. (Logger)
- TheList - Vapor SwiftyBeaver - Logging Provider for Vapor, the server-side Swift 3 web framework (Server Side Utilities / Logging)
README
# SwiftyBeaver Logging Provider for Vapor
[](https://swift.org)
[](http://vapor.codes/)
[](https://github.com/SwiftyBeaver/SwiftyBeaver)
[](https://slack.swiftybeaver.com)Adds the powerful logging of [SwiftyBeaver](https://github.com/SwiftyBeaver/SwiftyBeaver) to [Vapor](https://github.com/vapor/vapor) for server-side Swift on Linux and Mac.
## Installation
Add this to the `Package.swift` of your Vapor project:
```swift
dependencies: [
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor.git", from: "1.1.0"),
//...other packages here
],
targets: [
.target(name: "App", dependencies: [
.product(name: "SwiftyBeaverVapor", package: "SwiftyBeaver-Vapor")
//...other packages here
])
]
```
## Setup
In `configure.swift`:
```swiftimport SwiftyBeaverVapor
import SwiftyBeaver/// Called before your application initializes.
public func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {
// ...// console logging
let consoleDestination = ConsoleDestination()
try services.register(SwiftyBeaverProvider(destinations: [consoleDestination]))
// OR console and cloud platform logging
let consoleDestination = ConsoleDestination()
let cloudDestination = SBPlatformDestination(appID: "xxx", appSecret: "xxxxxx", encryptionKey: "xxxxx")
try services.register(SwiftyBeaverProvider(destinations: [consoleDestination, cloudDestination]))config.prefer(SwiftyBeaverVapor.self, for: Logger.self)
// ...
}
```Add the SwiftyBeaver [logging destinations](http://docs.swiftybeaver.com/category/8-logging-destinations) you want to use, optionally adjust their defaults like format, color, filter or minimum log level and you are ready to log 🙌
## Use
For example, you can log requests as they come in.
```swift
func index(_ req: Request) throws -> Future<[Foo]> {let logger = try? req.sharedContainer.make(Logger.self)
logger?.log(req.description, at: .verbose, file: #file, function: #function, line: #line, column: #column)return Foo.query(on: req).all()
}```
For more information see the SwiftyBeaver [destination docs](http://docs.swiftybeaver.com/category/8-logging-destinations) and how to set a [custom logging format](http://docs.swiftybeaver.com/category/19-advanced-topics).
## Output to Xcode 8 Console
[Learn more](http://docs.swiftybeaver.com/article/9-log-to-xcode-console) about colored logging to Xcode 8 Console.
## Output to File
[Learn more](http://docs.swiftybeaver.com/article/10-log-to-file) about logging to file which is great for Terminal.app fans or to store logs on disk.
## Output to Cloud & Mac App

[Learn more](http://docs.swiftybeaver.com/article/11-log-to-swiftybeaver-platform) about logging to the SwiftyBeaver Platform **during release!**
## Learn More
- [Website](https://swiftybeaver.com)
- [SwiftyBeaver Framework](https://github.com/SwiftyBeaver/SwiftyBeaver)
- [Documentation](http://docs.swiftybeaver.com/)
- [Medium Blog](https://medium.com/swiftybeaver-blog)
- [On Twitter](https://twitter.com/SwiftyBeaver)Get support via Github Issues, email and our public Slack channel.
## License
SwiftyBeaverVapor is released under the [MIT License](https://github.com/SwiftyBeaver/SwiftyBeaver-Vapor/blob/master/LICENSE).