Re: elog with automatic file, line, and function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: elog with automatic file, line, and function
Date: 2001-03-19 23:23:30
Message-ID: 7932.985044210@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philip Warner 2001-03-19 23:48:55 Re: More on elog and error codes
Previous Message Peter Eisentraut 2001-03-19 23:13:36 Re: [HACKERS] src/test/regress/README duplicates SGML material