API: Log
Filename:
fwpLog_data.ctag
Released With:
5.0.0
Current Version:
1.0.1
Status: Active
Min Lasso Tested: 8.1.0
Max Lasso Tested: 8.5.3
Related:
Still don't get it?
Check out the talk list archives, or join and ask your questions.
Documentation Error or Request?
Email documentation corrections or comments
Writes to a tab delimited log file or database table certain user, page, and database information about database add, delete, and update actions. The tag is automatically executed when using built-in framework tags to modify database tables.
Logging can be turned on|off by setting the variable $fw_gLogDb to true|false. Text file rolling can be set to annual, monthly, weekly, or daily by setting the variable $fw_gLogDbRoll to 'A|M|W|D'. Local vars noted below are passed as tag parameters. The log can be directed to a text file or a data table by setting the variable $fw_gLogDbTarget to 'file|database'.
The following items are logged (with tab separators if text file used):
[server_date: -extended]
[server_time]
[Client_IP]
action = "add," "update," or "delete"
usrName = a logged in user's full name, or "anonymous"
usrRcrd = a logged in user's recordID, or "anonymous"
table = the database table name involved
recordID = the record ID involved
[response_filePath]
pageInfo = arbitrary info about the current page
fwpInfo = arbitrary info about the framework status
qryTime = the time in milliseconds to execute the action
fwpLog_data: -usrName = string, -usrRcrd = string, -table = string, -rcrd = string, -action = 'add|update|delete', -pageInfo = string, -fwpInfo = string, -qryTime = integer;
-usrName - required : a concatenation of the user's account first and last name fields, or the string "anonymous" if there's no logged in user
-usrRcrd - required : the user's account record ID, or the string "anonymous" if there's no logged in user
-table - required : the table being modified
-rcrd - required : the record ID of the record being modified
-action - required : the database action being performed
-pageInfo - required : custom misc info about the page. This is picked up by setting the variable $fw_logPageInfo to whatever is desired throughout the application on a per page basis. The default entry is "n/a" unless changed. This is particularly useful in editing systems like the event driven pages (EDP) framework where the same page name is used, but actually several different displays are possible. This input can be used to identify exactly which display the current page is using.
-fwpInfo - required : custom misc info about the current framework tag (if applicable). This is set by the internal framework code by setting the variable $fw_logFWPInfo to reflect what tag is active which can provide additional debugging info. The default entry is "n/a" unless changed. This capability was added in version 3.2, but hasn't been fully utilized in all tags yet.
-qryTime - required : the time in milliseconds it took to execute the query
An example from inside the fwp_recordData type:
if: ((var:$fw_userVarName)->'loginValid') == 'Y'; #fw_usrName = (var:$fw_userVarName)->(getProfile:'userName'); #fw_usrRcrd = (var:$fw_userVarName)->(getProfile:'userRcrdID'); else; #fw_usrName = 'Anonymous'; #fw_usrRcrd = 'Anonymous'; /if; $fw_logFWPInfo = '-updateUsingKeyVal, kv=' + #fw_actnKeyVal; fwpLog_data: -usrName = #usrName, -usrRcrd = #usrRcrd, -table = (self->'fw_modelTbl'), -rcrd = #rcrd, -action = 'add', -pageInfo = $fw_logPageInfo, -fwpInfo = $fw_logFWPInfo, -qryTime = #qryTime;
<?lassoscript
//............................................................................
//
// pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*
{fileName= fwpLog_data.ctag }
{rsrcType= tag }
{rsrcName= fwpLog_data }
{rsrcHTTP= www.pageblocks.org/refc/fwpLog_data }
{lassoVrsnMin= 8.1.0 }
{lassoVrsnMax= 8.5.3 }
{author= Greg Willits }
{authorEmail= subscribe to pbTalk at www.pageblocks.org/talk/ }
{authorHTTP= www.pageblocks.org }
{desc= Creates a log of database action events. }
{maintvsrn= 1.1.1 }
{maintrelease= 5.2.4 }
{maintdate= 2007-07-21 }
{maintauthor= Greg Willits }
{maintnotes= added tagTacer }
{maintvsrn= 1.1 }
{maintrelease= 5.2.0 }
{maintdate= 2007-06-09 }
{maintauthor= Greg Willits }
{maintnotes= added log_critical }
{maintvsrn= 1.0.1 }
{maintrelease= 5.0.0 b5 }
{maintdate= 2006-02-02 }
{maintauthor= Greg Willits }
{maintnotes= changed db/tbl references to use new vars }
{maintvsrn= 1.0 }
{maintrelease= 5.0.0 }
{maintdate= 2006-01-16 }
{maintauthor= Greg Willits }
{maintnotes= initial release }
*/
//.............................................................................
define_tag:'fwpLog_data',
-autooutput,
-priority='replace',
-optional='usrName',
-optional='usrRcrd',
-optional='table',
-optional='action',
-optional='rcrd',
-optional='pageInfo',
-optional='fwpInfo',
-optional='qryTime';
log_critical: 'logData tag called';
$fw_debug >= fw_kChatty ? $fw_tagTracer->(add:'fwpLog_data', -errorMsg=local:'errorMsg');
local:'fw_logFileNm'=($fw_sPath->'logs') + 'datalog_' + (date->year);
// backwards compatibility
// doesn`t require the declaration of fw_gLogDataTarget
if: !(global_defined:'fw_gLogDbTarget');
$fw_gLogDbTarget = 'file';
/if;
if: $fw_gLogDbTarget == 'file';
inline:
-username=$fw_gFilesUser,
-password=$fw_gFilesPswd;
select: $fw_gLogDbRoll;
case:'M';
#fw_logFileNm += '_m' + (date->month);
case:'W';
#fw_logFileNm += '_w' + (date->week);
case:'D';
#fw_logFileNm += '_d' + (date->dayofyear);
/select;
#fw_logFileNm += '.txt';
log: #fw_logFileNm;
server_date: -extended;
'\t';
server_time;
'\t';
client_IP;
'\t';
#action;
'\t';
#usrName;
'\t';
#usrRcrd;
'\t';
#table;
'\t';
#rcrd;
'\t';
response_filepath;
'\t';
#fwpInfo;
'\t';
local:'qryTime';
'\n';
/log;
$fw_criticalLog && ((file_currentError: -errorcode) != 0)
? log_critical:('pbError : fwpLog_data -- ' + error_currentError);
/inline;
else: $fw_gLogDbTarget == 'database';
local:'logPairs' = (array:
'logDate' = server_date: -extended,
'logTime' = server_time,
'logClientIP' = client_IP,
'logAction' = #action,
'logUser' = #usrName,
'logUserID' = #usrRcrd,
'logTable' = #table,
'logRcrdNo' = #rcrd,
'logPageURL' = response_filepath,
'logPageInfo' = #pageInfo,
'logFWPInfo' = #fwpInfo,
'logQryTime' = local:'qryTime'
);
fwpLog_asyncSQL:
-logPairs = #logPairs,
-user = $fw_gQueryUser,
-pswd = $fw_gQueryPswd,
-db = $fw_gDatabases->find:'logs',
-tbl = $fw_gTables->find:'logdata',
-keyfld = 'id';
/if;
/define_tag;
?>
© 2002-2013, pageblocks.org