Link | log_sqlerror |
Author | Jason Huck |
Category | Utility |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 22 Jan 2006 |
Updated | 22 Jan 2006 |
More by this author... |
This tag creates a log file (and optionally displays each entry on screen) containing additional helpful information about SQL errors. It logs the date and time of the error, the [error_code] and [error_msg] returned by Lasso, the [client_ip] and [response_url] that generated the error, and a custom message. Speeds debugging by putting all the pertinent details about the error in one central location and provides a focused audit trail. The formats of the timestamp, delimiter, line break, etc. are configurable.
Note: requires [response_url], available here.
inline( $dbconn, -sql=$sql ); // with no arguments, the tag will use // [action_statement] and other defaults log_sqlerror; /inline; inline( $dbconn, -sql=$sql ); log_sqlerror( -sql=$sql, -msg='Adding user.', -logpath='/errors/badsql.tab', -linebreak='\n', -delimiter='|', -dateformat='%m/%d/%Y', -display=true ); /inline;
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'sqlerror', -namespace='log_', -autooutput, -priority='replace', -optional='sql', -optional='msg', -optional='logpath', -optional='linebreak', -optional='delimiter', -optional='dateformat', -optional='display', -type='boolean', -description='Logs details about errors in SQL queries.' ); if(error_code != 0); !local_defined('sql') ? local('sql' = action_statement); local('cleanSQL') = string_replaceregexp( #sql, -find='(\\s+)', -replace=' ' ); local('defaults') = array( 'logpath' = '/__logs/badqueries.txt', 'linebreak' = '\r\n', 'delimiter' = '\t', 'dateformat' = '%Q %H:%M:%S', 'display' = false ); iterate(#defaults, local('i')); !local_defined(#i->first) ? local(#i->first = #i->second); /iterate; local('out' = string); #out += date->format(#dateformat) + #delimiter; #out += response_url + #delimiter; #out += client_ip + #delimiter; #out += (local_defined('msg') ? #msg | 'none') + #delimiter; #out += error_code + ' - ' + error_msg + #delimiter; #out += #cleanSQL + #delimiter; #out += #linebreak; log(#logpath); #out; /log; if(#display); #out->replace(#delimiter, #linebreak); #out->replace(#cleanSQL, ((#linebreak * 2) + #sql)); #out = '' + #out + '
'; return(@#out); /if; /if; /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft