PrettyLogger 2.0.0

PrettyLogger 2.0.0

Sebastián Varela 维护。



PrettyLogger

CocoaPods Compatible Carthage Compatible Platform Platform Platform Build Status codecov codebeat badge

简介

一套美观的日志函数,使用等级(调试、信息、跟踪、警告和错误)和表情符号来提高可见性💪

平台

支持 iOS、tvOS 和 macOS

支持

Swift 4 请使用 v1

Swift 5 请使用 v2+

安装

此框架与 Carthage 或 Cocoapods 兼容,请使用其中任何一个。

Carthage

将以下内容添加到您的 Cartfile

github "sebastianvarela/PrettyLogger" 

Cocoapods

将以下内容添加到您的 Podfile

pod 'PrettyLogger' 

使用方法

打印信息

要在控制台打印信息,您只需使用任何全局函数即可。

  logWarning("This a warning!!")
  logError("This is showed as error")
  logFatal("This is showed as fatal message")
  logInfo("This is an info message")
  logDebug("This is a debug message")
  logTrace("This is a trace info")

上一个示例将打印:

13:31:59.632 ◉ ⚠️⚠️⚠️ This a warning!! [File.swift:L109]
13:31:59.639 ◉ ❌❌❌ This is showed as error [File.swift:L110]
13:31:59.639 ◉ ☠️☠️☠️ This is showed as fatal message [File.swift:L111]
13:31:59.639 ◉ 🔍 This is an info message [File.swift:L112]
13:31:59.639 ◉ 🐛 This is a debug message [File.swift:L113]
13:31:59.640 ◉ ✏️ This is a trace info [File.swift:L114]

级别

您可以通过在共享实例上设置属性 level 来静音所有日志(或某些级别的日志)。

PrettyLogger.shared.level = .all //To show all messages
PrettyLogger.shared.level = .disable //To silent logger
PrettyLogger.shared.level = .info //To show all message except debug & trace

可用级别(按顺序):禁用、致命、错误、警告、信息、调试、跟踪 & 所有

全局框架

如果您想在项目中导入所有函数,而无需在每个文件中导入 PrettyLogger,则可以在 AppDelegate 中使用此指令。

@_exported import PrettyLogger