Skip to content

Instantly share code, notes, and snippets.

@foundry
Created June 8, 2015 11:20
Show Gist options
  • Save foundry/b6b4cedbcaed86fdf434 to your computer and use it in GitHub Desktop.
Save foundry/b6b4cedbcaed86fdf434 to your computer and use it in GitHub Desktop.
Crashlytics logging macro
//
// WNLog.h
// testCrash
//
// Created by foundry on 08/06/2015.
// Copyright (c) 2015 foundry. All rights reserved.
//
#ifndef testCrash_WNLog_h
#define testCrash_WNLog_h
#ifdef __OBJC__
// WN_CLSLog - logs to Crashlytics crash reports only
#define WN_CLSLog(__FORMAT__, ...) CLSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#ifdef DEBUG
// WN_CLSNSLog - logs to Crashlytics crash reports and routes to NSLog if in DEBUG mode
#define WN_CLSNSLog(__FORMAT__, ...) CLSNSLog((@"%s line %d $ " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#else
// WN_CLSNSLog - logs to Crashlytics crash reports only if in RELEASE mode
#define WN_CLSNSLog(__FORMAT__, ...) WN_CLSLog(__FORMAT__,##__VA_ARGS__)
#endif
// WNLog - routes to WN_CLSNSLog if LOG_ME == 1 else routes to WN_CLSLog
#define WNLog(__FORMAT__,...) if (LOG_ME)\
WN_CLSNSLog(__FORMAT__,##__VA_ARGS__);\
else \
WN_CLSLog(__FORMAT__,##__VA_ARGS__);
#define WNLogMethod WNLog(@"%@ %@",self.class,NSStringFromSelector(_cmd))
#endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment