[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gphoto-devel
Subject:    Re: [gphoto-devel] libgpio debugging messages
From:       Ragnar_Kjørstad <gphoto () ragnark ! vestdata ! no>
Date:       2000-08-31 20:35:47
[Download RAW message or body]

On Wed, Aug 30, 2000 at 04:12:45PM -0500, Scott Fritzinger wrote:
> I have a couple questions on the details:
> 
> > I would actually suggest doing it slightly differently for gphoto:
> > gphoto_set_logging(int loglevel, void (func_log)(char *message, void
> > *private), void (func_start_log)(void *private),
> > void (func_stop_log)(void *private), void *private);
> > func_log should be the function that actually perform this logging.
> > There should be predefined functions for logging to file, stderr and
> > syslog, and the application can define it's own if it needs to.
> 
> would it possible to just use
> 
> 	int (*gp_function_log) (char *message);
> 
> as the function pointer prototype? the logging message would be fully
> contained in "message" (the gphoto2 core will create a single buffer for
> it (via vsprintf).

I'm not sure if I understand your question, but my suggestion would be
that the different modules have three methods of logging something:
* void gp_log_printf(int priority, const char *format, ...);
* void gp_log_vprintf(int priority, const char *format, va_list ap);
* void gp_log_perror(const char *s);
  (not sure if this should have a priority argument or LOG_ERR should
  always be used.

All theese three functions will do the same thing:
Construct a buffer with the "compiled" errormessage, and run all the
registered message-handlers with the right priority.

The private argument is just for message-handlers that need to store
some kind of state.

> how much of a pain-in-the-ass or time savings is it to open/close the
> syslog with each call? this way, if the app crashes, syslog (or whatever
> other logging facility) is left in an OK state. the call to log
> something should have no implied states in between calls to reduce the
> probability of hosing something. :P

the OS will close any open filedescriptors anyway, so a crash should not
cause any problems.


-- 
Ragnar Kjorstad
Modus Media

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic