On Tue, 2003-03-25 at 15:50, Tony Cheung wrote:
> Hi,
>
> Is there any plan to make use of the macros __FILE__ and __LINE__ to log
> the filename and the line numbers automatically?
>
No. If you add informative log messages to your code, locating the code
fragment corresponding with the log message is trivial without file
names and line numbers. So I wouldn't want to add methods to Category or
LoggingEvent to support this. If anything, Category should stay small
and simple, I already regret making it subclassable :-/
A basic workaorund is to prefix your log messages with filename and line
numbers by having the compilere concatenate the necessary string
constants. That doesn't allow dynamic layouting of these parameters but
it does give you the data.
Good luck,
Bastiaan
> I am thinking of adding two parameters, line number and filename, to all
> logging functions. For example, we add Category::info(int lineNumber,
> const char* filename, const char* stringFormat, ...) and add two members
> lineNumber, filename to LoggingEvent. In this way, the Layout classes
> could make use of the lineNumber and filename, if exist.
>
> Then one could use category.info(__LINE__, __FILE__, "server started"),
> instead of category.info("%s %d server started", __FILE__, __LINE).
>
> Any idea?
>
> Tony
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:
> The Definitive IT and Networking Event. Be There!
> NetWorld+Interop Las Vegas 2003 -- Register today!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
> _______________________________________________
> Log4cpp-devel mailing list
> Log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4cpp-devel
|