function createLog($row)
{
    $log = new Log();
    $log->name = 'Developer.' . $row['category'];
    $log->enable_logging = true;
    if (CMSLog::RuntimeErrors == $row['category']) {
        $log->critical = true;
    }
    $log->insert();
    return $log;
}
Beispiel #2
0
 public static function createIfNotExists($name)
 {
     try {
         $result = self::getByName($name);
     } catch (\NotFoundException $e) {
         $result = new Log();
         $result->name->setValue($name);
         $result->insert();
         $result->setupLogging(true);
     }
     return $result;
 }
Beispiel #3
0
 public function testSetupLogging()
 {
     $api = new EditLog(array('name' => 'Log1', 'enable_logging' => 0));
     $api->exec();
     $log = new Log();
     $log->get(1);
     $this->assertEquals(0, $log->enable_logging->getValue());
     $api = new EditLog(array('name' => 'Log1', 'enable_logging' => 1));
     $api->exec();
     //
     $log = new Log();
     $log->get(1);
     $this->assertEquals(1, $log->enable_logging->getValue());
 }
Beispiel #4
0
 protected function action()
 {
     // event should exists
     Log::getByName($this->GetParam('event'));
     Record::add($this->GetParam('event'), $this->GetParam('short'), $this->GetParam('full'));
     return true;
 }
Beispiel #5
0
 protected function action()
 {
     $log = Log::getByName($this->getParam('name'));
     $log->critical->setValue(intval($this->getParam('priority')));
     $log->update();
     \CMSLog::addMessage(__CLASS__, sprintf('Log "%s" priority changed to - "%d"', $this->getParam('name'), $this->getParam('priority')));
     return true;
 }
Beispiel #6
0
 protected function action()
 {
     $log = Log::getByName($this->getParam('name'));
     $log->obj_enable_logging->setValue(intval($this->getParam('enable_logging')));
     $log->update();
     \CMSLog::addMessage(__CLASS__, sprintf('Log `%s` logging updated. Logging set to - "%d" ', $this->getParam('name'), $this->getParam('enable_logging')));
     return true;
 }
Beispiel #7
0
 protected function action()
 {
     $data = Log::selectAll();
     $result = array();
     foreach ($data as $row) {
         $result[] = array('name' => $row->name->getViewValue(), 'description' => $row->description->getViewValue(), 'critical' => $row->critical->getValue(), 'enable_logging' => $row->enable_logging->getValue());
     }
     return $result;
 }
Beispiel #8
0
 protected function sendEmailNotification()
 {
     try {
         $config = CConfig::getSchema(self::CriticalEmailSchemaName);
         $values = $config->getValues();
         $parseData = array('record' => $this->getParseData(), 'log' => $this->log->getParseData());
         Email_Controller::parseAndSend($values['to'], $values['subject'], $values['content'], $parseData);
     } catch (\Exception $e) {
     }
 }
Beispiel #9
0
 public function testSetValue()
 {
     $api = new SetupPriority();
     $api->setParamsData(array('name' => 'Log1', 'priority' => 1));
     //
     $api->exec();
     //
     $log = Log::getByName('Log1');
     $this->assertEquals(true, $log->critical->getValue());
 }
Beispiel #10
0
 public function testRecordNotAddedInEnableLoggingDisabled()
 {
     $initial = DBSimple::getRowsCount(Record::tableName);
     //
     $log = Log::getByName('Log1');
     $log->setupLogging(false);
     //
     $result = Record::add('Log1', '1', '2');
     $this->assertTrue(empty($result));
     //
     $result = DBSimple::getRowsCount(Record::tableName);
     $this->AssertEquals($initial, $result);
 }
Beispiel #11
0
try {
    $register->delete('Audit');
} catch (\Exception $e) {
}
Restorator::restore();
\SystemRegisterSample::createCache();
TestsHelper::dbFixture(ACL_TABLE, array());
ACL::create(ApiOperation::RightName);
// user record
TestsHelper::dbFixture(USERS_TABLE, array(array('login' => 'login', 'password' => passwordColumn::hash('testtest')), array('login' => 'guest', 'password' => passwordColumn::hash('testtest'))));
// grant user permission
$user = UserAccount::getByLogin('login');
ACL::grant(ApiOperation::RightName, $user->obj_rights->getEntity());
\UsersLogin::login('login', 'testtest');
// base logs
TestsHelper::dbFixture(Log::getTableName(), array(array('name' => 'Log1', 'critical' => 0, 'enable_logging' => 1), array('name' => 'Log2', 'critical' => 1, 'enable_logging' => 1)));
// base records
// - [different by user_id]
// - [different by date]
// - [different by content]
TestsHelper::dbFixture(Record::getTableName(), array(array('log_id' => 1, 'date' => '2001-01-01 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 2, 'date' => '2001-01-02 00:00:00', 'short' => 'short log', 'full' => 'full_log', 'user_id' => 1, 'user_login' => 'login'), array('log_id' => 1, 'date' => '2001-01-03 00:00:00', 'short' => 'short log', 'full' => 'full_log')));
// Create custom config if it exists
$schemaName = 'Audit.CriticalEventName';
try {
    $config = \CConfig::getSchema($schemaName);
    $config->delete();
} catch (\Exception $e) {
} finally {
    $config = \CConfig::createSchema($schemaName);
    $config->addControl('to', 'inputfield', 'Получатели письма', array(), '*****@*****.**');
    $config->addControl('subject', 'inputfield', 'Тема письма', array(), 'Email Subject');
Beispiel #12
0
 public function testSetupLogging()
 {
     $log = Log::getById(1);
     $log->setupLogging(1);
     $this->assertEquals(true, $log->enable_logging->getValue());
 }