GDLogger 1.1.2

GDLogger 1.1.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jun 2017

Maintained by Joe Barbour.



GDLogger 1.1.2

GDLogger is a lightweight class logging class for iOS versions 3.0 and above, build for Grado. It allows for quick, strightforward creation, and appending of multiple, formatted log files.

Setup

We now support CocoaPod's pod 'GDLogger'

Add #import "GDLogger/GDLogger.h"
In your .m file add GDLogger *logger = [[GDLogger alloc] init];

Debugging

to enable console debugging simply set logger.degbugger = true;

Mutiple Logs

We recently updated GDLogger to support multiple log files. By default there will be only one log file saved locally "[YourApp]-logger.txt". This is created when you log your first event. To create a new log file simply set the filename.

logger.filename = @"my-new-log";

NOTE To revert back to the default log file set logger.filename = nil; NOTE Do not include the file type when setting logger.filename

"Events"

Events are what are created every time you create a new item in GDLogger. They contain 2 objects, a "title" and "properties"

title (NSString
properties (NSDictionary)

[logger log:@"Event Title" properties:@{@"key":@"value", @"installed":[NSNumber numberWithBool:true]}];

Print

To print out the entire log file as a NSString use logger.logPrint

Alternatively, you can get the file content as NSData logger.logData

NOTE this will print out the default log file unless logger.filename has been set

Files

There is two ways of getting access to the saved files.
You can get the active most recent file by calling logger.logPrint

Or, you can get an array of all files by calling

[self.logger logFiles:true] (This will return the all the files with their full directories as NSURL)
[self.logger logFiles:false] (This will return the all the files with just their respective file names as NSString)

Remove/Destory

Calling [self logDestory]; will destory the active log file.

Share

There will be many ways you will choose to utilize the saved data. Sending it as an attachment is the most common so we have added an example for you lazy folk out there
MFMailComposeViewController *emailController = [[MFMailComposeViewController alloc] init];
[emailController setMailComposeDelegate:self];
[emailController setToRecipients:[[NSArray alloc] initWithObjects:@"[email protected]", nil]];
[emailController setSubject:@"Log File"];
[emailController setMessageBody:@"" isHTML:false];
[emailController addAttachmentData:[logger logData] mimeType:@"text/plain" fileName:@"logger.txt"];
[emailController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentViewController:emailController animated:true completion:nil];

NOTE the fileName for addAttachmentData can be anything