.. _Smart Log:

Smart Log
=========


For any invocation you can either use predefined filter sets for specific tools, or define your own filters and style maps in order to view the simulation output like the one below.

.. figure:: ../../images/common/vlogdt-vmm-smart-log.png
	:align: center




.. seealso::

	:ref:`Smart Log - Filters`

	:ref:`Smart Log - Hyperlinks`

	:ref:`Smart Log - Styles`
	
	:ref:`Run Configurations`




.. _Smart Log - Filters:

Smart Log - Filters
~~~~~~~~~~~~~~~~~~~



To define a new filter for a **DVT Generic** run configuration go to the Filters Tab, click New... and specify filter parameters.

.. figure:: ../../images/common/vlogdt-external-smart-log-new-filter.png
	:align: center




The main filter parameters are:

-  **Name** - The name of the filter
-  **Severity** - The severity of the filter.
-  **Pattern** - The filter pattern.  Use **${file}** to indicate a file hyper-link, and **${line}** to indicate the line to jump to.  Use **(?<TAG_NAME>)** to tag a group that will be used to randomly or explicitly assign a style (green bold for example - see :ref:`Smart Log - Styles`).

.. figure:: ../../images/common/vlogdt-external-smart-log-filters.png
	:align: center




In the Filters Tab you can also set other parameters such as:

-  The maximum number of characters per line (**1**)
-  The maximum number of consecutive lines (**2**)
-  Whether links should jump to resources from the current working set (**5**)

You can browse through predefined filters to see more examples (**3**).

You can also add a filter pattern for your console title (**4**). This should contain capturing groups whose contents will be appended to the console title. For example the pattern in the image above: "DVT_CONSOLE_TITLE\s+(\w+)" will append  to the console title when it will match a text like "DVT_CONSOLE_TITLE my_title" in the console output.


.. _Smart Log - Hyperlinks:

Smart Log - Hyperlinks
~~~~~~~~~~~~~~~~~~~~~~



Using the predefined filters enables you access to hyperlinks for files and also for some error codes of certain simulators. By clicking on a hyperlinked error code a dialog pops-up with the explanation of that error provided by the simulator help tool. 

.. figure:: ../../images/common/dvt-smart-log-simulator-help-error.png
	:align: center




DVT supports **verror** for Questa and **nchelp** for IUS. You can customize the name of these tools by setting the following environment variables: ``DVT_VERROR_TOOL_NAME`` and ``DVT_NCHELP_TOOL_NAME``

You can further customize this feature by creating your own regular expression for a custom hyperlink that launches a defined launch configuration. Use ``${cmd:run_configuration:regular_expression}`` to define these custom hyperlinks in your filter pattern, where **run_configuration** is the name of the launch configuration that is going to be launched when clicking on the hyperlink and **regular_expression** is the regular expression whose matched result will be hyperlinked. 

For example when running a launch configuration that outputs the location of a log file like this one:

.. figure:: ../../images/common/dvt-smart-log-custom-hyperlink.png
	:align: center




in order to hyperlink the location of the file a pattern needs to be defined:

.. figure:: ../../images/common/dvt-smart-log-custom-hyperlink-pattern.png
	:align: center




To summarize the content of the log file and display just the number of errors, warnings and infos in a new console:

.. figure:: ../../images/common/dvt-smart-log-custom-hyperlink-output.png
	:align: center




the "Summarize_log" launch configuration is defined with the ``$DVT_HYPERLINK_COMMAND_CAPTURING_GROUP_0`` environment variable

.. figure:: ../../images/common/dvt-smart-log-launch-configuration.png
	:align: center




.. _Smart Log - Styles:

Smart Log - Styles
~~~~~~~~~~~~~~~~~~



Assuming the filter MyTrace has a pattern Trace  (?<AGENT_KIND>[a-zA-Z_0-9]+) (?<INSTANCE>[a-zA-Z_0-9]+).* that contains 2 groups tagged <AGENT_KIND> and <INSTANCE>, DVT will randomly assign a color for each unique combination (AGENT_KIND_match, INSTANCE_match).

You'll get different colors for:

-  Master M1 (<AGENT_KIND> group matched "Master" and <INSTANCE> matched "M1")
-  Master M2 (<AGENT_KIND> group matched "Master" and <INSTANCE> matched "M2")
-  Slave S1 (<AGENT_KIND> group matched "Slave" and <INSTANCE> matched "S1")
-  Slave S2 (<AGENT_KIND> group matched "Slave" and <INSTANCE> matched "S2")




You can manually assign colors by editing the **.dvt/log_styles.xml** file:

You can easily share log styles using :ref:`Managed Settings`.


.. code-block::

	<?xml version="1.0" encoding="UTF-8"?>

	<section name="attributes">

	<item key="version" value="1"/>

	<list key="log_styles">

	<item value="PATTERN_NAME=MyTrace, AGENT_KIND=Master, INSTANCE=M1, COLOR=#FF8000, FONT_STYLE=BOLD, BORDER_STYLE=NONE"/>

	<item value="PATTERN_NAME=MyTrace, AGENT_KIND=Master, INSTANCE=M2, COLOR=#008000, FONT_STYLE=BOLD, BORDER_STYLE=NONE"/>

	<item value="PATTERN_NAME=MyTrace, AGENT_KIND=Slave, INSTANCE=S1, COLOR=#800080, FONT_STYLE=BOLD, BORDER_STYLE=NONE"/>

	<item value="PATTERN_NAME=MyTrace, AGENT_KIND=Slave, INSTANCE=S2, COLOR=#8080FF, FONT_STYLE=BOLD, BORDER_STYLE=NONE"/>

	</list>

	</section> 



For example the first line means "If pattern MyTrace matched and AGENT_KIND is 'Master' and INSTANCE is 'M1' set color to ...".

You can use regular expressions, for example AGENT_KIND=M*.

You can specify the **COLOR**, the **FONT_STYLE** (BOLD or ITALIC), and the **BORDER_STYLE** (DOT or SOLID or NONE).


.. note::

	If you want to also use the random color palette available for the predefined filters, you should add the following item in the **.dvt/log_styles.xml** file:


