无故事王国
2025-07-27 41aa6375f4086c3bbabd00c710c0734b25962d78
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
//  LanternLog.swift
//  Lantern
//
//  Created by JiongXing on 2019/11/12.
//  Copyright © 2021 Shenzhen Hive Box Technology Co.,Ltd All rights reserved.
//
 
import Foundation
 
public struct LanternLog {
    
    /// 日志重要程度等级
    public enum Level: Int {
        case low = 0
        case middle
        case high
        case forbidden
    }
    
    /// 允许输出日志的最低等级。`forbidden`为禁止所有日志
    public static var minimumLevel: Level = .forbidden
    
    public static func low(_ item: @autoclosure () -> Any) {
        if minimumLevel.rawValue <= Level.low.rawValue {
            print("[Lantern] [low]", item())
        }
    }
    
    public static func middle(_ item: @autoclosure () -> Any) {
        if minimumLevel.rawValue <= Level.middle.rawValue {
            print("[Lantern] [middle]", item())
        }
    }
    
    public static func high(_ item: @autoclosure () -> Any) {
        if minimumLevel.rawValue <= Level.high.rawValue {
            print("[Lantern] [high]", item())
        }
    }
}