Skip to content

Commit c45888b

Browse files
committed
More test cases
1 parent 1fe547f commit c45888b

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Sources/AndroidOSLog/OSLog.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ public struct Logger : @unchecked Sendable {
2121
}
2222

2323
public func log(_ message: OSLogMessage) {
24-
androidLog(priority: ANDROID_LOG_DEFAULT, message: message)
25-
}
26-
27-
public func log(level: OSLogType, _ message: OSLogMessage) {
28-
androidLog(priority: ANDROID_LOG_DEFAULT, message: message)
24+
androidLog(priority: ANDROID_LOG_INFO, message: message)
2925
}
3026

3127
public func trace(_ message: OSLogMessage) {
@@ -60,7 +56,7 @@ public struct Logger : @unchecked Sendable {
6056
androidLog(priority: ANDROID_LOG_FATAL, message: message)
6157
}
6258

63-
public func log(type: OSLogType, message: OSLogMessage) {
59+
public func log(level type: OSLogType, _ message: OSLogMessage) {
6460
let priority: android_LogPriority
6561
switch type {
6662
case .info: priority = ANDROID_LOG_INFO
@@ -75,12 +71,8 @@ public struct Logger : @unchecked Sendable {
7571

7672
private func androidLog(priority: android_LogPriority, message: OSLogMessage) {
7773
let tag = subsystem.isEmpty && category.isEmpty ? "" : (subsystem + "/" + category)
78-
tag.withCString { tagPtr in
79-
message.withCString { messagePtr in
80-
//swift_android_log(priority, tagPtr, messagePtr)
81-
__android_log_write(Int32(priority.rawValue), tagPtr, messagePtr)
82-
}
83-
}
74+
//swift_android_log(priority, tagPtr, messagePtr)
75+
__android_log_write(Int32(priority.rawValue), tag, message)
8476
}
8577
}
8678

Tests/AndroidOSLogTests/AndroidOSLogTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ class AndroidOSLogTests : XCTestCase {
1111

1212
logger.log("Android logger test: LOG message")
1313

14+
logger.trace("Android logger test: TRACE message")
15+
logger.debug("Android logger test: DEBUG message")
1416
logger.info("Android logger test: INFO message")
17+
logger.notice("Android logger test: NOTICE message")
18+
logger.warning("Android logger test: WARNING message")
1519
logger.error("Android logger test: ERROR message")
16-
logger.debug("Android logger test: DEBUG message")
17-
logger.trace("Android logger test: TRACE message")
1820
logger.critical("Android logger test: CRITICAL message")
1921

2022
logger.log(level: OSLogType.default, "Android logger test: DEFAULT message")

0 commit comments

Comments
 (0)