Skip to content

Commit 9c2fb9e

Browse files
committed
LogLevel now Comparable. Added colored icons to description of LogLevels.
1 parent a655e44 commit 9c2fb9e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Sources/MJLLogger/LogLevel.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Foundation
1414
/// - debug: a message only relevant while debugging
1515
/// - enter: a notice of enter a function
1616
/// - exit: a notice of exiting a function
17-
public enum LogLevel: Int, CustomStringConvertible {
17+
public enum LogLevel: Int, Comparable, CustomStringConvertible {
1818
case error = 1
1919
case warn
2020
case info
@@ -24,13 +24,15 @@ public enum LogLevel: Int, CustomStringConvertible {
2424

2525
public var description: String {
2626
switch self {
27-
case .error: return "ERROR"
28-
case .warn: return "WARN"
29-
case .info: return "INFO"
30-
case .debug: return "DEBUG"
31-
case .enter: return "ENTER"
32-
case .exit: return "EXIT"
27+
case .error: return "❤️ ERROR"
28+
case .warn: return "💛 WARN"
29+
case .info: return "💜 INFO"
30+
case .debug: return "🖤 DEBUG"
31+
case .enter: return "💙 ENTER"
32+
case .exit: return "💙 EXIT"
3333
}
3434
}
35-
35+
public static func <(lhs: LogLevel, rhs: LogLevel) -> Bool {
36+
return lhs.rawValue < rhs.rawValue
37+
}
3638
}

0 commit comments

Comments
 (0)