Changeset 687 for branches/1.1dev/lib


Ignore:
Timestamp:
May 29, 2019 12:56:07 AM (5 years ago)
Author:
anonymous
Message:

Add ignore_repeated_events to logMsg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.1dev/lib/App.inc.php

    r633 r687  
    8181{
    8282    global $CFG;
     83    static $previous_events = array();
    8384
    8485    // If priority is not specified, assume the worst.
     
    106107    // Serialize multi-line messages.
    107108    $message = preg_replace('/\s+/m', ' ', trim($message));
     109
     110    // Store this event under a unique key, counting each time it occurs so that it only gets reported a limited number of times.
     111    $msg_id = md5($message . $priority . $file . $line);
     112    if ($this->getParam('log_ignore_repeated_events') && isset($previous_events[$msg_id])) {
     113        $previous_events[$msg_id]++;
     114        if ($previous_events[$msg_id] == 2) {
     115            logMsg(sprintf('%s (Event repeated %s or more times)', $message, $previous_events[$msg_id]), $priority, $file, $line);
     116        }
     117        return false;
     118    } else {
     119        $previous_events[$msg_id] = 1;
     120    }
     121
     122    // Make sure to log in the system's locale.
     123    $locale = setlocale(LC_TIME, 0);
     124    setlocale(LC_TIME, 'C');
    108125
    109126    // Data to be stored for a log event.
     
    120137    $event_short = $event;
    121138    $event_short['url'] = truncate($event_short['url'], 120);
     139
     140    // Restore original locale.
     141    setlocale(LC_TIME, $locale);
    122142
    123143    // FILE ACTION
Note: See TracChangeset for help on using the changeset viewer.