https://github.com/vapor-community/multilogging
Logging utility package for Vapor 3
https://github.com/vapor-community/multilogging
logging logging-library spm swfit vapor vapor-3
Last synced: about 1 year ago
JSON representation
Logging utility package for Vapor 3
- Host: GitHub
- URL: https://github.com/vapor-community/multilogging
- Owner: vapor-community
- License: mit
- Created: 2018-06-22T07:21:26.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-21T06:29:13.000Z (almost 7 years ago)
- Last Synced: 2025-04-14T20:43:34.444Z (about 1 year ago)
- Topics: logging, logging-library, spm, swfit, vapor, vapor-3
- Language: Swift
- Size: 20.5 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MultiLogging
[](https://vapor.codes)
[](http://swift.org)
##
MultiLogging is a Vapor 3 utility package for logging. It allows you to log to files, Discord and Slack next to the default console logger. Next to that it allows you to run multiple loggers at once, so you can log to, for example, both Console and Discord
## Installation
MultiLogging can be installed using SPM
```swift
.package(url: "https://github.com/vapor-community/MultiLogging.git", from: "0.0.1")
```
## Usage
Setting up MultiLogging is easy to do and requires only little code.
### Registering a logger
In your `Configure.swift` file, add the following for each logger you want to use:
```swift
services.register(LoggerNameConfig())
services.register(LoggerName.self)
```
So for the Discord logger that'd be something like this:
```swift
services.register(DiscordLoggerConfig(prodURL: "webhookURL", useEmbeds: true))
services.register(DiscordLogger.self)
```
### Setting which loggers to use
If you only want to use one logger, prefer that logger in your config like so:
```swift
config.prefer(DiscordLogger.self, for: Logger.self)
```
If you however want to use multiple, say the discord logger and the default console logger, add the following:
```swift
services.register(MultiLoggerConfig(types: [.discord, .console])) // Order does not matter
services.register(MultiLogger.self)
config.prefer(MultiLogger.self, for: Logger.self)
```
### Advanced
COMMING SOON