Beispiel #1
0
 public function getLog()
 {
     if (!$this->_log instanceof Box_Log) {
         $log = new Box_Log();
         $log->addWriter(new Box_LogDb('Model_ActivitySystem'));
         return $log;
     }
     return $this->_log;
 }
Beispiel #2
0
 public function testLog()
 {
     $service_mock = $this->getMockBuilder('Box\\Mod\\Activity\\Service')->getMock();
     $service_mock->expects($this->atLeastOnce())->method('logEvent')->will($this->returnValue(true));
     $writer1 = new Box_LogDb($service_mock);
     $writer2 = new Box_LogStream('php://output');
     $writer3 = new Box_LogStream(BB_PATH_LOG . '/test.log');
     $log = new Box_Log();
     $log->addWriter($writer1);
     $log->addWriter($writer2);
     $log->addWriter($writer3);
     $log->err('Test', array('admin_id' => 1, 'client_id' => 2));
     $log->err('Test 2', array('admin_id' => 3, 'client_id' => 4));
     $date = date('Y-m-d H:i:s');
     $outputString = $date . " ERR (3): Test" . PHP_EOL;
     $outputString .= $date . " ERR (3): Test 2" . PHP_EOL;
     $this->expectOutputString($outputString);
 }
Beispiel #3
0
 * @copyright BoxBilling, Inc (http://www.boxbilling.com)
 * @license   Apache-2.0
 *
 * Copyright BoxBilling, Inc
 * This source file is subject to the Apache-2.0 License that is bundled
 * with this source code in the file LICENSE
 */
$di = new Box_Di();
$di['config'] = function () {
    $array = (include BB_PATH_ROOT . '/bb-config.php');
    return new Box_Config($array);
};
$di['logger'] = function () use($di) {
    $logFile = $di['config']['path_logs'];
    $writer = new Box_LogStream($logFile);
    $log = new Box_Log();
    $log->addWriter($writer);
    $log_to_db = isset($di['config']['log_to_db']) && $di['config']['log_to_db'];
    if ($log_to_db) {
        $activity_service = $di['mod_service']('activity');
        $writer2 = new Box_LogDb($activity_service);
        if ($di['auth']->isAdminLoggedIn()) {
            $admin = $di['loggedin_admin'];
            $log->setEventItem('admin_id', $admin->id);
        } elseif ($di['auth']->isClientLoggedIn()) {
            $client = $di['loggedin_client'];
            $log->setEventItem('client_id', $client->id);
        }
        $log->addWriter($writer2);
    }
    return $log;