[Openais] [PATCH corosync/trunk] add a log_printf function to coroipcs so we can pass log level

angus salkeld angus.salkeld at alliedtelesis.co.nz
Thu Oct 15 11:49:02 PDT 2009


On Thu, 2009-10-15 at 05:39 +0200, Fabio M. Di Nitto wrote:
> On Thu, 2009-10-15 at 11:22 +1300, angus salkeld wrote:
> > Hi
> > 
> > Add apiv2->log_printf(<log level>, ...);
> > 
> > Else you can't add anything but error logs int coroipcs.c.
> > 
> > (Attached & inline)
> > 
> > Note: I am not nuts about the #include <syslog.h>
> > but if I include <logsys.h> the #define for log_printf() in
> > that header messes with the log_printf in coroipcs.c
> 
> try this:
> 
> #define LOGSYS_UTILS_ONLY 1
> #include <corosync/engine/logsys.h>
> 

cool, thanks! That cleans that up.

> 
> > -struct coroipcs_init_stats_state {
> > +struct coroipcs_init_state_v2 {
> >  	hdb_handle_t (*stats_create_connection) (const char* name,
> >  		pid_t pid, int fd);
> >  	void (*stats_destroy_connection) (hdb_handle_t handle);
> >  	void (*stats_update_value) (hdb_handle_t handle,
> >  		const char *name, const void *value, size_t value_len);
> >  	void (*stats_increment_value) (hdb_handle_t handle, const char* name);
> > +	void (*log_printf) (unsigned int level, const char *format, ...)
> > +		__attribute__((format(printf, 2, 3)));
> >  };
> >  
> 
> Instead of making this generic log_printf available only for stats,
> would be an idea to look into cleaning it up all over the place in a

When you say "all over the place" you mean in coroipcs.c?
At the moment we don't have real file & line numbers (all will ref. to
main.c:881).

> similar way as totem, where there is only one log_printf that behaves as
> the one coming from logsys?
> 
> #define log_printf(level, format, args...)
> \
> do {
> \
>         instance->totemudp_log_printf (
> \
>                 LOGSYS_ENCODE_RECID(level,
> \
>                                     instance->totemudp_subsys_id,
> \
>                                     LOGSYS_RECID_LOG),
> \
>                 __FUNCTION__, __FILE__, __LINE__,
> \
>                 (const char *)format, ##args);
> \
> } while (0);
> 
> or something along those lines......
> 
> AFAICT ipc has 2/3 different ipc_log_foo, one for each level..

There is 2, the one does an exit().

> 
> Fabio
> 



More information about the Openais mailing list