cf_log
cf_log
| Version: | 1.0 build 20040507 |
|---|---|
| Requires: | Adobe ColdFusion 5.0 or greater |
| Total size: | 2.73 KB |
| Download time: | 0.49 seconds at 56kbps |
| Edition: | Freeware |
Description
Write to a CSV-formatted log file. This tag is similar to the cflog tag, but may write to any location. While the standard columns generated by cflog will be generated by cf_log, any extra attributes will result in additional columns.
Result
Writes to a physical file.
Category
debugging
Parameters
| Parameter | Type | Required? | Default | Description |
|---|---|---|---|---|
| file | string | Yes | Absolute path of log file. | |
| type | string | No | Information | Severity of log entry, e.g.: Information, Warning, Error, Fatal Error. |
| text | string | No | Message to log. | |
| [Any other parameters] | string | No | Any other parameters will be logged as extra columns. |
Custom tag source
<!---** * cf_log * Write to a CSV-formatted log file. This tag is similar to the cflog tag, * but may write to any location. While the standard columns generated by cflog * will be generated by cf_log, any extra attributes will result in additional * columns. * * @param file Absolute path of log file (required) * @param type Severity of log entry. Default: Information. * @param text Message to log. * Any other parameters Further data to log * @result Creates and appends a physical file * @author Matthew Walker, WWW.eswsoftware.com * @version 1, 20040507 * Recent changes: * 20040507 * Added locking * 20040419 * version 1 released *---> <cfif thisTag.executionMode eq "start"> <cfparam name="attributes.text" type="string" default=""> <cfparam name="attributes.file" type="string"> <cfparam name="attributes.type" type="string" default="Information"> <cfparam name="request.eswsoftware" default="#structNew()#"> <cfparam name="request.eswsoftware.log" default="#structNew()#"> <cfset request.eswsoftware.log.version = 1> <cflock timeout="1" throwontimeout="No" name="cflog" type="EXCLUSIVE"> <cfif not fileExists(attributes.file)> <cfset line = """Severity"",""Date"",""Time"",""Application"",""Message"""> <cfloop collection="#attributes#" item="key"> <cfif not listFindNoCase("file,name,template,text,type", key)> <cfset heading = replace(key, "_", " ", "all")> <cfset headingL = uCase(left(heading, 1))> <cfif len(heading) gt 1> <cfset headingR = lCase(mid(heading, 2, len(heading)-1))> <cfelse> <cfset headingR = ""> </cfif> <cfset heading = headingL & headingR> <cfset line = line & ",""#heading#"""> </cfif> </cfloop> <cffile action="WRITE" file="#attributes.file#" output="#line#" addnewline="Yes"> </cfif> </cflock> <cfset severity = attributes.type> <cfset date = dateFormat(now())> <cfset time = timeFormat(now())> <cfif structKeyExists(application, "applicationName")> <cfset app = application.applicationName> <cfelse> <cfset app = ""> </cfif> <cfset message = replace(attributes.text, """", """""", "all")> <cfset line = """#severity#"",""#date#"",""#time#"",""#app#"",""#message#"""> <cfloop collection="#attributes#" item="key"> <cfif not listFindNoCase("file,text,type", key)> <cfset line = line & ",""#replace(attributes[key], """", """""", "all")#"""> </cfif> </cfloop> <cflock timeout="1" throwontimeout="No" name="cflog" type="EXCLUSIVE"> <cffile action="APPEND" file="#attributes.file#" output="#line#" addnewline="Yes"> </cflock> </cfif>
World Wide Web
