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:
- 1:41f6c5ec11c2
- Parent:
- 0:eae9045546f3
- Child:
- 2:f3c036aca508
diff -r eae9045546f3 -r 41f6c5ec11c2 xenonym_logging.h --- a/xenonym_logging.h Thu Aug 04 20:29:26 2011 +0000 +++ b/xenonym_logging.h Thu Aug 04 21:59:29 2011 +0000 @@ -29,8 +29,14 @@ */ #define LOG LOGGER << xenonym::logging::eol +#ifdef LOGGING_DISABLED +#define LOGFUNC( x ) +#define LOGSCOPE( n, x ) +#else #define LOGFUNC( x ) xenonym::logging::Func func( x, __FILE__, __LINE__ ) #define LOGSCOPE( n, x ) xenonym::logging::Scope n( x, __FILE__, __LINE__ ) +#endif + namespace xenonym {