forked from AgoraIO/API-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogUtils.swift
More file actions
40 lines (33 loc) · 825 Bytes
/
LogUtils.swift
File metadata and controls
40 lines (33 loc) · 825 Bytes
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
//
// LogViewController.swift
// APIExample
//
// Created by 张乾泽 on 2020/4/17.
// Copyright © 2020 Agora Corp. All rights reserved.
//
import Foundation
enum LogLevel {
case info, warning, error
var description: String {
switch self {
case .info: return "Info"
case .warning: return "Warning"
case .error: return "Error"
}
}
}
struct LogItem {
var message:String
var level:LogLevel
var dateTime:Date
}
class LogUtils {
static var logs:[LogItem] = []
static func log(message: String, level: LogLevel) {
LogUtils.logs.append(LogItem(message: message, level: level, dateTime: Date()))
print("\(level.description): \(message)")
}
static func removeAll() {
LogUtils.logs.removeAll()
}
}