[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pdf-devel] Logging function
From: |
Aleksander Morgado |
Subject: |
[pdf-devel] Logging function |
Date: |
Mon, 18 Feb 2008 16:26:12 +0100 |
User-agent: |
Thunderbird 2.0.0.9 (Macintosh/20071031) |
Hi all,
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.
For example,
./configure --enable-log-base-text --with-log-level=debug
Would enable log level DEBUG in the Text Module of the Base layer
./configure --enable-log-object-reader --enable-log-object-writer
--with-log-level=info
Would enable log level INFO in the Reader and Writer Modules of the
Object layer
./configure --enable-log-base-all --with-log-level=warning
Would enable log level WARNING in All the modules of the Base layer
The API would be something like this:
/* 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,
PDF_LOG_TYPE_BASE_HASH = 2,
PDF_LOG_TYPE_BASE_LIST = 3,
PDF_LOG_TYPE_BASE_STREAM = 4,
PDF_LOG_TYPE_BASE_FLOAT = 5,
PDF_LOG_TYPE_BASE_TEXT = 6,
PDF_LOG_TYPE_BASE_TIME = 7,
PDF_LOG_TYPE_BASE_FILESYSTEM = 8,
PDF_LOG_TYPE_BASE_ERROR = 9,
PDF_LOG_TYPE_MAX
};
/* 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
};
/* Main logging function */
void pdf_log(enum pdf_log_level_e log_level,
enum pdf_log_type_e log_type,
const char *str_template,
...);
So that, for example, the Text module can call the logging function in
this way:
pdf_log(PDF_LOG_LEVEL_WARNING, PDF_LOG_TYPE_BASE_TEXT, \
"Invalid %s point found at index '%u'", \
encoding, position);
The message will be dumped to stderr only if `--enable-log-base-text'
was used when calling configure, and if at least `warning' level was
selected in `--with-log-level'.
The output would be something like:
[GNU PDF Warning] (Base-Text) Invalid UTF-16BE point found at index '8'
What do you think?
Aleksander
- [pdf-devel] Logging function,
Aleksander Morgado <=