-
Notifications
You must be signed in to change notification settings - Fork 0
Logging Delete Expired
Mr.P edited this page Aug 25, 2026
·
2 revisions
Remove retained logs older than a number of days or earlier than a specific cutoff date.
- The active log service uses a persistent destination.
-
maxAgeis greater than zero when deleting by age.
AIBudsLog.xcframework
/// Purges log messages older than the specified maximum age.
/// - Parameters:
/// - maxAge: Retention age in days.
/// - completion: Called with an error, or `nil` on success.
func purgeOldLogsWithMaxAge(
_ maxAge: Int,
completion: ((
NSError?
) -> Void)?
)
/// Purges log messages earlier than the specified timestamp.
/// - Parameters:
/// - timestamp: The exclusive cutoff date for retained logs.
/// - completion: Called with an error, or `nil` on success.
func purgeOldLogsBefore(
_ timestamp: Date,
completion: ((
NSError?
) -> Void)?
)/// Purges log messages older than the specified maximum age.
- (void)purgeOldLogsWithMaxAge:(NSInteger)maxAge
completion:(void (^ _Nullable)(NSError * _Nullable error))completion;
/// Purges log messages earlier than the specified timestamp.
- (void)purgeOldLogsBefore:(NSDate *)timestamp
completion:(void (^ _Nullable)(NSError * _Nullable error))completion;See purgeOldLogsWithMaxAge and purgeOldLogsBefore.
let retentionDays = 7
AIBudsLogSDK.logService.purgeOldLogsWithMaxAge(retentionDays) { error in
DispatchQueue.main.async {
if let error {
statusLabel.text = "Cleanup failed: \(error.localizedDescription)"
return
}
statusLabel.text = "Logs older than \(retentionDays) days were deleted"
}
}Delete using an explicit cutoff:
let cutoff = Calendar.current.date(byAdding: .day, value: -7, to: Date())!
AIBudsLogSDK.logService.purgeOldLogsBefore(cutoff) { error in
if let error { print(error.localizedDescription) }
}NSInteger retentionDays = 7;
[AIBudsLogSDK.logService purgeOldLogsWithMaxAge:retentionDays
completion:^(NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (error != nil) {
self.statusLabel.text = [NSString stringWithFormat:
@"Cleanup failed: %@", error.localizedDescription];
return;
}
self.statusLabel.text = @"Expired logs were deleted";
});
}];Delete using an explicit cutoff:
NSDate *cutoff = [[NSCalendar currentCalendar]
dateByAddingUnit:NSCalendarUnitDay
value:-7
toDate:[NSDate date]
options:0];
[AIBudsLogSDK.logService purgeOldLogsBefore:cutoff
completion:^(NSError *error) {
if (error != nil) { NSLog(@"%@", error.localizedDescription); }
}];-
AIBudsLogSDK.setXLFacilityPlugin(_:)automatically purges XLFacility logs using the currentlogFileMaxAgewhen the plugin loads. - Changing
logFileMaxAgeconfigures retention but does not immediately run a new cleanup. Call a purge method when immediate deletion is required. - Purge operations affect the active log service's retained data; console and OS Logger output are not app-managed retained stores.
- Use the completion callback instead of assuming that a background cleanup succeeded.
AIBuds SDK documentation · Full documentation · API Reference
- Introduction
- Getting Started
- Core Concepts
-
Core Features
- Basic Features
- Device Info
- Find Device
- Physical Operations
- Work Mode
- Work Status
- Wear Detection
- Volume Control
- Music Control
- TWS
- Equalizer
- ANC
- Audio
- Camera
- Remote Camera
- File Import
- Teleprompter
- Segment Navigation
- Live Streaming
- Device Applications
- OTA
- Camera OTA
- Service Auth
- AI Services
- Voice Assistant
- Logging
- Advanced Topics
- Releases
- Troubleshooting