RaLog

中文

RaLog 是一个轻量级、高度可定制的、面向协议的日志框架。

通过使用框架提供的类型,或自定义管理类,您可以快速构建自己的日志组件。

要求

安装

CocoaPods

pod 'RaLog'

Swift Package Manager

.Package(url: "https://github.com/RakuyoKit/RaLog.git", ...)

特性

用法

相关内容,请参见 wiki:快速入门

预览

以下代码展示了如何使用 RaLog 进行简单的日志打印。 通过此代码,您可以初步了解 RaLog

更多功能演示,以及完整的示例代码,可以在存储库提供的 demo 中找到(在 Examples 目录中)。

import UIKit
import RaLog

class ViewController: UIViewController {
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
        Log.appear(self)
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        
        Log.disappear(self)
    }
    
    deinit {
        Log.deinit(self)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        Log.debug("Note the output of the console")
        
        Log.warning("Please note that the request is about to start!😎")
        
        // Analog api request
        DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) {
            
            if success {
                Log.success("request success 🥳, content: api request succeeded")
                
            } else {
                Log.error("request failure 😢, error: \("some error")")
            }
        }
    }
}

ViewController 控制器即将被访问时,控制台将输出以下内容。


[↓ In `viewDidLoad()` of ViewController.swift:32 ↓]
[RaLog] 11:17:01:353 <👾 Debug> : Note the output of the console


[↓ In `viewDidLoad()` of ViewController.swift:36 ↓]
[RaLog] 11:17:01:356 <⚠️ Warning> : Please note that the request is about to start!😎


[↓ In `viewDidAppear(_:)` of ViewController.swift:16 ↓]
[RaLog] 11:17:01:370 <👋 Jump> : - Appear - ViewController


[↓ In `viewDidLoad()` of ViewController.swift:42 ↓]
[RaLog] 11:17:02:453 <✅ Success> : request success 🥳, content: api request succeeded

许可证

RaLogMIT 许可证下可用。 有关更多信息,请参见 LICENSE