mirror of https://github.com/MISP/MISP
chg: [syslog] Remove duplicate date and log type from log
parent
4ff7cccc7a
commit
8636c1f903
|
@ -272,7 +272,7 @@ class AuditLog extends AppModel
|
|||
if ($title) {
|
||||
$entry .= " -- $title";
|
||||
}
|
||||
$this->syslog->write('info', $entry);
|
||||
$this->syslog->write(LOG_INFO, $entry);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -383,13 +383,13 @@ class Log extends AppModel
|
|||
}
|
||||
}
|
||||
if ($this->syslog) {
|
||||
$action = 'info';
|
||||
$action = LOG_INFO;
|
||||
if (isset($data['Log']['action'])) {
|
||||
if (in_array($data['Log']['action'], self::ERROR_ACTIONS, true)) {
|
||||
$action = 'err';
|
||||
$action = LOG_ERR;
|
||||
}
|
||||
if (in_array($data['Log']['action'], self::WARNING_ACTIONS, true)) {
|
||||
$action = 'warning';
|
||||
$action = LOG_WARNING;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1223,13 +1223,12 @@ class User extends AppModel
|
|||
}
|
||||
|
||||
// query
|
||||
$this->Log = ClassRegistry::init('Log');
|
||||
$result = $this->Log->createLogEntry($user, $action, $model, $modelId, $description, $fieldsResult);
|
||||
$result = $this->loadLog()->createLogEntry($user, $action, $model, $modelId, $description, $fieldsResult);
|
||||
|
||||
// write to syslogd as well
|
||||
App::import('Lib', 'SysLog.SysLog');
|
||||
$syslog = new SysLog();
|
||||
$syslog->write('notice', "$description -- $action" . (empty($fieldsResult) ? '' : ' -- ' . $result['Log']['change']));
|
||||
$syslog->write(LOG_NOTICE, "$description -- $action" . (empty($fieldsResult) ? '' : ' -- ' . $result['Log']['change']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,9 +38,9 @@ class SysLog
|
|||
* @param array $options Options for the SysLog, see above.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
public function __construct($options = [])
|
||||
{
|
||||
$options += array('ident' => LOGS, 'facility' => LOG_LOCAL0, 'to_stderr' => true);
|
||||
$options += ['ident' => LOGS, 'facility' => LOG_LOCAL0, 'to_stderr' => true];
|
||||
$option = LOG_PID; // include PID with each message
|
||||
if ($options['to_stderr']) {
|
||||
$option |= LOG_PERROR; // print log message also to standard error
|
||||
|
@ -51,7 +51,7 @@ class SysLog
|
|||
/**
|
||||
* Implements writing to the specified syslog
|
||||
*
|
||||
* @param string $type The type of log you are making.
|
||||
* @param int $type The type of log you are making.
|
||||
* @param string $message The message you want to log.
|
||||
* @return boolean success of write.
|
||||
*/
|
||||
|
@ -60,14 +60,9 @@ class SysLog
|
|||
if (!$this->_log) {
|
||||
return false;
|
||||
}
|
||||
$debugTypes = array('notice', 'info', 'debug');
|
||||
$priority = LOG_INFO;
|
||||
if ($type == 'error' || $type == 'warning') {
|
||||
$priority = LOG_ERR;
|
||||
} else if (in_array($type, $debugTypes)) {
|
||||
$priority = LOG_DEBUG;
|
||||
if (!is_int($type)) {
|
||||
throw new InvalidArgumentException("Invalid log type `$type`, must be one of LOG_* constant.");
|
||||
}
|
||||
$output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message;
|
||||
return syslog($priority, $output);
|
||||
return syslog($type, $message);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue