Simple logging library that outputs over the PC serial link to add logging to a file simply `include "xenonym_logging.h" ` then you can add logging with which looks slighly like c++ std::cout logging by using the LOG define or the LOGGER define thus; LOG << "this message will begin a new line" or LOGGER << "this message will append to the end of the previous log"; there is also a simple `LOGFUNC( "funcname" );` define that will log the entry and exit from a function and indent the stream so its easy to see where you are. if you want to disable the logging from a file without removing your logging all you need do is ~#define LOGGING_DISABLED and the logging will compile to nothing. also has simple manipulators hex,dec to change the output radix and eol to start a new line. i.e. <<code>> #include "xenonym_logging.h" using namespace xenonym; class Devr : public Base { public: Devr( int i ) : Base(i) { LOGFUNC( "mylib::Devr" ); ... do stuff .. LOG << "param is still " << logging::dec << i; .... do more stuff .... } virtual uint16_t something( uint16_t msg ) { LOGFUNC( "Derv::something" ); uint16_t reply = proccess( msg ); LOG << "sent:0x" << logging::hex << msg << " reply:0x"<< reply << logging::dec; return reply; } }; <</code>>
Diff: xenonym_logging.h
- Revision:
- 2:f3c036aca508
- Parent:
- 1:41f6c5ec11c2
diff -r 41f6c5ec11c2 -r f3c036aca508 xenonym_logging.h --- a/xenonym_logging.h Thu Aug 04 21:59:29 2011 +0000 +++ b/xenonym_logging.h Thu Aug 04 22:02:33 2011 +0000 @@ -29,6 +29,9 @@ */ #define LOG LOGGER << xenonym::logging::eol +/** + * if logging is disabled then we do not want to create any scope logging objects. + */ #ifdef LOGGING_DISABLED #define LOGFUNC( x ) #define LOGSCOPE( n, x )