Reputation: 4028
I have followed How to NSLog into a file to create my own NSLog.
in iFob-Prefix.pch:
#import "Log.h"
#ifdef DEBUG_MODE
#define NSLog( args, ... ) _Log(@"Prefixs", __FILE__, __LINE__, __PRETTY_FUNCTION__, args);
#else
#define NSLog( args, ... )
in Log.h
@interface Log : NSObject
void _Log(NSString *prefix, const char *file, int lineNumber, const char *funcName, NSString *format,...);
@end
in Log.m
#import "Log.h"
#import <objc/runtime.h>
#define PADDING_TABS 10
@implementation Log
void _Log(NSString *prefix, const char *file, int lineNumber, const char *funcName, NSString *format,...) {
va_list ap;
va_start (ap, format);
format = [format stringByAppendingString:@"\n"];
NSString *msg = [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"%@",format]
arguments:ap];
msg = formatJsonData(msg);
va_end (ap);
fprintf(stderr,"\n%s[%30s:%4d] - %s",[prefix UTF8String], [[[NSString stringWithUTF8String:file] lastPathComponent]UTF8String] , lineNumber, [msg UTF8String]);
append(msg);
}
I got error every time when I pass [<"object"> description] into the log. Like:
NSManagedObjectContext *context = rasEngine.managedObjectContext ;
NSLog(@"context: %@",[context description])
error:
Upvotes: 1
Views: 92
Reputation: 46598
change NSLog( args, ... )
to NSLog( args... )
otherwise you are calling something like NSLog(@"content %@");
without pass the object
Upvotes: 1