14.4 HTML

The HTML plug-in is a sample implementation and is intended to be used as reference for implementing own HTML plug-ins.

Ascolog Insight is delivered with a sample plug-in called HTML that converts logs to HTML. An HTML table is used to display the logs. The HTML plug-in is only a demo. It is based on Ascolog Insight's SDK.

You can use the layout “TestLayout.xml” which is delivered with Ascolog Insight to study the HTML sample. Alternatively, add the code snippet listed in example Code snippet for exporting to HTML to a custom columns definition of your layout. You can either put this code in an own custom columns definition file which you have to include in the layout's main custom columns definition or you can directly put the code into the layout's main custom columns definition file.

#include <basemacros.cdf> #include <basecolumns.cdf>
// columns used for HTML conversion
#define _HTMLCOLUMN(name, label, img) dti($HTML_column_##name, fmt(label##"#00"##img##".ico"))
#define HTMLCOLUMN(name) _HTMLCOLUMN(name, #@name, #@name)
#define HTMLESCAPE(txt) rpl(txt, "%0d%0a", "<br/>", "<", "&lt;", ">", "&gt;", "&", "&amp;")

 

#define HTML_MAX_TEXT_LENGTH 80

 

HTMLINIT = ONCE(exe("HTMLInit", "", "Type", "Timestamp,left,10", "ThreadId", "ProcessId", "Text,left,30", "File,left,70"));

 

HTML_TYPE = map(TYPE, TYPE, "0",HTMLCOLUMN(Trace), "1",HTMLCOLUMN(Info), "2",HTMLCOLUMN(Warning), "3",HTMLCOLUMN(Error), "4",HTMLCOLUMN(Fatal));
#if HTML_MAX_TEXT_LENGTH != 0
HTML_TEXT = HTMLESCAPE(cdt( { text == %1 }, dat($tmp, cpy(TEXT, 1, 0, HTML_MAX_TEXT_LENGTH)), dat($tmp), fmt("%s...", dat($tmp))));
#else
HTML_TEXT = HTMLESCAPE(TEXT);
#endif

Code snippet for exporting to HTML

The command HTMLInit in the custom columns definition specifies the HTML table's header and the columns of the HTML table (e.g. width and text alignment).

Record definition for HTML conversion
Record definition for HTML conversion

In order to export to HTML go to the Tools menu of the main menu and open the Options dialog. In the Calculation category set the AutoRecalcMode to DYNAMIC or FORCE. Then go to the File menu and select Convert... to open the Conversion dialog. In the Record definition list you must add all the columns which are passed as parameters to the command HTMLInit in the custom columns definition in the same order, otherwise the HTML table won't be correct. Moreover, you have to set the Encoding to HTML and specify a file name in the File name field. The file name should have the extension “.html” or “.htm”. If your Conversion dialog looks similar to the one in figure Record definition for HTML conversion press the Save button to convert the log records and save them to an HTML file.

When you open the HTML file in a web browser you will see an HTML table containing the log records similar to the ones shown in figure HTML table containing the log records. If you do not see the icons in the Type column check if the paths to the icons in the created HTML file and the actual location of the icon files in the file system match.

HTML table containing the log records
HTML table containing the log records