pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pdf-devel] Logging function


From: jemarch
Subject: Re: [pdf-devel] Logging function
Date: Mon, 18 Feb 2008 22:23:14 +0100
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/23.0.60 (i686-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

   I am thinking in preparing a simple logging function to be used mostly 
   for development and debugging purposes. It would allow to enable at 
   configure level not only the level of debug wanted, but also which 
   modules should have the logging enabled.

I think that the logging system should be simple enough to be
implemented using just a few macros. The proper place to define these
macros would be the error module.

I agree with Cirilo in that traces should be simply written to
stderr. 

   /* Enumeration of log types (only for Base layer modules yet) */
   enum pdf_log_type_e {
      PDF_LOG_TYPE_BASE_MEMORY      = 0,
      PDF_LOG_TYPE_BASE_BASICTYPES  = 1,
      ...
   };

Ok. To be able to select the tracing scope (the full library, a
specific layer or a specific module) is useful and easy to implement.

   /* Enumeration of log levels */
   enum pdf_log_level_e {
      PDF_LOG_LEVEL_DEBUG   = 0,
      PDF_LOG_LEVEL_INFO    = 1,
      PDF_LOG_LEVEL_WARNING = 2,
      PDF_LOG_LEVEL_ERROR   = 3,
      PDF_LOG_LEVEL_NONE    = 4
   };

I would not use several log levels. The library is not expected to
emit traces except for debugging purposes or to notify fatal errors.

   /* Main logging function */
   void pdf_log(enum pdf_log_level_e log_level,
                 enum pdf_log_type_e  log_type,
                 const char           *str_template,
                 ...);

I like gerel's proposal to use a conditional macro `PDF_DEBUG' (or a
set of macros `PDF_DEBUG_*' if we implement several logging scopes)
that may expand to the empty string.

   The output would be something like:
   [GNU PDF Warning] (Base-Text) Invalid UTF-16BE point found at index '8'

I would use instead the GCS recommended format for non-interactive
programs:

     program:source-file-name:lineno: message

In this way Emacs (and presumably other tools) will be able to parse
the debugging traces.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]