本文整理汇总了PHP中SysLog::write方法的典型用法代码示例。如果您正苦于以下问题:PHP SysLog::write方法的具体用法?PHP SysLog::write怎么用?PHP SysLog::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SysLog
的用法示例。
在下文中一共展示了SysLog::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __extralog
private function __extralog($action = null, $description = null, $fieldsResult = null)
{
// TODO move audit to AuditsController?
// new data
$userId = $this->Auth->user('id');
$model = 'User';
$modelId = $this->Auth->user('id');
if ($action == 'login') {
$description = "User (" . $this->Auth->user('id') . "): " . $this->data['User']['email'];
} elseif ($action == 'logout') {
$description = "User (" . $this->Auth->user('id') . "): " . $this->Auth->user('email');
} elseif ($action == 'edit') {
$description = "User (" . $this->User->id . "): " . $this->data['User']['email'];
} elseif ($action == 'change_pw') {
$description = "User (" . $this->User->id . "): " . $this->data['User']['email'];
$fieldsResult = "Password changed.";
}
// query
$this->Log = ClassRegistry::init('Log');
$this->Log->create();
$this->Log->save(array('org' => $this->Auth->user('org'), 'email' => $this->Auth->user('email'), 'action' => $action, 'title' => $description, 'change' => $fieldsResult));
// write to syslogd as well
App::import('Lib', 'SysLog.SysLog');
$syslog = new SysLog();
if ($fieldsResult) {
$syslog->write('notice', $description . ' -- ' . $action . ' -- ' . $fieldsResult);
} else {
$syslog->write('notice', $description . ' -- ' . $action);
}
}
示例2: elseif
//.........这里部分代码省略.........
// UserModel is active, but the data hasnt been set. Assume system action.
$logData['Log']['description'] .= ' by System';
}
$logData['Log']['description'] .= '.';
}
if (isset($this->schema['email'])) {
// TODO Audit, LogableBehevior email
if ($this->user && $this->UserModel) {
$logData['Log']['email'] = $this->user[$this->UserModel->alias][$this->UserModel->displayField];
} else {
// UserModel is active, but the data hasnt been set. Assume system action.
$logData['Log']['email'] = 'SYS';
}
}
if (isset($this->schema['org'])) {
// TODO Audit, LogableBehevior org CHECK!!!
if ($this->user && $this->UserModel) {
$logData['Log']['org'] = $this->user[$this->UserModel->alias][$this->UserModel->orgField];
} else {
// UserModel is active, but the data hasnt been set. Assume system action.
$logData['Log']['org'] = 'SYS';
}
}
if (isset($this->schema['title'])) {
// TODO LogableBehevior title
if ($this->user && $this->UserModel) {
// $Model->data[$Model->alias][$Model->displayField]
switch ($Model->alias) {
case "User":
// TODO Audit, not used here but done in UsersController
if ($logData['Log']['action'] == 'edit' || $logData['Log']['action'] == 'delete') {
return;
// handle in model itself
}
$title = 'User (' . $Model->data[$Model->alias]['id'] . ') ' . $Model->data[$Model->alias]['email'];
break;
case "Event":
App::uses('EventsController', 'Controller');
App::build(array('Controller' => array(APP . DS . 'Controller'), 'EventsController'));
$this->Events = new EventsController();
$this->Events->constructClasses();
$title = 'Event (' . $Model->data[$Model->alias]['id'] . '): ' . $Model->data[$Model->alias]['info'];
$logData['Log']['title'] = $title;
break;
case "Attribute":
if (isset($Model->combinedKeys)) {
if (is_array($Model->combinedKeys)) {
$title = 'Attribute (' . $Model->data[$Model->alias]['id'] . ') ' . 'from Event (' . $Model->data[$Model->alias]['event_id'] . '): ' . $Model->data[$Model->alias][$Model->combinedKeys[1]] . '/' . $Model->data[$Model->alias][$Model->combinedKeys[2]] . ' ' . $Model->data[$Model->alias]['value1'];
$logData['Log']['title'] = $title;
}
}
break;
case "Server":
$this->Servers = new ServersController();
$this->Servers->constructClasses();
$title = 'Server (' . $Model->data[$Model->alias]['id'] . '): ' . $Model->data[$Model->alias]['url'];
$logData['Log']['title'] = $title;
break;
case "Role":
$this->Roles = new RolesController();
$this->Roles->constructClasses();
$title = 'Role (' . $Model->data[$Model->alias]['id'] . '): ' . $Model->data[$Model->alias]['name'];
$logData['Log']['title'] = $title;
break;
case "Whitelist":
$this->Whitelists = new WhitelistsController();
$this->Whitelists->constructClasses();
$title = 'Whitelist (' . $Model->data[$Model->alias]['id'] . '): ' . $Model->data[$Model->alias]['name'];
$logData['Log']['title'] = $title;
break;
case "Regexp":
$this->Regexp = new RegexpController();
$this->Regexp->constructClasses();
$title = 'Regexp (' . $Model->data[$Model->alias]['id'] . '): ' . $Model->data[$Model->alias]['regexp'];
$logData['Log']['title'] = $title;
break;
default:
if (isset($Model->combinedKeys)) {
if (is_array($Model->combinedKeys)) {
$title = '';
foreach ($Model->combinedKeys as $combinedKey) {
$title .= '/' . $Model->data[$Model->alias][$combinedKey];
}
$title = substr($title, 1);
$logData['Log']['title'] = $title;
}
}
}
}
}
$this->Log->create($logData);
$this->Log->save(null, array('validate' => false, 'callbacks' => false));
// write to syslogd as well
$syslog = new SysLog();
if (isset($logData['Log']['change'])) {
$syslog->write('notice', $logData['Log']['description'] . ' -- ' . $logData['Log']['change']);
} else {
$syslog->write('notice', $logData['Log']['description']);
}
}