velog + vereport? - Mailing list pgsql-hackers

From Andres Freund
Subject velog + vereport?
Date
Msg-id 201210121300.18134.andres@2ndquadrant.com
Whole thread Raw
Responses Re: velog + vereport?
List pgsql-hackers
Hi,

When writing code which should be able to run inside and outside a normal 
backend environment its sometimes useful to be able add a wrapper arround 
elog/ereport for when executing inside the backend.
Currently that requires relatively ugly macro surgery and/or recompiling the 
file. I suggest adding velog/vereport or elog_va/vereport_va to make such 
wrappers easier (still not easy though).

The aim would be able to do something like:

#define my_elog \   elog_wrapper_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO), \        elog_wrapper_finish

And then
void
elog_wrapper_finish(int elevel, const char *fmt, ..)
{   va_list args;   va_start(args);   velog(elevel, fmt, args);   va_end(args);
}
when inside the backend

And something like:

void elog_wrapper_finish(int elevel, const char *fmt, ..)
{   va_list args;   fprintf(stderr, "...", my_elog_file, my_elog_line, my_elog_func);   va_start(args);
vfprintf(stderr,fprintf, args);   va_end(args);
 
}

Comments? Better idea (please!)? 

This would be easier if we had vararg macros, but I don't see me winning that 
argument :P

Greetings,

Andres
-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Daniel Farina
Date:
Subject: Re: Deprecating RULES
Next
From: Andres Freund
Date:
Subject: Re: Deprecating RULES