Re: Apple system log facility: questions
Re: Apple system log facility: questions
- Subject: Re: Apple system log facility: questions
- From: Paul Nelson <email@hidden>
- Date: Thu, 16 Nov 2006 10:42:18 -0600
- Thread-topic: Apple system log facility: questions
on 11/16/06 10:07 AM, Stephane at email@hidden wrote:
>
<snip>
>> I never had any trouble figuring out the api. Not sure why this is
>> even an issue.
>
> Well, for instance, my first look at the API shows that you need to
> use asl_new to create a new Message. This leads me to wonder if this
> is slow because it's apparently allocating some memory. But is it
> really allocating memory because the sample codes in the man page are
> not using the asl_free call (and the "may be freed" sentence is a bit
> strange). Then I wondered if you could avoid allocating a message for
> each record you want to log. It's answered in the man page but a
> @discussion on asl_new or a detailed topic (such as the ones
> available for Cocoa or Carbon) could have been easier to find and
> provided a enlightening answer.
>
> So for my part, I could use a detailed documentation (to avoid
> looking at the source code of asl in the near future).
My usage is quite simple: call asl_log using a preconfigured aslmsg (arg 2).
I take care of the open, and asl_new one time, unless I have a special case
where I want to add to or modify my aslmsg. When these cases arise, I use
asl_set. I don't really need asl_unset, but that works too.
I would only use asl_free if I was going to unload my logging facility from
memory - (if I'm a plug-in).
Here is my obj-c wrapper for my log init method:
-(void)initAuthLog:(NSDictionary*)inParams
{
if( auth_log )
asl_close(auth_log);
auth_log = asl_open("AM-PKINIT", "auth", ASL_OPT_NO_DELAY);
auth_msg = asl_new( ASL_TYPE_MSG );
asl_set(auth_msg, ASL_KEY_SENDER, "AM-PKINIT" );
asl_set(auth_msg, "Facility", "auth" );
NSEnumerator* paramEnum = [inParams keyEnumerator];
NSString* paramKey;
while( (paramKey=[paramEnum nextObject])!=0 )
{
NSString* value = [[inParams objectForKey:paramKey] description];
asl_set(auth_msg, [paramKey cString], [value cString] );
}
NSString* initmsg = [NSString stringWithFormat: @"initAuthLog: %@",
inParams];
asl_log( auth_log, auth_msg, ASL_LEVEL_DEBUG, [initmsg cString] );
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden