{"id":179,"date":"2015-09-11T21:33:39","date_gmt":"2015-09-11T19:33:39","guid":{"rendered":"http:\/\/www.albertopasca.it\/whiletrue\/?p=179"},"modified":"2018-05-25T14:11:58","modified_gmt":"2018-05-25T12:11:58","slug":"write-console-log-to-file-and-send-for-email","status":"publish","type":"post","link":"https:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/","title":{"rendered":"[Objc] Write console log to file\u2026 and send for email"},"content":{"rendered":"<p>I\u2019ve prepared a simple class that write logs on device disk.<br \/>\nThis is very useful, because you can send and receive logs from apps, crashlog, backtrace and debug informations.<\/p>\n<p><!--more--><\/p>\n<h5>How it works<\/h5>\n<p>It has the same behavior of\u00a0<strong>NSLog<\/strong>\u00a0method. You can pass as parameters, the format and the optional arguments.<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]FOUNDATION_EXPORT\u00a0void\u00a0NSLog(NSString\u00a0*format, &#8230;)\u00a0NS_FORMAT_FUNCTION(1,2);<\/p>\n<p>void\u00a0NSLog\u00a0(NSString*\u00a0format, &#8230;)\u00a0{<br \/>\n\t\/\/ [&#8230;]<br \/>\n}<\/p>\n<p>NSLog(@&quot;[UI:%d] &#8211; %@&quot;,\u00a0[NSThread\u00a0isMainThread], aMessage);[\/code]<\/p>\n<p>I\u2019ve made a custom\u00a0<strong>NSLog<\/strong>, called\u00a0<strong>APLog<\/strong>, with the same imprint.<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]FOUNDATION_EXPORT\u00a0void\u00a0APLog(NSString\u00a0*format, &#8230;)\u00a0NS_FORMAT_FUNCTION(1,2);<\/p>\n<p>void\u00a0APLog\u00a0(NSString*\u00a0format, &#8230;)\u00a0{<br \/>\n\t\/\/ [&#8230;]<br \/>\n}<\/p>\n<p>APLog(@&quot;[UI:%d] &#8211; %@&quot;,\u00a0[NSThread\u00a0isMainThread], aMessage);&lt;\/div&gt;&lt;\/td&gt;<br \/>\n[\/code]<br \/>\nThe difference is that\u00a0<em>APLog write the logs on the console and in the same time, to a file<\/em>, in details, append text to a file called console.log in your\u00a0<strong>NSDocumentDirectory<\/strong>, to a max size of XXMb (to prevent big log file).<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]\/\/[&#8230;]<br \/>\n[fileHandle seekToEndOfFile];<br \/>\n[fileHandle writeData:[formattedMessage dataUsingEncoding:NSUTF8StringEncoding]];<br \/>\n\/\/[&#8230;][\/code]<\/p>\n<p>Here the\u00a0<em>complete classes<\/em>\u00a0and the\u00a0<em>APLog<\/em>\u00a0method and other stuffs:<\/p>\n<p><a href=\"https:\/\/gist.github.com\/elpsk\/9b72ffaffec947546c6b\" target=\"_blank\" rel=\"noopener\">https:\/\/gist.github.com\/elpsk\/9b72ffaffec947546c6b<\/a><\/p>\n<p>Put the include to this file, in your global project config, like\u00a0<strong>Prefix.pch<\/strong>\u00a0to use in entire application.<\/p>\n<h5>Get callStack symbols (main.m)<\/h5>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;](lldb)\u00a0backtrace<br \/>\n*\u00a0thread\u00a0#1: tid = 0x1c03, 0x00003146 Debug`-[APViewController callMe:andANumber:](self=0x07187e50, _cmd=0x000038b9, str=0x0715aa40, aNum=38) + 230 at APViewController.m:33, stop reason = breakpoint 3.1<br \/>\nframe\u00a0#0: 0x00003146 Debug`-[APViewController callMe:andANumber:](self=0x07187e50, _cmd=0x000038b9, str=0x0715aa40, aNum=38) + 230 at APViewController.m:33<br \/>\nframe\u00a0#1: 0x0000304a Debug`-[APViewController viewDidLoad](self=0x07187e50, _cmd=0x005c5a77) + 122 at APViewController.m:16<br \/>\nframe\u00a0#2: 0x000f41c7 UIKit`-[UIViewController loadViewIfRequired] + 536<br \/>\nframe\u00a0#3: 0x000f4232 UIKit`-[UIViewController view] + 33<br \/>\nframe\u00a0#4: 0x000433d5 UIKit`-[UIWindow addRootViewControllerViewIfPossible] + 66<br \/>\nframe\u00a0#5: 0x0004376f UIKit`-[UIWindow _setHidden:forced:] + 368<br \/>\nframe\u00a0#6: 0x00043905 UIKit`-[UIWindow _orderFrontWithoutMakingKey] + 49<br \/>\n[&#8230;]<br \/>\nframe\u00a0#10: 0x00010747 UIKit`-[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1248<br \/>\nframe\u00a0#11: 0x0001194b UIKit`-[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 805<br \/>\nframe\u00a0#12: 0x00022cb5 UIKit`-[UIApplication handleEvent:withNewEvent:] + 1022<br \/>\nframe\u00a0#13: 0x00023beb UIKit`-[UIApplication sendEvent:] + 85<br \/>\nframe\u00a0#14: 0x00015698 UIKit`_UIApplicationHandleEvent + 9874<br \/>\n[&#8230;]<br \/>\nframe\u00a0#22: 0x0001117a UIKit`-[UIApplication _run] + 774<br \/>\nframe\u00a0#23: 0x00012ffc UIKit`UIApplicationMain + 1211<br \/>\nframe\u00a0#24: 0x00002b22 Debug`main(argc=1, argv=0xbffff3a4) + 130 at main.m:16<br \/>\nframe\u00a0#25: 0x00002a55 Debug`start + 53<br \/>\n(lldb)[\/code]<\/p>\n<p>If you want to collect app crash (backtrace) and redirect to\u00a0<strong>APLog<\/strong>, open your\u00a0<em>main.m<\/em>file and change the original one:<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]int\u00a0main(int\u00a0argc,\u00a0char\u00a0*\u00a0argv[])<br \/>\n{<br \/>\n\t@autoreleasepool\u00a0{<br \/>\n\t\treturn\u00a0UIApplicationMain(argc, argv,\u00a0nil, NSStringFromClass([AppDelegate class]));<br \/>\n\t}<br \/>\n}[\/code]<\/p>\n<p>to this:<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]int\u00a0main(int\u00a0argc,\u00a0char\u00a0*\u00a0argv[])<br \/>\n{<br \/>\n\t@autoreleasepool\u00a0{<br \/>\n\t\tint\u00a0retVal;<br \/>\n\t\t@try\u00a0{<br \/>\n\t\t\tretVal\u00a0=\u00a0UIApplicationMain(argc, argv,\u00a0nil, NSStringFromClass([AppDelegate class]));<br \/>\n\t\t}<br \/>\n\t\t@catch\u00a0(NSException\u00a0*exception)\u00a0{<br \/>\n\t\t\tAPLog(@&quot;[APL] !!! -&amp;gt; %@&quot;,\u00a0[exception callStackSymbols]);<br \/>\n\t\t}<br \/>\n\t\treturn\u00a0retVal;<br \/>\n\t}<br \/>\n}[\/code]<\/p>\n<p>Well, UIApplicationMain is catched and you can write the error to disk.<\/p>\n<p><strong>More crash info on<\/strong>: \u201c<a href=\"http:\/\/www.albertopasca.it\/whiletrue\/2013\/06\/xcode-power-of-breakpoints\/\" target=\"_blank\" rel=\"noopener\">Xcode \u2013 Power of breakpoints<\/a>\u201d and\u00a0<a href=\"http:\/\/www.albertopasca.it\/whiletrue\/2013\/10\/objectivec-0x8badf00d-and-others-crashes\/\" target=\"_blank\" rel=\"noopener\">0x8badf00d and others crashes<\/a>.<\/p>\n<h5>ZIP and send file<\/h5>\n<p>Using Objective-Zip\u00a0<a href=\"https:\/\/github.com\/gianlucabertani\/Objective-Zip\" target=\"_blank\" rel=\"noopener\">library<\/a>, prepare a zip file:<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]@try\u00a0{<br \/>\n\tZipFile\u00a0*zipFile\u00a0=\u00a0[[ZipFile alloc]\u00a0initWithFileName:yourZipFilePath mode:ZipFileModeCreate];<\/p>\n<p>\tNSString\u00a0*fName\u00a0=\u00a0[NSString\u00a0stringWithFormat:@&quot;%@\/console.log&quot;, documentsDirectory];<br \/>\n\tZipWriteStream\u00a0*stream\u00a0=\u00a0[zipFile writeFileInZipWithName:fName compressionLevel:ZipCompressionLevelBest];<\/p>\n<p>\tNSData\u00a0*fData\u00a0=\u00a0[NSData\u00a0dataWithContentsOfFile:fName];<br \/>\n\t[stream writeData:fData];<br \/>\n\t[stream finishedWriting];<\/p>\n<p>\t[zipFile close];<br \/>\n\t[zipFile release];<br \/>\n}<br \/>\n@catch\u00a0(ZipException\u00a0*ze)\u00a0{<br \/>\n\treturn\u00a0nil;<br \/>\n}<br \/>\n@catch\u00a0(id\u00a0e)\u00a0{<br \/>\n\treturn\u00a0nil;<br \/>\n}[\/code]<\/p>\n<p>and send it for email, or make an upload to a web service automatically\u2026<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]\/\/ SEND MAIL WITH ZIP ATTACHMENT<br \/>\nif\u00a0(\u00a0[MFMailComposeViewController canSendMail]\u00a0)<br \/>\n{<br \/>\n\tMFMailComposeViewController\u00a0*mail\u00a0=\u00a0[[MFMailComposeViewController alloc]\u00a0init];<br \/>\n\tmail.mailComposeDelegate\u00a0=\u00a0self;<br \/>\n\t[mail setToRecipients:@[\u00a0@&quot;support@yoursite.com&quot;\u00a0]];<br \/>\n\t[mail setSubject:@&quot;[APP-iOS] Support request&quot;];<\/p>\n<p>\tNSData\u00a0*zipData\u00a0=\u00a0[NSData\u00a0dataWithContentsOfFile:@&quot;yourZipPath.zip&quot;];<br \/>\n\t[mail addAttachmentData:zipData mimeType:@&quot;application\/zip&quot;\u00a0fileName:@&quot;console.zip&quot;];<\/p>\n<p>\t[self presentViewController:mail animated:YES\u00a0completion:NULL];<br \/>\n}[\/code]<\/p>\n<h5>Check for crash on start<\/h5>\n<p>You want to know if your app is crashed last time?<br \/>\nWell, store a\u00a0<strong>NSUserdefault<\/strong>\u00a0value on startup and delete on quit..<br \/>\nOn startup if value stored is != EMPTY, a crash happened.<\/p>\n<p>When you want, in your code, check it:<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]-\u00a0(void)\u00a0checkForCrash<br \/>\n{<br \/>\n\tAppDelegate\u00a0*appDelegate\u00a0=\u00a0[[UIApplication sharedApplication]\u00a0delegate];<br \/>\n\tif\u00a0(\u00a0appDelegate.hasCrashed\u00a0)<br \/>\n\t{<br \/>\n\t\t[UIAlertView showAlertViewWithTitle:@&quot;Crash!&quot;\u00a0message:NSLocalizedString(@&quot;Application has crashed :(. Please send us an email to fix the issue.&quot;,\u00a0nil)\u00a0cancelButtonTitle:NSLocalizedString(@&quot;Cancel&quot;,\u00a0nil)\u00a0otherButtonTitles:@[NSLocalizedString(@&quot;Send&quot;,\u00a0nil)]\u00a0onSelect:^(int\u00a0buttonIndex)<br \/>\n\t\t{<br \/>\n\t\t\t\/\/ what you want, load a controller, say Hi! to user, etc&#8230;<br \/>\n\t\t\tSegnalazioneViewController\u00a0*segnalazione\u00a0=\u00a0[self.storyboard instantiateViewControllerWithIdentifier:@&quot;segnalazione&quot;];<br \/>\n\t\t\t[self.navigationController pushViewController:segnalazione animated:YES];<\/p>\n<p>\t\t\t}\u00a0onCancel:^{<\/p>\n<p>\t\t\t}];<br \/>\n\t}<br \/>\n}[\/code]<\/p>\n<h6>Note:<\/h6>\n<p>You can find\u00a0<strong>showAlertViewWithTitle<\/strong>:<\/p>\n<p>[code autolinks=&#8221;false&#8221; collapse=&#8221;false&#8221; firstline=&#8221;1&#8243; gutter=&#8221;true&#8221; htmlscript=&#8221;false&#8221; light=&#8221;false&#8221; padlinenumbers=&#8221;false&#8221; smarttabs=&#8221;true&#8221; tabsize=&#8221;4&#8243; toolbar=&#8221;false&#8221;]+\u00a0(UIAlertView*)\u00a0showAlertViewWithTitle:(NSString*)\u00a0title<br \/>\n\tmessage:(NSString*)\u00a0message<br \/>\n\tcancelButtonTitle:(NSString*)\u00a0cancelButtonTitle<br \/>\n\totherButtonTitles:(NSArray*)\u00a0otherButtons<br \/>\n\tonSelect:(SelectBlock)\u00a0selected<br \/>\n\tonCancel:(CancelBlock)\u00a0cancelled;[\/code]<\/p>\n<p>on this old article:\u00a0<a href=\"http:\/\/www.albertopasca.it\/whiletrue\/2013\/10\/objectivec-uialertview-and-blocks\/\" target=\"_blank\" rel=\"noopener\">uialertview-and-blocks<\/a><\/p>\n<p>Well, enjoy crashing!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve prepared a simple class that write logs on device disk. This is very useful, because you can send and receive logs from apps, crashlog, backtrace and debug informations.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[11,2],"tags":[169,170,171,172,173,174,175,176,177],"class_list":["post-179","post","type-post","status-publish","format-standard","hentry","category-mobile","category-objectivec","tag-aplog","tag-callstacksymbols","tag-mfmailcomposeviewcontroller","tag-nsexception","tag-objective-zip","tag-showalertviewwithtitle","tag-uiapplicationmain","tag-zipfile","tag-zipwritestream"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Objc] Write console log to file\u2026 and send for email - while (true) {\u00a0}<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Objc] Write console log to file\u2026 and send for email - while (true) {\u00a0}\" \/>\n<meta property=\"og:description\" content=\"I\u2019ve prepared a simple class that write logs on device disk. This is very useful, because you can send and receive logs from apps, crashlog, backtrace and debug informations.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/\" \/>\n<meta property=\"og:site_name\" content=\"while (true) {\u00a0}\" \/>\n<meta property=\"article:published_time\" content=\"2015-09-11T19:33:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-05-25T12:11:58+00:00\" \/>\n<meta name=\"author\" content=\"Alberto Pasca\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@lupasca\" \/>\n<meta name=\"twitter:site\" content=\"@lupasca\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alberto Pasca\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/#article\",\"isPartOf\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/\"},\"author\":{\"name\":\"Alberto Pasca\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"headline\":\"[Objc] Write console log to file\u2026 and send for email\",\"datePublished\":\"2015-09-11T19:33:39+00:00\",\"dateModified\":\"2018-05-25T12:11:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/\"},\"wordCount\":968,\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"keywords\":[\"APLog\",\"callStackSymbols\",\"MFMailComposeViewController\",\"NSException\",\"Objective-Zip\",\"showAlertViewWithTitle\",\"UIApplicationMain\",\"ZipFile\",\"ZipWriteStream\"],\"articleSection\":[\"mobile\",\"objectivec\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/\",\"url\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/\",\"name\":\"[Objc] Write console log to file\u2026 and send for email - while (true) {\u00a0}\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\"},\"datePublished\":\"2015-09-11T19:33:39+00:00\",\"dateModified\":\"2018-05-25T12:11:58+00:00\",\"breadcrumb\":{\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/write-console-log-to-file-and-send-for-email\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Objc] Write console log to file\u2026 and send for email\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#website\",\"url\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/\",\"name\":\"while (true) {\u00a0}\",\"description\":\"notes from a developer, tutorials, how-to, ideas\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.albertopasca.it\\\/whiletrue\\\/#\\\/schema\\\/person\\\/d3cf0df774eb4aac797f246a795e9fac\",\"name\":\"Alberto Pasca\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\",\"caption\":\"Alberto Pasca\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g\"},\"description\":\"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.\",\"sameAs\":[\"https:\\\/\\\/www.albertopasca.it\",\"albertopasca\",\"https:\\\/\\\/x.com\\\/lupasca\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Objc] Write console log to file\u2026 and send for email - while (true) {\u00a0}","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/","og_locale":"en_US","og_type":"article","og_title":"[Objc] Write console log to file\u2026 and send for email - while (true) {\u00a0}","og_description":"I\u2019ve prepared a simple class that write logs on device disk. This is very useful, because you can send and receive logs from apps, crashlog, backtrace and debug informations.","og_url":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/","og_site_name":"while (true) {\u00a0}","article_published_time":"2015-09-11T19:33:39+00:00","article_modified_time":"2018-05-25T12:11:58+00:00","author":"Alberto Pasca","twitter_card":"summary_large_image","twitter_creator":"@lupasca","twitter_site":"@lupasca","twitter_misc":{"Written by":"Alberto Pasca","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/#article","isPartOf":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/"},"author":{"name":"Alberto Pasca","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"headline":"[Objc] Write console log to file\u2026 and send for email","datePublished":"2015-09-11T19:33:39+00:00","dateModified":"2018-05-25T12:11:58+00:00","mainEntityOfPage":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/"},"wordCount":968,"publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"keywords":["APLog","callStackSymbols","MFMailComposeViewController","NSException","Objective-Zip","showAlertViewWithTitle","UIApplicationMain","ZipFile","ZipWriteStream"],"articleSection":["mobile","objectivec"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/","url":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/","name":"[Objc] Write console log to file\u2026 and send for email - while (true) {\u00a0}","isPartOf":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website"},"datePublished":"2015-09-11T19:33:39+00:00","dateModified":"2018-05-25T12:11:58+00:00","breadcrumb":{"@id":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.albertopasca.it\/whiletrue\/write-console-log-to-file-and-send-for-email\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.albertopasca.it\/whiletrue\/"},{"@type":"ListItem","position":2,"name":"[Objc] Write console log to file\u2026 and send for email"}]},{"@type":"WebSite","@id":"https:\/\/www.albertopasca.it\/whiletrue\/#website","url":"https:\/\/www.albertopasca.it\/whiletrue\/","name":"while (true) {\u00a0}","description":"notes from a developer, tutorials, how-to, ideas","publisher":{"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.albertopasca.it\/whiletrue\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.albertopasca.it\/whiletrue\/#\/schema\/person\/d3cf0df774eb4aac797f246a795e9fac","name":"Alberto Pasca","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g","caption":"Alberto Pasca"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/4d8fe43c412d0bb34a71c41f60dce53eff3afc027853cbfd20bee6ddc7e93f35?s=96&d=retro&r=g"},"description":"Software engineer @ Pirelli &amp; C. S.p.A. with a strong passion for mobile \uf8ff development, security, and connected things.","sameAs":["https:\/\/www.albertopasca.it","albertopasca","https:\/\/x.com\/lupasca"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/comments?post=179"}],"version-history":[{"count":4,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/179\/revisions"}],"predecessor-version":[{"id":797,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/posts\/179\/revisions\/797"}],"wp:attachment":[{"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/media?parent=179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/categories?post=179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.albertopasca.it\/whiletrue\/wp-json\/wp\/v2\/tags?post=179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}