[webkit-dev] newbie question

Mark Rowe mrowe at apple.com
Wed Nov 7 10:37:45 PST 2007


On 08/11/2007, at 05:23, Amit Joshi wrote:

> I have just started my hacking adventure in the webkit code-base. I  
> was wondering whats a typical way to print log output lines ? I can  
> always write my own routine to write into my own log file, but I  
> thought may be there would be a standard way of doing this through  
> some common routine/class in this huge code base. I came across WTF  
> log functions, like this one
> void WTFReportError(const char* file, int line, const char*  
> function, const char* format, ...)..
>
These functions are not typically used directly.  There are several  
macros, also defined in Assertions.h, that wrap them and provide sane  
values for most of the arguments.  Of particular interest to you will  
be the LOG macro.  The icon database code in WebCore/loader/icon/ 
IconDatabase.cpp makes heavy use of this.  Be aware that by default  
logging is only available in debug builds, and that the majority of  
the logging channels are disabled unless explicitly enabled.  On the  
Mac user defaults can be used to enable or disable a given channel.
> Is this whats been used typically to print debug info ? I wonder  
> what function and line parameters (used in all other WTF log  
> functions) mean ?
>
The file, line and function parameters are the file, source line  
number and function name of the code emitting the log output.  This  
makes it easy to pinpoint exactly what code is emitting a given  
message.  LOG and friends will pass __FILE__, __LINE__ and  
__FUNCTION__ here as is appropriate.
> I always feel being able to print your own 'hello-world' line in the  
> new code-base is very important in order to be comfortable with the  
> code you are hacking ..
>
If you're just hacking around and using the logging for debugging, I  
find that fprintf(stderr, ...); works really well.  No need to get  
fancy unless the logging is intended to be permanent.

Kind regards,

Mark Rowe



More information about the webkit-dev mailing list