[pgrouting-dev] New logger for C/C++ for pgrouting
    Stephen Woodbridge 
    woodbri at swoodbridge.com
       
    Sun May  4 11:06:48 PDT 2014
    
    
  
Hi Devs,
I have created a new very simple header file at:
pgrouting/src/common/src/pgr_logger.h
The goal for this is to provide a consistent way for adding debug 
messages to the C/C++ that get directed to a log file. There is a define 
that can be used to globally disable the logging on a per file basis.
I looked at a lot of other loggers for C/C++ but this seems to be good 
for our modest needs and it is easy to disable when we are ready to 
deploy it.
Let me know you thoughts and please use it for the C++ code. You can 
also use this for the C code, but most of the C code already is using 
postgresql elog() function to send NOTICE statements back to the client.
Thanks,
   -Steve
READ the header file it has documentation in it.
     USAGE:
     #define LOGGERR_ON
     #undef LOGGER_ON  // turn off logging for production
     // override the default log file "/tmp/pgr_logger.log"
     #define LOGGER_FILE "mylogger.log"
     #undef LOGGER_LOC  // dont log filename and line number
     #define LOGGER_LOC  // log filename and line number with log message
     // include the logger macros and configure based on defines above
     #include pgr_logger.h
     // log a message to the log file
     LOG(format, args)
     LOG("%s at %d\n", "this is a message", time())
     This will log something like:
     myfile:123: this is a message at 1399216875
    
    
More information about the pgrouting-dev
mailing list