class LoggingBuilder
cangjie
public class LoggingBuilder功能:提供日志系统的配置构建能力。
成员概览
| 成员 | 功能 |
|---|---|
| init(ServiceCollection) | 使用指定服务集合创建日志构建器。 |
| prop services | 获取当前绑定的服务集合。 |
init(ServiceCollection)
cangjie
public init(services: ServiceCollection)功能:使用指定服务集合创建日志构建器。
参数:
- services: ServiceCollection - 日志相关服务的容器。
prop services
cangjie
public prop services: ServiceCollection功能:获取当前绑定的服务集合。
扩展成员
| 成员 | 功能 |
|---|---|
| func setMinimumLevel(LogLevel) | 设置全局最低日志级别。 |
| func addProvider(ILoggerProvider) | 注册日志提供程序。 |
| func clearProviders() | 清除已注册的日志提供程序。 |
| func addFilter((?String, ?String, LogLevel) -> Bool) | 添加自定义过滤函数。 |
| func addFilter((?String, LogLevel) -> Bool) | 添加按分类和级别过滤的规则。 |
| func addFilter((LogLevel) -> Bool) | 添加仅按级别过滤的规则。 |
| func addFilter(?String, LogLevel) | 添加按分类名和最低级别过滤的规则。 |
| func addFilter(?String, (LogLevel) -> Bool) | 添加按分类名和级别判断函数过滤的规则。 |
func setMinimumLevel(LogLevel)
cangjie
public func setMinimumLevel(level: LogLevel): LoggingBuilder功能:设置全局最低日志级别。
参数:
- level: LogLevel - 全局最低级别。
返回值:
- LoggingBuilder - 返回当前构建器。
func addProvider(ILoggerProvider)
cangjie
public func addProvider(provider: ILoggerProvider)功能:注册日志提供程序。
参数:
- provider: ILoggerProvider - 要注册的提供程序实例。
返回值:
Unit- 返回当前构建器。
func clearProviders()
cangjie
public func clearProviders()功能:清除已注册的日志提供程序。
返回值:
Unit- 返回当前构建器。
func addFilter((?String, ?String, LogLevel) -> Bool)
cangjie
public func addFilter(filter: (?String, ?String, LogLevel) -> Bool)功能:添加自定义过滤函数。
参数:
- filter: (?String, ?String, LogLevel) -> Bool - 判断是否允许输出日志的函数。
返回值:
Unit- 返回当前构建器。
func addFilter((?String, LogLevel) -> Bool)
cangjie
public func addFilter(categoryLevelFilter: (?String, LogLevel) -> Bool)功能:添加按分类和级别过滤的规则。
参数:
- categoryLevelFilter: (?String, LogLevel) -> Bool - 按分类和级别判断是否允许输出的函数。
返回值:
Unit- 返回当前构建器。
func addFilter((LogLevel) -> Bool)
cangjie
public func addFilter(levelFilter: (LogLevel) -> Bool)功能:添加仅按级别过滤的规则。
参数:
- levelFilter: (LogLevel) -> Bool - 按级别判断是否允许输出的函数。
返回值:
Unit- 返回当前构建器。
func addFilter(?String, LogLevel)
cangjie
public func addFilter(category: ?String, level: LogLevel)功能:添加按分类名和最低级别过滤的规则。
参数:
- category:
?String- 适用的分类名称。 - level: LogLevel - 允许输出的最低级别。
返回值:
Unit- 返回当前构建器。
func addFilter(?String, (LogLevel) -> Bool)
cangjie
public func addFilter(category: ?String, levelFilter: (LogLevel) -> Bool)功能:添加按分类名和级别判断函数过滤的规则。
参数:
- category:
?String- 适用的分类名称。 - levelFilter: (LogLevel) -> Bool - 按级别判断是否允许输出的函数。
返回值:
Unit- 返回当前构建器。