This isn't even a case of me not RTFMing and then discovering something I didn't know. I knew this already. But am just a bit dense.
I'm perennially doing this sort of thing:
private function logArgs(required struct args, required string from){
savecontent variable="local.dump" {
writeDump(var=args, label=from);
}
fileWrite(getDirectoryFromPath(getCurrentTemplatePath()) & "dump_#from#.html", local.dump);
(As case in point being: I just wrote that code for a new blog article that I should have done and dusted by this evening)
However I don't need to do that. I can just do this:
private function logArgs(required struct args, required string from){
var dumpFile = getDirectoryFromPath(getCurrentTemplatePath()) & "dump_#from#.html";
if (fileExists(dumpFile)){
fileDelete(dumpFile);
}
writeDump(var=args, label=from, output=dumpFile, format="html");
}
I'm so accustomed to only every using the
var
argument, and occasionally the label
one, I tend to forget there's a bunch of other options on <cfdump>
/ writeDump()
as well (from the docs):Attribute | Req/Opt | Default | Description |
---|---|---|---|
var | Required | Variable to display. Enclose a variable name in number signs. These kinds of variables yield meaningful cfdump output | |
expand | Optional | yes |
|
format | Optional | text | Use with the output attribute to specify whether to save the results of a cfdump to a file in text or HTML format. |
hide | Optional | all | For a query, this is a column name or a comma-delimited list of column names. For a structure, this is a key or a comma-delimited list of keys. If you specify a structure element that doesn't exist, ColdFusion ignores it and does not generate an error. |
keys | Optional | 9999 | For a structure, the number of keys to display. |
label | Optional | A string; header for the dump output. Ignored if the value of the var attribute is a simple types. | |
metainfo | Optional | yes for queryno for persistence CFCs | For use with queries and persistence CFCs. Includes information about the query in the cfdump results, including whether the query was cached, the execution time, and the SQL. Specify metainfo="no" to exclude this information from the query result. For persistence CFCs, if metainfo="yes", returns property attributes such as getters and setters. |
output | Optional | browser | Where to send the results of cfdump . The following values are valid:
|
show | Optional | all | For a query, this is a column name or a comma-delimited list of column names. For a structure, this is a key or a comma-delimited list of keys. |
showUDFs | Optional | yes |
|
top | Optional | 9999 | The number of rows to display. For a structure, this is the number of nested levels to display. |
abort | Optional | false | If this attribute is set to "true", it stops processing the current page at the tag location. |
Perhaps everyone else in the world remembers all this stuff and uses it all the time. I'm simply not that clever.
--
Adam