forked from mirrors/linphone-iphone
Add helper functions for Logging
This commit is contained in:
parent
77dfa1c6b3
commit
831a7f222f
2 changed files with 42 additions and 3 deletions
|
|
@ -62,4 +62,12 @@ typedef enum _LinphoneLoggerSeverity {
|
|||
|
||||
@end
|
||||
|
||||
void Linphone_log(NSString* format, ...) NS_FORMAT_FUNCTION(1,2);
|
||||
void Linphone_dbg(NSString* format, ...) NS_FORMAT_FUNCTION(1,2);
|
||||
void Linphone_warn(NSString* format, ...) NS_FORMAT_FUNCTION(1,2);
|
||||
void Linphone_err(NSString* format, ...) NS_FORMAT_FUNCTION(1,2);
|
||||
void Linphone_fatal(NSString* format, ...) NS_FORMAT_FUNCTION(1,2);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,9 +23,8 @@
|
|||
|
||||
@implementation LinphoneLogger
|
||||
|
||||
+ (void)log:(LinphoneLoggerSeverity) severity format:(NSString *)format,... {
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
|
||||
+ (void)logv:(LinphoneLoggerSeverity)severity format:(NSString*)format args:(va_list)args{
|
||||
NSString *str = [[NSString alloc] initWithFormat: format arguments:args];
|
||||
if(severity <= LinphoneLoggerDebug) {
|
||||
ms_debug("%s", [str UTF8String]);
|
||||
|
|
@ -39,6 +38,12 @@
|
|||
ms_fatal("%s", [str UTF8String]);
|
||||
}
|
||||
[str release];
|
||||
}
|
||||
|
||||
+ (void)log:(LinphoneLoggerSeverity) severity format:(NSString *)format,... {
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
[LinphoneLogger logv:severity format:format args:args];
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
|
|
@ -237,3 +242,29 @@
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
#define LOGV(level, argstart) \
|
||||
va_list args; \
|
||||
va_start(args, argstart); \
|
||||
[LinphoneLogger logv:level format:argstart args:args]; \
|
||||
va_end(args);
|
||||
|
||||
void Linphone_log(NSString* format, ...){
|
||||
LOGV(LinphoneLoggerLog, format);
|
||||
}
|
||||
|
||||
void Linphone_dbg(NSString* format, ...){
|
||||
LOGV(LinphoneLoggerDebug, format);
|
||||
}
|
||||
|
||||
void Linphone_warn(NSString* format, ...){
|
||||
LOGV(LinphoneLoggerWarning, format);
|
||||
}
|
||||
|
||||
void Linphone_err(NSString* format, ...){
|
||||
LOGV(LinphoneLoggerError, format);
|
||||
}
|
||||
|
||||
void Linphone_fatal(NSString* format, ...){
|
||||
LOGV(LinphoneLoggerFatal, format);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue