importing classes and calling custom logs

Hi All,

My main app is comprised of half OBJc and applescript classes. I have some complex logging needs and am trying CocoaLumberjack which is great.

The trick is calling it from the applescript classes.

In OBJc class:

#import "DDLog.h"

//then later for log calls 
DDLogError(@"some message %@",someVar);

I made a bridge function in my utility OBJc class

+(void)setLoggerTxt:(NSString*) intxt var:(NSString*) invar {
		DDLogError(intxt, invar);
}

and call it from applescript

on logInfo_var_(intext,inVar)
			tell current application's  UtilsPlus to setLoggerTxt_var_(intext,inVar)
end logInfo_var_

Would it be in any way possible to call these DDLogErrors from the applescript itself. That way it would show the correct line numbers logged in the applescript class. Now it always shows the line number for the OBJc class that sends the DDLogError line. I don’t know if it is possible to import the needed #import "DDLog.h or even call something like DDLogError(@“some message %@”,someVar).

Thanks!

Rob

I haven’t looked at CocoaLumberjack , but your mention of line numbers suggests it’s relying on compile-time macros, and they’re not going to do anything with AS code.

Hi Shane,

Yes it relies on compile time expansion of macros to determine the log levels etc. and then rolls it’s own logging.

I didn’t think there was any way of picking up macro substitution in AS scripts as in any of the usual macros

#define MYLog(args,...) NSLog(args,##__VA_ARGS__)

In lumberjack you just import the lumberjack class into any OBJc class and can call DDLogError(…) so thought maybe there is some way to do the equivalent in AS…

Cheers, Rob

You could try adding it to a framework and importing that. You’d have to make the framework generate a suitable .bridgesupport file. But I honestly don’t know that it’s going to get you far with AS.