diff --git a/Sources/Logging/Logging.swift b/Sources/Logging/Logging.swift index 01c354a..49cda79 100644 --- a/Sources/Logging/Logging.swift +++ b/Sources/Logging/Logging.swift @@ -304,7 +304,7 @@ extension Logger { /// /// Raw values of log levels correspond to their severity, and are ordered by lowest numeric value (0) being /// the most severe. The raw values match the syslog values. - public enum Level { + public enum Level: CaseIterable { /// Appropriate for messages that contain information only when debugging a program. case trace diff --git a/Tests/LoggingTests/LocalLoggingTest.swift b/Tests/LoggingTests/LocalLoggingTest.swift index 9d8378b..75c8492 100644 --- a/Tests/LoggingTests/LocalLoggingTest.swift +++ b/Tests/LoggingTests/LocalLoggingTest.swift @@ -65,8 +65,8 @@ class LocalLoggerTest: XCTestCase { logging.history.assertNotExist(level: .info, message: "TestLibrary::doSomethingAsync") // global context logging.history.assertExist(level: .debug, message: "Struct3::doSomethingElse::Local", metadata: ["bar": "baz", "baz": "qux"]) // hyper local context logging.history.assertExist(level: .debug, message: "Struct3::doSomethingElse::end", metadata: ["bar": "baz"]) // local context - logging.history.assertExist(level: .debug, message: "Struct3::doSomething::end", metadata: ["bar": "baz"]) // local context logging.history.assertExist(level: .debug, message: "Struct2::doSomethingElse::end") // local context + logging.history.assertExist(level: .debug, message: "Struct3::doSomething::end", metadata: ["bar": "baz"]) // local context logging.history.assertNotExist(level: .debug, message: "Struct1::doSomethingElse::end") // global context logging.history.assertNotExist(level: .debug, message: "Struct1::doSomething::end") // global context } diff --git a/Tests/LoggingTests/LoggingTest+XCTest.swift b/Tests/LoggingTests/LoggingTest+XCTest.swift index 1365e65..31dcfe3 100644 --- a/Tests/LoggingTests/LoggingTest+XCTest.swift +++ b/Tests/LoggingTests/LoggingTest+XCTest.swift @@ -40,6 +40,7 @@ extension LoggingTest { ("testLoggingAString", testLoggingAString), ("testMultiplexerIsValue", testMultiplexerIsValue), ("testLoggerWithGlobalOverride", testLoggerWithGlobalOverride), + ("testLogLevelCases", testLogLevelCases), ("testLogLevelOrdering", testLogLevelOrdering), ] } diff --git a/Tests/LoggingTests/LoggingTest.swift b/Tests/LoggingTests/LoggingTest.swift index 9fb3fb7..4b4677e 100644 --- a/Tests/LoggingTests/LoggingTest.swift +++ b/Tests/LoggingTests/LoggingTest.swift @@ -388,6 +388,11 @@ class LoggingTest: XCTestCase { logRecorder.assertExist(level: .notice, message: "logger1, after") logRecorder.assertExist(level: .notice, message: "logger2, after") } + + func testLogLevelCases() { + let levels = Logger.Level.allCases + XCTAssertEqual(7, levels.count) + } func testLogLevelOrdering() { XCTAssertLessThan(Logger.Level.trace, Logger.Level.debug)