Skip to content

Commit 55f739c

Browse files
authored
chore: logging timestamp tweaks (#5480)
1 parent 4e3915a commit 55f739c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Sources/Swift/Core/Tools/SentryLog.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ typealias SentryLogOutput = ((String) -> Void)
3434
public static func log(message: String, andLevel level: SentryLevel) {
3535
guard willLog(atLevel: level) else { return }
3636

37-
// We use the timeIntervalSinceReferenceDate because date format is
37+
// We use the time interval because date format is
3838
// expensive and we only care about the time difference between the
3939
// log messages. We don't use system uptime because of privacy concerns
4040
// see: NSPrivacyAccessedAPICategorySystemBootTime.
4141
let time = self.dateProvider.date().timeIntervalSince1970
42-
logOutput("[Sentry] [\(level)] [timeIntervalSince1970:\(time)] \(message)")
42+
logOutput("[Sentry] [\(level)] [\(time)] \(message)")
4343
}
4444

4545
/**

Tests/SentryTests/Helper/SentryLogTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SentryLogTests: XCTestCase {
3838
SentryLog.log(message: "2", andLevel: SentryLevel.warning)
3939
SentryLog.log(message: "3", andLevel: SentryLevel.none)
4040

41-
XCTAssertEqual(["[Sentry] [fatal] [timeIntervalSince1970:\(timeIntervalSince1970)] 0", "[Sentry] [error] [timeIntervalSince1970:\(timeIntervalSince1970)] 1"], logOutput.loggedMessages)
41+
XCTAssertEqual(["[Sentry] [fatal] [\(timeIntervalSince1970)] 0", "[Sentry] [error] [\(timeIntervalSince1970)] 1"], logOutput.loggedMessages)
4242
}
4343

4444
func testDefaultInitOfLogoutPut() {
@@ -61,7 +61,7 @@ class SentryLogTests: XCTestCase {
6161

6262
// -- Assert --
6363
XCTAssertEqual(1, logOutput.loggedMessages.count)
64-
XCTAssertEqual("[Sentry] [fatal] [timeIntervalSince1970:\(timeIntervalSince1970)] fatal", logOutput.loggedMessages.first)
64+
XCTAssertEqual("[Sentry] [fatal] [\(timeIntervalSince1970)] fatal", logOutput.loggedMessages.first)
6565
}
6666

6767
func testLevelNone_PrintsEverythingExceptNone() {
@@ -76,11 +76,11 @@ class SentryLogTests: XCTestCase {
7676
SentryLog.log(message: "4", andLevel: SentryLevel.debug)
7777
SentryLog.log(message: "5", andLevel: SentryLevel.none)
7878

79-
XCTAssertEqual(["[Sentry] [fatal] [timeIntervalSince1970:\(timeIntervalSince1970)] 0",
80-
"[Sentry] [error] [timeIntervalSince1970:\(timeIntervalSince1970)] 1",
81-
"[Sentry] [warning] [timeIntervalSince1970:\(timeIntervalSince1970)] 2",
82-
"[Sentry] [info] [timeIntervalSince1970:\(timeIntervalSince1970)] 3",
83-
"[Sentry] [debug] [timeIntervalSince1970:\(timeIntervalSince1970)] 4"], logOutput.loggedMessages)
79+
XCTAssertEqual(["[Sentry] [fatal] [\(timeIntervalSince1970)] 0",
80+
"[Sentry] [error] [\(timeIntervalSince1970)] 1",
81+
"[Sentry] [warning] [\(timeIntervalSince1970)] 2",
82+
"[Sentry] [info] [\(timeIntervalSince1970)] 3",
83+
"[Sentry] [debug] [\(timeIntervalSince1970)] 4"], logOutput.loggedMessages)
8484
}
8585

8686
func testMacroLogsErrorMessage() {
@@ -90,7 +90,7 @@ class SentryLogTests: XCTestCase {
9090

9191
sentryLogErrorWithMacro("error")
9292

93-
XCTAssertEqual(["[Sentry] [error] [timeIntervalSince1970:\(timeIntervalSince1970)] [SentryLogTestHelper:20] error"], logOutput.loggedMessages)
93+
XCTAssertEqual(["[Sentry] [error] [\(timeIntervalSince1970)] [SentryLogTestHelper:20] error"], logOutput.loggedMessages)
9494
}
9595

9696
func testMacroDoesNotEvaluateArgs_WhenNotMessageNotLogged() {
@@ -109,7 +109,7 @@ class SentryLogTests: XCTestCase {
109109
SentryLogSwiftSupport.configure(true, diagnosticLevel: SentryLevel.debug)
110110
let line = #line + 1
111111
SentryLog.debug("Debug Log")
112-
XCTAssertEqual(["[Sentry] [debug] [timeIntervalSince1970:\(timeIntervalSince1970)] [SentryLogTests:\(line)] Debug Log"], logOutput.loggedMessages)
112+
XCTAssertEqual(["[Sentry] [debug] [\(timeIntervalSince1970)] [SentryLogTests:\(line)] Debug Log"], logOutput.loggedMessages)
113113
}
114114

115115
/// This test only ensures we're not crashing when calling configure and log from multiple threads.

0 commit comments

Comments
 (0)