TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Sep 2017 |
Maintained by Bill Burgess.
SimpleLogger
is an easy to use log file generator for iOS that uploads to Amazon S3.
SimpleLogger
works on iOS 8+ and requires ARC to build. It depends on the following Apple Frameworks which should already be included with Xcode:
You can directly add the contents of the SimpleLogger
folder to your project. It contains SimpleLogger.h/m
as well as a category for date helpers and a header for the defaults. You will need to link to the AWSS3
framework provided by Amazon for this to work. Cocoapods will automatically include it.
If you only want to log the files out locally you can just dive right in with the log event method:
[SimpleLogger addLogEvent:@"Log some event to today's file."];
This will create a file with the current date in the documents directory using the default date/time formatting.
[2017-8-14 10:10:10] Log some event to today's file.
You can customize many of the logging formats and settings:
// number of days of log files are retained by the logger (default 7)
[[SimpleLogger sharedLogger] setRetentionDays:7];
// log event formatter date format
[[[SimpleLogger sharedLogger] logFormatter] setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// file name date format
// be sure to set this one before writing your first log event to avoid duplicate files for same day
[[SimpleLogger sharedLogger] setFilenameFormatter:yourDateFormatter];
// filename extension
[[SimpleLogger sharedLogger] setFilenameExtension:@"log"];
// folder location inside your AWSS3 bucket
[[SimpleLogger sharedLogger] setFolderLocation:@"Your/Folder/Location"];
You must initialize SimpleLogger
with the correct Amazon AWS S3 credentials and bucket to upload your log files. If you plan to upload, call the initializer early enough in your app to let the Amazon library to initialize and be ready for upload. We recommend during app startup in the AppDelegate.
[SimpleLogger initWithAWSRegion:AWSRegionUSEast1 bucket:@"my-bucket-name" accessToken:@"MYAMAZONACCESSTOKEN" secret:@"MYAMAZONSECRET"];
You should NOT manually set the variables even though it is possible. Use the initializer method to validate your values and pass them to AWSS3 to avoid crashing your application.
iOS 9 users need to support App Transport Security (ATS). To prevent uploads from failing, add the following keys to your Info.plist
.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>amazonaws.com.cn</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
This code is distributed under the terms and conditions of the MIT license.
This library was written by Bill Burgess, Co-Founder and iOS/Mac Developer for Simply Made Apps.
You can find the Android companion library at SimpleLogger-Android.