I needed to create an HTML logger that would be portable across Win32 and VXWorks OSs.
This code was written in a weekend so don't judge it severely.
What the code does
This code will help you create colored, clear to read HTML logs from any C++ applications.
The HTML log generated will be easy to present to a user: you just need to give
a browser the generated file URL and refresh the browser once the log changes.
This code does not use MFC or any other library. In order to provide thread safety there are
a couple of classes (namely: CLock, CGuard ) that helps make the code safe.
Furthermore, there are additional helper classes that hides nasty details:
- CGenFile - hides the file access details
- CLogFont - generally an implementation of HTML font tag
- CLogColor - an implementation of HTML color
- CSmartString - a string class.
Using the code
Instantiate CHtmlLogger in your code, create the log, create as many HTML tables (reports)
as you wish.
Log.Create( "FirstHMLLog.htm" );
Log.CreateTable( 3, "First HTML log" );
Log.SetColumn( 0, "Heading1" );
Log.SetColumn( 1, "Heading2" );
Log.SetColumn( 2, "Heading3" );
Log.AddLine( 0, CHtmlLogger::LT_Header );
Kindergarten stuff, right ? The return values validation was removed for clarity.
You should look at the sample provided to see the full API.
The sample will create a sample log you see in the picture.