CocoaLumberjack - File rolling when maximum file size is exceeded not working - cocoa-touch

I want to set up logging which creates a new file once the original file exceeds 1MB, up to a maximum of 5 files.
The issue is that currently I'm seeing the log file far exceeds 1MB and doesn't create a new file.
I'm using Objective C with CocoaLumberjack installed from CocoaPods. Testing with iphone simulator.
This is my code:
DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
[fileLogger setRollingFrequency:-1];
[fileLogger setMaximumFileSize:1024*1024];
[[fileLogger logFileManager] setMaximumNumberOfLogFiles:5];
[DDLog addLogger:fileLogger];
I can't see where I've gone wrong but can't see anyone experiencing similar issues recently so I don't think there's a bug around it. Can anyone shed some light for me? Could it be to do with the iphone simulator? I unfortunately don't have a device at hand to test it on.

Related

How do I access logs from the past day with os_log from Apple Watch?

I'm trying to troubleshoot an issue on watchOS.
I'm not sure how to reproduce the problem I'm seeing, but I do encounter it occasionally during testing on a real device in the wild, so I'm trying to use os_log in order to diagnose the problem after the fact.
As a first step, to make sure I understand how how to write to the log and access it later, I've attempted to log an event any time the app first loads.
In the ExtensionDelegate.swift file for my app, I added this:
import os.log
extension OSLog {
private static var subsystem = Bundle.main.bundleIdentifier!
static let health = OSLog(subsystem: subsystem,
category: "health")
}
Then, I updated the applicationDidBecomeActive delegate function with this:
func applicationDidBecomeActive() {
os_log("App Started",
log: OSLog.health,
type: .error)
}
I know it's not really an error message, but from what I've read, messages that are not .error are not written to saved to the log for later. I want to make sure it gets written to the log like a real error would.
I installed the sysdiagnose profile, then installed the the most recent version of my app.
After testing the app for the day, I attempted to export the file. Following the instructions I've found elsewhere, I produced a sysdiagnose on Apple Watch by holding the Digital Crown and Side button for two seconds (and felt the haptic feedback when I released).
Then, I put the watch on the charger for a few minutes per the instructions here, which recommended 15 minutes.
I opened the Watch app on my paired iPhone, then went to General > Diagnostic Logs and downloaded the sysdiagnose from Apple Watch, and sent it to my computer with AirDrop.
This gave me a tarball file (for example, sysdiagnose_2021.03.05_17-01-57-0700_Watch-OS_Watch_18S801.tar.gz). Once I decompressed that, I had a folder of lots of files and subfolders.
After poking around in this folder, I figured my best bet was to look in the system_logs.logarchive file. I opened that in the macOS Console app, set the Showing dropdown to All Messages, and looked around the time I opened the app. I didn't see any log output from my app.
I also filtered for "App Started" (the log message from my app) and didn't find anything.
Then, I filtered by category for "health" and didn't find the event I had logged.
Is system_logs.logarchive the correct place to be looking for the log output from my app?
If not, where should I be looking? Or what am I doing wrong?
I really want a better understanding of how I can log messages on Apple Watch so I can view them later so I can make my Apple Watch apps more robust, but I'm at a dead end.
Am I looking in the wrong place? Or am I setting up the logging wrong? Or is it something else? I would appreciate any guidance about this!
According to the Apple Dev Forms, sysdiagnose allows you to view the logs on your apple watch.

Enable Transfer Acceleration for AWS SDK for macos

Disclaimer: I posted this originally on Code Review but as the code does not currently work I was suggested to post at SO instead.
I have converted the official AWS SDK iOS (v 2.5.0) framework (focusing on S3) to macOS and everything is working as expected with uploads and downloads. However, I wanted to also enable Transfer Acceleration for S3 using AWSTransferManager. I know that you can enable Transfer Acceleration (TA) using the AWSTransferUtility, but that utility uses pre-signed requests that are valid for only 50 minutes (useful for iOS but not macOS). I would like to be able to transfer files that are large and can take hours even when using Transfer Acceleration.
I have edited the original code from AWS to enable TA for AWSTransferManager, however, I still can not get this to work properly as the final signing of the upload/download request fails. The error message is:
Message=The request signature we calculated does not match the signature you provided. Check your key and signing method.}]
For the most part, I have edited the files AWSSignature, AWSS3TransferManager, and AWSService (AWSServiceConfiguration). I think that the signing error occurs because I am editing a path, or URL without correctly code signing the change (probably in AWSSignature.m). As I am uncertain as to where my code breaks, I have created a repository with all of the AWS SKD macOS files required to compile the framework including a unit test. If I run the test initializing the call to AWSServiceConfiguration with:
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc]initWithRegion:[region aws_regionTypeValue] credentialsProvider:credentialsProvider
accelerateModeEnabled:#(NO)
bucketName:self.testBucketName];
Then everything works as expected and the test file uploads and downloads correctly. However, if I try to turn transfer acceleration on (I have already made sure that my bucket has acceleration enabled), then it fails with the code signing error above.
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc]initWithRegion:[region aws_regionTypeValue] credentialsProvider:credentialsProvider
accelerateModeEnabled:#(YES)
bucketName:self.testBucketName];
In fact it seems like the test script is trying to upload a file much larger than what the testfile (3 Mb) really is. I assume my error is related to the signing of the URL body in some way as the size of the file seems wrong.
I know that finding this error requires a bigger effort than what is usually expected at SO and it is not something many will throw themselves at (but hopefully some) as it involves very complex code and it is time-consuming. However, I do believe that if we could make this work then many can find the framework for AWS SKD for macOS + Transfer Acceleration very useful.
I hope you will take a look at try to identify what may be my problem breaking the code signing.
All code for the framework+test example is available here: https://github.com/trondkr/aws-sdk-macos-TA. To run the unit test you need to provide the secret key and access id to your AWS S3 and the name of a bucket that has transfer acceleration enabled.
Thanks. Cheers, Trond

