Audit: Log messages with separate function

This commit is contained in:
Bart Visscher 2012-03-29 11:24:29 +02:00
parent 1e12db35ee
commit a2df8a4746
1 changed files with 12 additions and 9 deletions

View File

@ -3,47 +3,50 @@
class OC_Admin_Audit_Hooks_Handlers {
static public function pre_login($params) {
$path = $params['uid'];
OCP\Util::writeLog('admin_audit', 'Trying login '.$user, OCP\Util::INFO);
self::log('Trying login '.$user);
}
static public function post_login($params) {
$path = $params['uid'];
OCP\Util::writeLog('admin_audit', 'Login '.$user, OCP\Util::INFO);
self::log('Login '.$user);
}
static public function logout($params) {
$user = OCP\User::getUser();
OCP\Util::writeLog('admin_audit', 'Logout '.$user, OCP\Util::INFO);
self::log('Logout '.$user);
}
static public function rename($params) {
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
$newpath = $params[OC_Filesystem::signal_param_newpath];
$user = OCP\User::getUser();
OCP\Util::writeLog('admin_audit', 'Rename "'.$oldpath.'" to "'.$newpath.'" by '.$user, OCP\Util::INFO);
self::log('Rename "'.$oldpath.'" to "'.$newpath.'" by '.$user);
}
static public function create($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
OCP\Util::writeLog('admin_audit', 'Create "'.$path.'" by '.$user, OCP\Util::INFO);
self::log('Create "'.$path.'" by '.$user);
}
static public function copy($params) {
$oldpath = $params[OC_Filesystem::signal_param_oldpath];
$newpath = $params[OC_Filesystem::signal_param_newpath];
$user = OCP\User::getUser();
OCP\Util::writeLog('admin_audit', 'Copy "'.$oldpath.'" to "'.$newpath.'" by '.$user, OCP\Util::INFO);
self::log('Copy "'.$oldpath.'" to "'.$newpath.'" by '.$user);
}
static public function write($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
OCP\Util::writeLog('admin_audit', 'Write "'.$path.'" by '.$user, OCP\Util::INFO);
self::log('Write "'.$path.'" by '.$user);
}
static public function read($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
OCP\Util::writeLog('admin_audit', 'Read "'.$path.'" by '.$user, OCP\Util::INFO);
self::log('Read "'.$path.'" by '.$user);
}
static public function delete($params) {
$path = $params[OC_Filesystem::signal_param_path];
$user = OCP\User::getUser();
OCP\Util::writeLog('admin_audit', 'Delete "'.$path.'" by '.$user, OCP\Util::INFO);
self::log('Delete "'.$path.'" by '.$user);
}
static protected function log($msg) {
OCP\Util::writeLog('admin_audit', $msg, OCP\Util::INFO);
}
}