目录
目录README.md

MultiLogging

Vapor 3 Swift 4.1

#

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

.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:

services.register(LoggerNameConfig(<params>))
services.register(LoggerName.self)

So for the Discord logger that’d be something like this:

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:

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:

services.register(MultiLoggerConfig(types: [.discord, .console])) // Order does not matter
services.register(MultiLogger.self)
config.prefer(MultiLogger.self, for: Logger.self)

Advanced

COMMING SOON

关于
56.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号