diff --git a/apps/macos/Sources/Clawdis/DebugActions.swift b/apps/macos/Sources/Clawdis/DebugActions.swift index 6f22e405b..1099e478c 100644 --- a/apps/macos/Sources/Clawdis/DebugActions.swift +++ b/apps/macos/Sources/Clawdis/DebugActions.swift @@ -114,7 +114,7 @@ enum DebugActions { } static func pinoLogPath() -> String { - LogLocator.bestLogFile()?.path ?? LogLocator.legacyLogPath + LogLocator.bestLogFile()?.path ?? LogLocator.launchdLogPath } @MainActor diff --git a/apps/macos/Sources/Clawdis/LogLocator.swift b/apps/macos/Sources/Clawdis/LogLocator.swift index 1b45bb4a2..f437b8176 100644 --- a/apps/macos/Sources/Clawdis/LogLocator.swift +++ b/apps/macos/Sources/Clawdis/LogLocator.swift @@ -2,36 +2,28 @@ import Foundation enum LogLocator { private static let logDir = URL(fileURLWithPath: "/tmp/clawdis") - private static let legacyLog = logDir.appendingPathComponent("clawdis.log") + private static let stdoutLog = logDir.appendingPathComponent("clawdis-stdout.log") - /// Returns the newest rolling log (clawdis-YYYY-MM-DD.log) if it exists, falling back to the legacy single-file log. + /// Returns the newest log file under /tmp/clawdis/ (rolling or stdout), or nil if none exist. static func bestLogFile() -> URL? { let fm = FileManager.default - let rollingFiles = (try? fm.contentsOfDirectory( + let files = (try? fm.contentsOfDirectory( at: logDir, includingPropertiesForKeys: [.contentModificationDateKey], options: [.skipsHiddenFiles])) ?? [] - let newestRolling = rollingFiles - .filter { $0.lastPathComponent.hasPrefix("clawdis-") && $0.pathExtension == "log" } + return files + .filter { $0.lastPathComponent.hasPrefix("clawdis") && $0.pathExtension == "log" } .sorted { lhs, rhs in let lDate = (try? lhs.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPast let rDate = (try? rhs.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate) ?? .distantPast return lDate > rDate } .first - - if let rolling = newestRolling { - return rolling - } - if fm.fileExists(atPath: legacyLog.path) { - return legacyLog - } - return nil } - /// Legacy path used by launchd stdout/err; exposed for plist generation. - static var legacyLogPath: String { - legacyLog.path + /// Path to use for launchd stdout/err. + static var launchdLogPath: String { + stdoutLog.path } } diff --git a/apps/macos/Sources/Clawdis/Utilities.swift b/apps/macos/Sources/Clawdis/Utilities.swift index 11089011d..d6eb5a19e 100644 --- a/apps/macos/Sources/Clawdis/Utilities.swift +++ b/apps/macos/Sources/Clawdis/Utilities.swift @@ -80,9 +80,9 @@ enum LaunchAgentManager { StandardOutPath - \(LogLocator.legacyLogPath) + \(LogLocator.launchdLogPath) StandardErrorPath - \(LogLocator.legacyLogPath) + \(LogLocator.launchdLogPath) """