Debug Logging in iOS Objective-C Apps

So recently I’ve been working on Veteris (My App Store client/server) and YewTube (My YouTube client) and needed a better way to add logging to my apps without it logging on release builds.

Whilst searching for a solution I found a ancient Ars Technica article pointing to this link, Of course the links on the article are dead but I was able to extract enough information to get it working for me. Here’s how I implemented it.

So first, in a class you’d like to use, I used the AppDelegate you just need to add these lines to your header.

#ifdef DEBUG
#define DebugLog(args...) _DebugLog(__FILE__,__LINE__,args);
#else
#define DebugLog(x...)
#endif

@interface YourClass: NSObject
void _DebugLog(const char *file, int lineNumber, NSString *format,...);
@end

And you need to add these lines to the implementation.

void _DebugLog(const char *file, int lineNumber, NSString *message,...) {
  NSString *string = [[NSString alloc] initWithUTF8String:file];
  NSLog(@"%@:%d: %@", string, lineNumber, message);
}

Of course, there is probably a better way to write this implementation but I’m content with this. You can call the function like so.

DebugLog([NSString stringWithFormat:@"VAPIDeviceString = %@", [VAPIHelper getVAPIDeviceString]]);

Thank you for coming to my TED Talk and I hope someone finds this useful now, or in the future.

