4 votes

XSLT LogHelper

 

I needed a way to easily add log rows from my xslt macros, and added a single-line-extension for that reason. And for it to be a little more complete I also added a getlog-function. 

For the most complete way to watch and handle log rows, I would recommend using the other logging packages, but if you for some reason need it inside your Xslt, you can use this.

Add a log row : 

xsl:value-of select="LogHelper:LogAdd(-1, 'heres a comment for the log')"

Iterate the log rows from last 2 days: 

xsl:for-each select="LogHelper:GetLog(2)/Log/Logrows [logHeader='Custom']

The LogAdd-function adds a row with "Custom" header.

Have fun!

I have used ideas from Niels Hartvig (HelloWorldExt) and Immo Wache (Log4Umbraco).

The whole thing is 40 or so lines of code, and you find the source at the codeplex site.

Here's a sample XSLT that adds a log row, and displays a html-table with all log rows with header "Custom" from last 1 day:

<!-- add log row -->
<xsl:value-of select="LogHelper:LogAdd(-1, 'heres a comment for the log')"/>

<!-- get log rows for 1 day and display it in a table, newest at the top-->
<xsl:variable name="getDays" select="1"/>
<table>
<tr><th>logHeader</th><th>DateStamp</th><th>userId</th><th>nodeId</th><th>logComment</th></tr>
<xsl:for-each select="LogHelper:GetLog($getDays)/Log/Logrows [logHeader='Custom']">
<xsl:sort select="./DateStamp" order="descending"/>
<tr><td><xsl:value-of select="./logHeader"/></td><td><xsl:value-of select="./DateStamp"/></td><td><xsl:value-of select="./userId"/></td><td><xsl:value-of select="./nodeId"/></td><td><xsl:value-of select="./logComment"/></td></tr>
</xsl:for-each>
</table>

 

Screenshots

Archived files

Documentation

Source code

Package owner

Jonas Eriksson

Jonas Eriksson

Jonas has 1818 karma points

Package Compatibility

This package is compatible with the following versions as reported by community members who have downloaded this package:
Untested or doesn't work on Umbraco Cloud
7.12.x (untested)
7.11.x (untested)
7.10.x (untested)
7.9.x (untested)
7.8.x (untested)
7.7.x (untested)
7.6.x (untested)
7.5.x (untested)
7.4.x (untested)
7.3.x (untested)
7.2.x (untested)
7.1.x (untested)
7.0.x (untested)
6.1.x (untested)
6.0.x (untested)

You must login before you can report on package compatibility.

Package Information

  • Package owner: Jonas Eriksson
  • Created: 19/03/2010
  • Current version 0.9
  • License MIT
  • Downloads: 800

External resources