You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Samisa Abeysinghe <sa...@gmail.com> on 2006/01/27 20:09:34 UTC
[Axis2] File name and line number in log messages
Hi All,
It is useful to have file name and number info in some log messages.
As an example, debug level log messages must have this to help find
where it went wrong.
I get the following debug messages from simple axis server when
testing and I have no clue on where they came from:
[debug] AXIS2_XML_READER_START_ELEMENT
[debug] identified soap version is soap12
[debug] AXIS2_XML_READER_SPACE
[debug] AXIS2_XML_READER_START_ELEMENT
[debug] AXIS2_XML_READER_SPACE
[debug] AXIS2_XML_READER_END_ELEMENT
[debug] AXIS2_XML_READER_SPACE
[debug] AXIS2_XML_READER_END_ELEMENT
Also, just poping up the error code in the log makes no sense. We
need more details, human readable and understandable message into the log.
Please help fix this.
Thanks,
Samisa...
Re: [Axis2] File name and line number in log messages
Posted by Samisa Abeysinghe <sa...@gmail.com>.
Nabeel wrote:
> Yes..correct; should set the __FILE__ and __LINE__ macros to
> AXIS2_LOG_WRITE macro
>
> in axis2_log.h
> #define AXIS2_LOG_WRITE(log, buffer, level) ((log)->ops->write(log,
> buffer, level,__FILE__,__LINE__))
>
> in log.c
>
> axis2_status_t AXIS2_CALL
> axis2_log_impl_write (struct axis2_log *log, const axis2_char_t
> *buffer, axis2_log_levels_t level,char *fn,int ln)
> {
> ...
> fprintf(stderr,"%s%s(%d) %s\n", level_str,fn,ln,buffer);
> }
Yep, may be we could provide an interface to do this in log ops struct
interface.
Thanks,
Samisa...
>
> - Nabeel
>
>
> Samisa Abeysinghe wrote:
>
>> Nabeel wrote:
>>
>>> The following change to log.c:axis2_log_impl_write() fn would log
>>> the line number and file name along with the error msg
>>>
>>> /*fprintf (stderr, "%s", level_str);*/
>>> /*fprintf (stderr, "%s\n", buffer);*/
>>> fprintf(stderr,"%s%s(%d) %s\n", level_str,__FILE__,__LINE__,buffer);
>>
>>
>>
>> I am afraid not. Then it will laways log the line number of loc.c
>> file :(
>> e.g.
>> [info] log.c(96) axis2_handler_t *addressing_based_dispatcher added
>> to the index 0 of the phase Dispatch
>> [info] log.c(96) axis2_handler_t *request_uri_based_dispatcher added
>> to the index 1 of the phase Dispatch
>> [info] log.c(96) axis2_handler_t *soap_action_based_dispatcher added
>> to the index 2 of the phase Dispatch
>> [info] log.c(96) axis2_handler_t *soap_message_body_based_dispatcher
>> added to the index 3 of the phase Dispatch
>> [info] log.c(96) axis2_handler_t *dispatch_post_conditions_evaluator
>> added to the index 0 of the phase PostDispatch
>> [info] log.c(96) axis2_handler_t *context_handler added to the index
>> 1 of the phase PostDispatch
>>
>> You have to use __FILE__ and __LINE__ from the respective source file
>> and pass that to log.c
>>
>> Samisa...
>>
>>>
>>> - Nabeel
>>>
>>> Samisa Abeysinghe wrote:
>>>
>>>> Hi All,
>>>> It is useful to have file name and number info in some log
>>>> messages. As an example, debug level log messages must have this to
>>>> help find where it went wrong.
>>>> I get the following debug messages from simple axis server when
>>>> testing and I have no clue on where they came from:
>>>> [debug] AXIS2_XML_READER_START_ELEMENT
>>>> [debug] identified soap version is soap12
>>>> [debug] AXIS2_XML_READER_SPACE
>>>> [debug] AXIS2_XML_READER_START_ELEMENT
>>>> [debug] AXIS2_XML_READER_SPACE
>>>> [debug] AXIS2_XML_READER_END_ELEMENT
>>>> [debug] AXIS2_XML_READER_SPACE
>>>> [debug] AXIS2_XML_READER_END_ELEMENT
>>>>
>>>> Also, just poping up the error code in the log makes no sense.
>>>> We need more details, human readable and understandable message
>>>> into the log.
>>>>
>>>> Please help fix this.
>>>> Thanks,
>>>> Samisa...
>>>>
>>>
>>>
>>
>>
>
>
Re: [Axis2] File name and line number in log messages
Posted by Nabeel <na...@wso2.com>.
Yes..correct; should set the __FILE__ and __LINE__ macros to
AXIS2_LOG_WRITE macro
in axis2_log.h
#define AXIS2_LOG_WRITE(log, buffer, level) ((log)->ops->write(log,
buffer, level,__FILE__,__LINE__))
in log.c
axis2_status_t AXIS2_CALL
axis2_log_impl_write (struct axis2_log *log, const axis2_char_t *buffer,
axis2_log_levels_t level,char *fn,int ln)
{
...
fprintf(stderr,"%s%s(%d) %s\n", level_str,fn,ln,buffer);
}
- Nabeel
Samisa Abeysinghe wrote:
> Nabeel wrote:
>
>> The following change to log.c:axis2_log_impl_write() fn would log the
>> line number and file name along with the error msg
>>
>> /*fprintf (stderr, "%s", level_str);*/
>> /*fprintf (stderr, "%s\n", buffer);*/
>> fprintf(stderr,"%s%s(%d) %s\n", level_str,__FILE__,__LINE__,buffer);
>
>
> I am afraid not. Then it will laways log the line number of loc.c file :(
> e.g.
> [info] log.c(96) axis2_handler_t *addressing_based_dispatcher added to
> the index 0 of the phase Dispatch
> [info] log.c(96) axis2_handler_t *request_uri_based_dispatcher added
> to the index 1 of the phase Dispatch
> [info] log.c(96) axis2_handler_t *soap_action_based_dispatcher added
> to the index 2 of the phase Dispatch
> [info] log.c(96) axis2_handler_t *soap_message_body_based_dispatcher
> added to the index 3 of the phase Dispatch
> [info] log.c(96) axis2_handler_t *dispatch_post_conditions_evaluator
> added to the index 0 of the phase PostDispatch
> [info] log.c(96) axis2_handler_t *context_handler added to the index 1
> of the phase PostDispatch
>
> You have to use __FILE__ and __LINE__ from the respective source file
> and pass that to log.c
>
> Samisa...
>
>>
>> - Nabeel
>>
>> Samisa Abeysinghe wrote:
>>
>>> Hi All,
>>> It is useful to have file name and number info in some log
>>> messages. As an example, debug level log messages must have this to
>>> help find where it went wrong.
>>> I get the following debug messages from simple axis server when
>>> testing and I have no clue on where they came from:
>>> [debug] AXIS2_XML_READER_START_ELEMENT
>>> [debug] identified soap version is soap12
>>> [debug] AXIS2_XML_READER_SPACE
>>> [debug] AXIS2_XML_READER_START_ELEMENT
>>> [debug] AXIS2_XML_READER_SPACE
>>> [debug] AXIS2_XML_READER_END_ELEMENT
>>> [debug] AXIS2_XML_READER_SPACE
>>> [debug] AXIS2_XML_READER_END_ELEMENT
>>>
>>> Also, just poping up the error code in the log makes no sense. We
>>> need more details, human readable and understandable message into
>>> the log.
>>>
>>> Please help fix this.
>>> Thanks,
>>> Samisa...
>>>
>>
>>
>
>
Re: [Axis2] File name and line number in log messages
Posted by Samisa Abeysinghe <sa...@gmail.com>.
Nabeel wrote:
> The following change to log.c:axis2_log_impl_write() fn would log the
> line number and file name along with the error msg
>
> /*fprintf (stderr, "%s", level_str);*/
> /*fprintf (stderr, "%s\n", buffer);*/
> fprintf(stderr,"%s%s(%d) %s\n", level_str,__FILE__,__LINE__,buffer);
I am afraid not. Then it will laways log the line number of loc.c file :(
e.g.
[info] log.c(96) axis2_handler_t *addressing_based_dispatcher added to
the index 0 of the phase Dispatch
[info] log.c(96) axis2_handler_t *request_uri_based_dispatcher added to
the index 1 of the phase Dispatch
[info] log.c(96) axis2_handler_t *soap_action_based_dispatcher added to
the index 2 of the phase Dispatch
[info] log.c(96) axis2_handler_t *soap_message_body_based_dispatcher
added to the index 3 of the phase Dispatch
[info] log.c(96) axis2_handler_t *dispatch_post_conditions_evaluator
added to the index 0 of the phase PostDispatch
[info] log.c(96) axis2_handler_t *context_handler added to the index 1
of the phase PostDispatch
You have to use __FILE__ and __LINE__ from the respective source file
and pass that to log.c
Samisa...
>
> - Nabeel
>
> Samisa Abeysinghe wrote:
>
>> Hi All,
>> It is useful to have file name and number info in some log
>> messages. As an example, debug level log messages must have this to
>> help find where it went wrong.
>> I get the following debug messages from simple axis server when
>> testing and I have no clue on where they came from:
>> [debug] AXIS2_XML_READER_START_ELEMENT
>> [debug] identified soap version is soap12
>> [debug] AXIS2_XML_READER_SPACE
>> [debug] AXIS2_XML_READER_START_ELEMENT
>> [debug] AXIS2_XML_READER_SPACE
>> [debug] AXIS2_XML_READER_END_ELEMENT
>> [debug] AXIS2_XML_READER_SPACE
>> [debug] AXIS2_XML_READER_END_ELEMENT
>>
>> Also, just poping up the error code in the log makes no sense. We
>> need more details, human readable and understandable message into the
>> log.
>>
>> Please help fix this.
>> Thanks,
>> Samisa...
>>
>
>
Re: [Axis2] File name and line number in log messages
Posted by Nabeel <na...@wso2.com>.
The following change to log.c:axis2_log_impl_write() fn would log the
line number and file name along with the error msg
/*fprintf (stderr, "%s", level_str);*/
/*fprintf (stderr, "%s\n", buffer);*/
fprintf(stderr,"%s%s(%d) %s\n", level_str,__FILE__,__LINE__,buffer);
- Nabeel
Samisa Abeysinghe wrote:
> Hi All,
> It is useful to have file name and number info in some log
> messages. As an example, debug level log messages must have this to
> help find where it went wrong.
> I get the following debug messages from simple axis server when
> testing and I have no clue on where they came from:
> [debug] AXIS2_XML_READER_START_ELEMENT
> [debug] identified soap version is soap12
> [debug] AXIS2_XML_READER_SPACE
> [debug] AXIS2_XML_READER_START_ELEMENT
> [debug] AXIS2_XML_READER_SPACE
> [debug] AXIS2_XML_READER_END_ELEMENT
> [debug] AXIS2_XML_READER_SPACE
> [debug] AXIS2_XML_READER_END_ELEMENT
>
> Also, just poping up the error code in the log makes no sense. We
> need more details, human readable and understandable message into the
> log.
>
> Please help fix this.
> Thanks,
> Samisa...
>