Always flush logger in owsFailDebug

This commit is contained in:
Sasha Weiss
2025-10-15 14:48:27 -07:00
committed by GitHub
parent 74f9698ce7
commit 38b9f69c41
5 changed files with 8 additions and 24 deletions

View File

@@ -36,10 +36,8 @@ class NSEEnvironment {
didStartAppSetup = true
}
logger.info(
"pid: \(ProcessInfo.processInfo.processIdentifier), memoryUsage: \(LocalDevice.memoryUsageString)",
flushImmediately: true
)
logger.info("pid: \(ProcessInfo.processInfo.processIdentifier), memoryUsage: \(LocalDevice.memoryUsageString)")
logger.flush()
}
@MainActor

View File

@@ -104,7 +104,8 @@ class NotificationService: UNNotificationServiceExtension {
// Detect and handle "no GRDB file" and "no keychain access".
if !hasShownFirstUnlockError {
hasShownFirstUnlockError = true
logger.error("DB Keys not accessible; showing error.", flushImmediately: true)
logger.error("DB Keys not accessible; showing error.")
logger.flush()
let content = UNMutableNotificationContent()
let notificationFormat = OWSLocalizedString(
"NOTIFICATION_BODY_PHONE_LOCKED_FORMAT",
@@ -115,7 +116,8 @@ class NotificationService: UNNotificationServiceExtension {
} else {
// Only show a single error if we receive multiple pushes
// before first device unlock.
logger.error("DB Keys not accessible; completing silently.", flushImmediately: true)
logger.error("DB Keys not accessible; completing silently.")
logger.flush()
let emptyContent = UNMutableNotificationContent()
return emptyContent
}

View File

@@ -16,7 +16,7 @@ public func owsFailBeta(
if FeatureFlags.isPrerelease {
owsFail(logMessage, file: file, function: function, line: line)
} else {
Logger.error(logMessage, file: file, function: function, line: line)
owsFailDebug(logMessage, file: file, function: function, line: line)
}
}

View File

@@ -46,11 +46,11 @@ public func owsFailDebug(
line: Int = #line
) {
logger.error(logMessage, file: file, function: function, line: line)
logger.flush()
if IsDebuggerAttached() {
TrapDebugger()
} else if Preferences.isFailDebugEnabled {
Preferences.setIsFailDebugEnabled(false)
logger.flush()
fatalError(logMessage)
} else {
assertionFailure(logMessage)
@@ -67,7 +67,6 @@ public func owsFail(
) -> Never {
logger.error(Thread.callStackSymbols.joined(separator: "\n"))
owsFailDebug(logMessage, logger: logger, file: file, function: function, line: line)
logger.flush()
fatalError(logMessage)
}

View File

@@ -32,7 +32,6 @@ open class PrefixedLogger {
open func verbose(
_ logString: @autoclosure () -> String,
flushImmediately: Bool = false,
file: String = #fileID,
function: String = #function,
line: Int = #line
@@ -43,13 +42,10 @@ open class PrefixedLogger {
function: function,
line: line
)
if flushImmediately { flush() }
}
open func debug(
_ logString: @autoclosure () -> String,
flushImmediately: Bool = false,
file: String = #fileID,
function: String = #function,
line: Int = #line
@@ -60,13 +56,10 @@ open class PrefixedLogger {
function: function,
line: line
)
if flushImmediately { flush() }
}
open func info(
_ logString: @autoclosure () -> String,
flushImmediately: Bool = false,
file: String = #fileID,
function: String = #function,
line: Int = #line
@@ -77,13 +70,10 @@ open class PrefixedLogger {
function: function,
line: line
)
if flushImmediately { flush() }
}
open func warn(
_ logString: @autoclosure () -> String,
flushImmediately: Bool = false,
file: String = #fileID,
function: String = #function,
line: Int = #line
@@ -94,13 +84,10 @@ open class PrefixedLogger {
function: function,
line: line
)
if flushImmediately { flush() }
}
open func error(
_ logString: @autoclosure () -> String,
flushImmediately: Bool = false,
file: String = #fileID,
function: String = #function,
line: Int = #line
@@ -111,8 +98,6 @@ open class PrefixedLogger {
function: function,
line: line
)
if flushImmediately { flush() }
}
open func flush() {