Macro names are changed as indicated earlier and a test is also added to the patch. Pls review & commit.
Function Prototype
AXIS2_LOG_XXX(log,file,line,formated_string,...);

XXX stands for the log level
Example
AXIS2_LOG_DEBUG(log,__FILE__,__LINE__,"this  is a  test  %s","test123");

Note:
We wanted to get File name and line number transparently to the macros. (e.g. AXIS2_LOG_DEBUG(log,formated_string,...)) This can be done with UNIX using __VA_ARGS__ macro. But for windows, this macro is not found in VC versions <= 7. would appreciate if someone can come up with a way to use variable number of arguments in macros in windows.
Thanks.

-Nabeel

Samisa Abeysinghe wrote:

Oh yes, I missed that. We have to change this.

Samisa...

Nabeel wrote:

Log levels are already defined as AXIS2_LOG_DEBUG, AXIS2_LOG_INFO, etc. Since these enums are used in many places in the source code to wrtie logs, I didn't want to change them with this patch.

Ideally these enums should be changed to AXIS2_LOG_LEVEL_DEBUG, AXIS2_LOG_LEVEL_INFO, etc and as you suggested, the functions should be changed as AXIS2_LOG_DEBUG, AXIS2_LOG_INFO, etc.

- Nabeel

Samisa Abeysinghe wrote:

This is cool. BTW, why did you use _F_ in the function macro? any specific reason? I would like it to read as AXIS2_LOG_DEBUG instead of AXIS2_F_LOG_DEBUG.
Thanks,
Samisa...

Nabeel wrote:

Sorry..missed the Axised prefix..

Nabeel wrote:

Hi,
log implementation is updated to have the following methods. and these methods take variable number of arguments (work just like printf,sprintf, etc). now you don't need to do a sprintf to create the string and pass it to log write method. Pls review and commit if useful.

AXIS2_F_LOG_DEBUG
AXIS2_F_LOG_INFO
AXIS2_F_LOG_ERROR
AXIS2_F_LOG_WARNING
AXIS_F_LOG_CRITICAL

(for performance reasons and convenience, instead of using a switch, seperate methods are written for different log levels)
All these takes similar set of arguments
(log,__FILE__,__LINE__,formated string)

e.g.:
AXIS2_F_LOG_INFO(log,__FILE__,__LINE__,"my info %s %d","test",1);

this would log
[info] xxx.c(nn) my info test 1

files in the patch:
modules/util/log.c
modules/util/axis2_log_default.h
include/axis2_log.h

3 booleans are defined to independently on/off debug/info/warning logs. (log_level parameter may be removed if we go for this scheme. AXIS2_LOG_WRITE macro works as it used to, but prints the file name and line number transparently.
TODO (suggestions): read log configuations from an xml file
implement AXIS2_F_LOG_XML(log obj ,xml obj, formated string) using a file descriptor instead of stderr (2) and keeping previous log when the app restarts

Thanks
- Nabeel










Attachment: patch_log2.tar.gz
Description: GNU Zip compressed data

Reply via email to