Różnica między Nslog i DLog
Czy ktoś może mi powiedzieć jaka jest różnica między NSLog
a DLog
?
Znalazłem o tym Dlogu kiedy przeglądałem ten kod projektu: http://code.google.com/p/iphone-socks-proxy/
5 answers
NSLog
to funkcja wbudowana w fundament, który zapewnia Apple. Nigdy nie słyszałem o DLog
, więc zakładam, że jest to niestandardowa funkcja zaimplementowana przez kod, na który patrzysz.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-11 23:04:27
DLog jest powszechnie używaną alternatywą "Debug NSLog" (po prostu Google)
Oto kompletny zestaw dyrektyw Log # define (w tym ULog, funkcja logowania oparta na Ualertview )
// DLog will output like NSLog only when the DEBUG variable is set
#ifdef DEBUG
# define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
# define DLog(...)
#endif
// ALog will always output like NSLog
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
// ULog will show the UIAlertView only when the DEBUG variable is set
#ifdef DEBUG
# define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
# define ULog(...)
#endif
Po prostu umieść je w nagłówku precompile (.PCH) plik.
(Źródło: http://overbythere.co.uk/blog/2012/01/alternatives-nslog )
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-02-13 05:46:40
DLog jest makrem przeznaczonym do conditionalizacji zachowania NSLog()
w kompilacjach debugujących i wydających. W przypadku kompilacji release nic nie wydrukuje. NSLog()
jest przeznaczony do drukowania ciągów formatujących do konsoli.
Oto jego definicja dla odniesienia:
#ifdef DEBUG
# define DLog(...) NSLog(__VA_ARGS__)
#else
# define DLog(...) /* */
#endif
#define ALog(...) NSLog(__VA_ARGS__)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-12 20:34:09
Cześć., Poniżej makro cmd dla formatu pliku zastępczego nslog, a także poniżej wspomniałem Makro undef oraz
Definicja:
#define _LOG_TO_CONSOLE_ //#undef _LOG_TO_CONSOLE_
#ifdef _LOG_TO_CONSOLE_
#define DLog(format, ...) NSLog(format, ##__VA_ARGS__)
#else
#define DLog(format, ...)
#endif
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-03-31 17:52:55
Myślę, że istotną różnicą między Nslog i DLog jest to, że nslog opóźnia wykonanie programu (wyobraź sobie, że zapominasz usunąć wszystkie wywołania nslog w produkcji/publikacji), więc do celów debugowania należy użyć DLog.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-03-30 10:03:41