Handling iOS 8's Changes To App Containers within Xamarin (alternative to Environment.GetFolderPath)

Per the thread started at (http://forums.xamarin.com/discussion/24860/documents-directory-has-moved-in-ios-8#latest), we are working to adapt our App to the recent changes make in iOS regarding accessing the iOS 8 file structure. We have reviewed and attempted the implementation of the code found within the iOS 8 Note at http://developer.xamarin.com/guides/ios/application_fundamentals/working_with_the_file_system/#Creating_Files_and_Directories, and while the results of the sample code does provide some environment
variables, some additional instructions and how to get the results to behave in the same manner as Environment.GetFolderPath would be helpful – or guidance on whatever the appropriate approach should be.
The following takes place after a Release archive is built and pushed to an iPad device running iOS 8.0 (note not 8.0.1). We are using the following code:
var documents = NSFileManager.DefaultManager.GetUrls
(NSSearchPathDirectory.LibraryDirectory,
NSSearchPathDomain.User)
[0].Path
And we get:
/var/mobile/Containers/Data/Application/8C4D70BC-7607-xxxx-xxxx-A503A061E1EF/Library
But when we try to write to files in this directory, we get the following error in the device log:
Sep 25 12:47:22 Cognilores-iPad kernel[0] <Notice>: Sandbox: SEXI_reader(1243) deny file-write-create /usr/share/CogniLore
Is anyone able to help us identify what is going wrong and what workaround we can use? This is a severe issue – our App crashes immediately after users upgrade to 8.0, and we need to get an updated version into the approval process as soon as possible.
Is anyone able to help us identify what is going wrong
The path you show does not match the path from the device logs. Are you sure they come from the same code ?
e.g. maybe another part of your application later try to access a different directory (and this is what you're seeing in the logs) ?
Some quick test shows that the code (below) works fine on iOS8 devices.
var urls = NSFileManager.DefaultManager.GetUrls (NSSearchPathDirectory.LibraryDirectory, NSSearchPathDomain.User);
var path = urls [0].Path;
File.WriteAllText (Path.Combine (path, "myfile.txt"), "woohoo");

Strange SyncServices / iSync console messages when saving ABAddressBook

I'm displaying and editing an ABPerson with an ABPersonView. I do this like so:
ABPerson *person = (ABPerson *)[_addressBook recordForUniqueId:[curDict valueForKey:#"id"]];
[_personView setPerson:person];
[_personView setEditing:YES];
Where _personView is my ABPersonView. When I edit the ABPerson with the ABPersonView and I save the AddressBook:
[ABAddressBook addressBook] save];
It does save and in the AddressBook application I can see its value has changed, but I get these error messages in Xcode and Console:
I first get this:
sandboxd: ([3082]) AddressBookSync(3082) deny file-read-data /Users/xcodeuser/Library/Developer/Xcode/DerivedData/CompanyName-asdxadsafadfqmwqxaagdsfgafguge/Build/Products/Debug
Followed by a lot of this:
sandboxd: ([3035]) AddressBookSync(3035) deny mach-lookup com.apple.syncservices.SyncServer
And it ends with this:
AddressBookSync[3035:707] [0x10011ba50] |ISyncManager|Warning| SyncServer is unavailable: timed out trying to connect
AddressBookSync[3035:707] AddressBookSync (client id: com.apple.AddressBook) error: Exception running AddressBookSync: Timed out waiting for the sync server
AddressBookSync exited with 2
My application is sandboxed and I integrated iCloud.
I have searched but could not find anyone having the same kind of problems, I have tried this:
Using [[ABAddressBook] sharedAddressBook] instead of [[ABAddressBook] addressBook] but I then get an error from the ABPersonView saying the use of sharedAddressBook is deprecated with the ABPersonView.
I added SyncServices framework, didn't help
The code does work though, at least with my iCloud account. Anyone got a clue to why I'm getting these errors? Is it worth a shot trying it with Xcode 4.3 and 10.8? I'm currently running 4.2.1 with Lion.
Thanks!
I've seen exactly this same problem. I believe you are seeing a bug in the Apple frameework.

Writing many files at once with Cordova / Phonegap 1.6.1 on iOS

When I write many files at once (batched or not) with an average size of 100KB, I get the following message in the output console:
void SendDelegateMessage(NSInvocation*): delegate
(webView:decidePolicyForNavigationAction:request:frame:decisionListener:)
failed to return after waiting 10 seconds.
main run loop mode: kCFRunLoopDefaultMode
This is using the Cordova fileWriter: http://docs.phonegap.com/en/1.6.1/cordova_file_file.md.html#FileWriter
What's the cause of this error and what's the best way to prevent it?
I'm having a similar problem. Found the cause, but no solution yet.
So far I've found that web view returns an error if a script runs for more than 10 seconds, stopping the user from interacting with the app. If you are using alert(), then the duration of the alertbox (until you press ok) may be counted in these 10 seconds.