logEvent
Last edited by Kari Söderholm on Jan 26, 2015.
API:logEvent
API Quick reference
Variable name: | logEvent |
Modx versions: | 0.9.x + Evolution |
Variable type: | void |
Object parent: | DocumentParser |
Description
void logEvent(int $evtid, int $type, string $msg [, $source= 'Parser']);
- $evtid - Event ID
- $type - Types: 1 = information, 2 = warning, 3 = error
- $msg - Message to be logged. May contain HTML.
- $source - source of the event (module, snippet name, etc.). Currently limited to max 50 characters by database field length.
Add an a alert message to the system event log.
Usage / Examples
$modx->logEvent($my_msg_cnt, 3, 'There was an error!', 'MySnippet');
Related
Notes
Compared to other systems, it is a bit odd that the error levels are numbered the way they are.
Function Source
Function source in MODX version 1.0.15
API Source File | manager/includes/document.parser.class.inc.php | 1782
/** * Add an a alert message to the system event log * * @param int $evtid Event ID * @param int $type Types: 1 = information, 2 = warning, 3 = error * @param string $msg Message to be logged * @param string $source source of the event (module, snippet name, etc.) * Default: Parser */ function logEvent($evtid, $type, $msg, $source= 'Parser') { $msg= $this->db->escape($msg); if ($GLOBALS['database_connection_charset'] == 'utf8' && extension_loaded('mbstring')) { $esc_source = mb_substr($source, 0, 50 , "UTF-8"); } else { $esc_source = substr($source, 0, 50); } $esc_source= $this->db->escape($esc_source); $LoginUserID = $this->getLoginUserID(); if ($LoginUserID == '') $LoginUserID = 0; $evtid= intval($evtid); $type = intval($type); if ($type < 1) $type= 1; // Types: 1 = information, 2 = warning, 3 = error if (3 < $type) $type= 3; $this->db->insert( array( 'eventid' => $evtid, 'type' => $type, 'createdon' => time() + $this->config['server_offset_time'], 'source' => $esc_source, 'description' => $msg, 'user' => $LoginUserID, ), $this->getFullTableName('event_log')); if (isset($this->config['send_errormail']) && $this->config['send_errormail'] !== '0') { if ($this->config['send_errormail'] <= $type) { $this->sendmail(array( 'subject' => 'MODX System Error on ' . $this->config['site_name'], 'body' => 'Source: ' . $source . ' - The details of the error could be seen in the MODX system events log.', 'type' => 'text') ); } } }
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).