Re: elog with automatic file, line, and function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: elog with automatic file, line, and function
Дата
Msg-id 7932.985044210@sss.pgh.pa.us
обсуждение исходный текст
Ответ на elog with automatic file, line, and function  (Peter Eisentraut <peter_e@gmx.net>)
Ответы Re: elog with automatic file, line, and function  (Peter Eisentraut <peter_e@gmx.net>)
Список pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> It has been brought up that elog should be able to automatically fill in
> the file, line, and perhaps the function name where it's called, to avoid
> having to prefix each message with the function name by hand, which is
> quite ugly.

> Since these would be mostly developer features, how do people feel about
> relying on modern tools for implementing these?

Not happy.  A primary reason for wanting the exact location is to make
bug reports more specific.  If Joe User's copy of Postgres doesn't
report error location then it doesn't help me much that my copy does
(if I could reproduce the reported failure, then gdb will tell me where
the elog call is...).  In particular, we *cannot* remove the habit of
mentioning the reporting routine name in the message text unless there
is an adequate substitute in all builds.

> The bottom line seems to be that without these tools it would simply
> not be possible.

Sure it is, it just requires a marginal increase in ugliness, namely
double parentheses:
ELOG((level, format, arg1, arg2, ...))

which might work like

#define ELOG(ARGS)  (elog_setloc(__FILE__, __LINE__), elog ARGS)


> Additionally, C99 (and GCC for a while) would allow filling in the
> function name automatically.

We could probably treat the function name as something that's optionally
added to the file/line error report info if the compiler supports it.

BTW, how does that work exactly?  I assume it can't be a macro ...
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: src/test/regress/README duplicates SGML material
Следующее
От: Philip Warner
Дата:
Сообщение: Re: More on elog and error codes