This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Debug Logging in iOS Objective-C Apps

  1. Avenue17 says:

    I agree with told all above.

  2. Johnnyjal says:

    301 Moved Permanently
    [url=https://5000-recipe.ru/]301 Moved Permanently![/url]

  3. RachelDek says:

    Десерты La familia — этто элементарный, ясный, что-что главное цельный продукт. Евонный далеко не требуется расширять, прояснять, украшать. Это его только испортит.
    Умереть и не встать эра когда яко штабель заинтересованности уделяется обложке, вожделению непрерывно изумлять, делать спецэффекты, отвлекая от сути, автор разрешили четко изобличить, яко содержание стократ важнее. РАВНЫМ ОБРАЗОМ у нас этто сраслось!
    Через целой нашей семьи эго хочу тест, монета и еще громкого смеха в течение с носа) дом.
    И ЕЩЕ пусть вам сегодня хорэ вкусно!

    [b]Наши домашние тортики ручной работы[/b]
    [url=http://www.google.sh/url?q=https://lafamillia.ru/tort-ptiche-moloko/]где купить торт москва птичье молоко[/url]
    [url=https://google.sc/url?q=https://lafamillia.ru/tort-ptichka/]домашний торт птичка[/url]
    [url=https://google.com.gh/url?q=https://lafamillia.ru/tort-mikado/]торт микадо москва[/url]
    [url=https://images.google.dk/url?q=https://lafamillia.ru/tort-bananovyy/]шоколадно банановый торт[/url]
    [url=http://images.google.tg/url?q=https://lafamillia.ru/tort-praga/]торт прага какой[/url]

    [url=https://www.amputee-coalition.org/ways-to-give/donate-online-by-mail-or-by-phone/donate-online/?tfa_next=%2Fforms%2FlegacyView%2F388853%2F2a70241c293d7afd4714d99e7e70d4cf%2F53361278%3Fjsid%3DeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IjczZmMwOWJjM2JiMWU1MzJlYTM4NjE5YTc3ZDhlODE0Ig.2_Q1wET0OIIp-vuqi5ktmPWLTeJB8f-kssLcUxw-3Q0]простейший торт эскимо[/url]
    [url=https://www.kone.fr/?tfa_next=%2Fforms%2FlegacyView%2F738%2F95135f7e537c142aabfc4cd72c712f59%2F995326%3Fjsid%3DeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IjgxZGI4YmQ5YWFlM2UzNDZkMTEzMGQ5ZDdhN2M1Y2RhIg._z2_lrQtuWL17j1_BfHAC83hoTQw_sjP5Jqa-cSffKc]торт прага классический[/url]
    [url=https://www.shelfengine.com/?_wpcf7=682&_wpcf7_version=5.6.2&_wpcf7_locale=en_US&_wpcf7_unit_tag=wpcf7-f682-o1&_wpcf7_container_post=0&_wpcf7_posted_data_hash&first_name=RachellogCN&last_name=RachellogCN&email=laaaffaaammii%40gmail.com&phone=84795727895&company=google&industry=Solution%20Provider&message=%D0%94%D0%B5%D1%81%D0%B5%D1%80%D1%82%D1%8B%20La%20familia%20%E2%80%94%20%D1%8D%D1%82%D1%82%D0%BE%20%D1%8D%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%80%D0%BD%D1%8B%D0%B9%2C%20%D0%BF%D0%BE%D0%BD%D1%8F%D1%82%D0%BD%D1%8B%D0%B9%2C%20%D1%87%D1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D0%BC%D0%BE%D0%BD%D0%B5%D1%82%D0%B0%20%28%D0%B0%29%20%D1%82%D0%B0%D0%BA%D0%B6%D0%B5%20%D0%B3%D1%80%D0%BE%D0%BC%D0%BA%D0%BE%D0%B3%D0%BE%20%D1%81%D0%BC%D0%B5%D1%85%D0%B0%20%D0%B2%20%D0%BA%D0%B0%D0%B6%D0%B4%D1%8B%D0%B9%20%D0%B4%D0%BE%D0%BC.%3Cbr%3E%20%D0%98%20%D0%BF%D1%83%D1%81%D1%82%D1%8C%20%D0%B2%D0%B0%D0%BC%20%D1%82%D0%B5%D0%BF%D0%B5%D1%80%D1%8C%20%D1%85%D0%BE%D1%80%D1%8D%20%D0%B2%D0%BA%D1%83%D1%81%D0%BD%D0%BE%21%20%20%20%3Cb%3E%D0%9D%D0%B0%D1%88%D0%B8%20%D0%B4%D0%BE%D0%BC%D0%B0%D1%88%D0%BD%D0%B8%D0%B5%20%D1%82%D0%BE%D1%80%D1%82%D1%8B%20%D1%80%D1%83%D1%87%D0%BD%D0%BE%D0%B9%20%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D1%8B%3C%2Fb%3E%20%3Ca%20href%3Dhttp%3A%2F%2Fmaps.google.com.gt%2Furl%3Fq%3Dhttps%3A%2F%2Flafamillia.ru%2Ftort-rafaello%2F%3E%D1%82%D0%BE%D1%80%D1%82%20%D1%80%D0%B0%D1%84%D0%B0%D1%8D%D0%BB%D0%BB%D0%BE%20%D1%84%D0%BE%D1%82%D0%BE%3C%2Fa%3E%20%3Ca%20href%3Dhttps%3A%2F%2Fimages.google.com.fj%2Furl%3Fq%3Dhttps%3A%2F%2Flafamillia.ru%2Ftort-bananovyy%2F%3E%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%BE%D0%B2%D1%8B%D0%B9%20%D1%82%D0%BE%D1%80%D1%82%20%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C%3C%2Fa%3E%20%3Ca%20href%3Dhttps%3A%2F%2Fmaps.google.co.zw%2Furl%3Fq%3Dhttps%3A%2F%2Flafamillia.ru%2Ftort-rafaello%2F%3E%D0%B2%D0%BA%D1%83%D1%81%D0%BD%D1%8B%D0%B9%20%D1%82%D0%BE%D1%80%D1%82%20%D1%80%D0%B0%D1%84%D0%B0%D1%8D%D0%BB%D0%BB%D0%BE%3C%2Fa%3E%20%3Ca%20href%3Dhttp%3A%2F%2Fimages.google.mg%2Furl%3Fq%3Dhttps%3A%2F%2Flafamillia.ru%2Ftort-ptiche-moloko%2F%3E%D0%B3%D0%B4%D0%B5%20%D0%B2%20%D0%BC%D0%BE%D1%81%D0%BA%D0%B2%D0%B5%20%D0%BF%D1%82%D0%B8%D1%87%D1%8C%D0%B5%20%D0%BC%D0%BE%D0%BB%D0%BE%D0%BA%D0%BE%3C%2Fa%3E%20%3Ca%20href%3Dhttps%3A%2F%2Fwww.google.is%2Furl%3Fq%3Dhttps%3A%2F%2Flafamillia.ru%2Ftort-smetannik%2F%3E%D1%82%D0%BE%D1%80%D1%82%20%D1%81%D0%BC%D0%B5%D1%82%D0%B0%D0%BD%D0%BD%D0%B8%D0%BA%20%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C%3C%2Fa%3E%20%20%20%3Ca%20href%3Dhttps%3A%2F%2Fwww.ivey.uwo.ca%2Falumni%2Fyour-ivey-network%2Fivey-alumni-network%2Fnomination-form%2F%3Ftfa_next%3D%252Fforms%252FlegacyView%252F4971432%252Fcc7d282fab840c7a32669a63bd689acf%252F284098256%253Fjsid%253DeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IjhiNmZiNTQyOWQxNTM4ZWVlYzkyZTRmYTg5YzNkYjQwIg.5lNCGp2U2N1-GxB3vgBqh0hKHslCf3Xag4srj0MVs6A%3E%D0%BC%D0%B0%D0%BD%D0%B3%D0%BE%20%D0%BC%D0%B0%D1%80%D0%B0%D0%BA%D1%83%D0%B9%D1%8F%20%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C%3C%2Fa%3E%3Ca%20href%3Dhttps%3A%2F%2Fmertingen.de%2Fkontakt-mertingen%3Fcf_success%3Dyes%26data%3D715-3f096c5587c799b51a3b32870489dee0%3E%D1%87%D0%B8%D0%B7%D0%BA%D0%B5%D0%B9%D0%BA%20%D0%BA%D0%BB%D0%B0%D1%81%D1%81%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B9%20%D1%84%D0%BE%D1%82%D0%BE%3C%2Fa%3E%3Ca%20href%3Dhttp%3A%2F%2Fpaste.fyi%2F9dXGTPn8%3Fclike%3E%D0%BA%D0%BB%D1%83%D0%B1%D0%BD%D0%B8%D1%87%D0%BD%D0%B0%D1%8F%20%D0%BD%D0%B0%D1%87%D0%B8%D0%BD%D0%BA%D0%B0%20%D0%B4%D0%BB%D1%8F%20%D1%82%D0%BE%D1%80%D1%82%D0%B0%3C%2Fa%3E%3Ca%20href%3Dhttps%3A%2F%2Fwww.castletonlyons.com%2F%3Fsubmission_id%3D544223%26key%3Da82962551736db7ea87f0154c14b60de%26page%3D0%3E%D0%B1%D0%B0%D0%BD%D0%B0%D0%BD%D0%BE%D0%B2%D1%8B%D0%B9%20%D0%B1%D0%B8%D1%81%D0%BA%D0%B2%D0%B8%D1%82%D0%BD%D1%8B%D0%B9%20%D1%82%D0%BE%D1%80%D1%82%3C%2Fa%3E%3Ca%20href%3Dhttps%3A%2F%2Fcollege.studywoo.com%2Fpublic%2Fdirectorate-of-coldwater-fisheries-research-nainital%3E%D1%82%D0%BE%D1%80%D1%82%20%D0%BC%D0%B5%D0%B4%D0%BE%D0%B2%D0%B8%D0%BA%3C%2Fa%3E%20bcd5a0b%20&Page_Title=Home&Page_URL=https%3A%2F%2Fwww.shelfengine.com%2F&Form_Name=Main%20Inquiry&GCLID&FBCLID&Shelf_Marketing_Source]торт рафаэлло фото[/url]
    [url=https://www.kone.de/unternehmen/kontakt/angebot-beratung/?tfa_next=%2Fforms%2FlegacyView%2F924%2Faa616dd264d9533de3aabc850ea9b358%2F996864%3Fjsid%3DeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.IjE5NjhhMWE4MDhlODYxZjNiZTc4ZTZkMmNmN2NlNWRlIg.2rVrAj3uDQfWL4RJgoC_6w6FAv2d9Oo66D_eas1nGo4]шоколадно банановый торт[/url]
    [url=https://www.fantasygrounds.com/forums/entry.php?403-I-m-insane%21%21%21%21&bt=1375]торт медовик простой[/url]
    8d0f550

Leave a Reply

Your email address will not be published. Required fields are marked *