Ejemplo n.º 1
0
 /**
  * @return      LoggerInterface
  */
 public function getLogger()
 {
     $logHandler = new NullHandler();
     $loggerObject = new Logger();
     $loggerObject->addHandler($logHandler);
     return $loggerObject;
 }
Ejemplo n.º 2
0
 /**
  * @return      void
  */
 public function initLogger()
 {
     $this->logHandler = new LogHandler();
     $loggerObject = new Logger();
     $loggerObject->addHandler($this->logHandler);
     LoggerManager::init($loggerObject);
 }
Ejemplo n.º 3
0
 /**
  * @return      LoggerInterface
  */
 public function getLogger()
 {
     $logPath = __DIR__ . '/log/test2.log';
     $this->logHandler = new StdHandler($logPath);
     $loggerObject = new Logger();
     $loggerObject->addHandler($this->logHandler);
     return $loggerObject;
 }
Ejemplo n.º 4
0
<?php

$logPath = __DIR__ . '/log/test2.log';
use Naucon\Logger\Logger;
use Naucon\Logger\LoggerManager;
use Naucon\Logger\Handler\LogHandler;
$logHandler = new LogHandler($logPath);
$loggerObject = new Logger();
$loggerObject->addHandler($logHandler);
LoggerManager::init($loggerObject);
LoggerManager::emergency('message of level emergency');
LoggerManager::alert('message of level alert');
LoggerManager::critical('message of level critical');
LoggerManager::alert('message of level alert');
LoggerManager::error('message of level error');
LoggerManager::warning('message of level warning');
LoggerManager::notice('message of level notice');
LoggerManager::info('message of level info');
LoggerManager::debug('message of level debug');
LoggerManager::critical(new \Exception('invalid foo'));
// with context
LoggerManager::emergency('message of level emergency with context: {user}', array('user' => 'Bob'));
LoggerManager::alert('message of level alert with context: {user}', array('user' => 'Bob'));
LoggerManager::critical('message of level critical with context: {user}', array('user' => 'Bob'));
LoggerManager::alert('message of level alert with context: {user}', array('user' => 'Bob'));
LoggerManager::error('message of level error with context: {user}', array('user' => 'Bob'));
LoggerManager::warning('message of level warning with context: {user}', array('user' => 'Bob'));
LoggerManager::notice('message of level notice with context: {user}', array('user' => 'Bob'));
LoggerManager::info('message of level info with context: {user}', array('user' => 'Bob'));
LoggerManager::debug('message of level debug with context: {user}', array('user' => 'Bob'));
$exception = new \Exception('invalid foo');
Ejemplo n.º 5
0
<?php

use Naucon\Logger\Logger;
$loggerObject = new Logger();
$loggerObject->addHandler(new Gelf\Logger());
$loggerObject->emergency('message of level emergency');
$loggerObject->emergency('message of level emergency');
$loggerObject->alert('message of level alert');
$loggerObject->critical('message of level critical');
$loggerObject->alert('message of level alert');
$loggerObject->error('message of level error');
$loggerObject->warning('message of level warning');
$loggerObject->notice('message of level notice');
$loggerObject->info('message of level info');
$loggerObject->debug('message of level debug');
$loggerObject->critical(new \Exception('invalid foo'));
// with context
$loggerObject->emergency('message of level emergency with context: {user}', array('user' => 'Bob'));
$loggerObject->alert('message of level alert with context: {user}', array('user' => 'Bob'));
$loggerObject->critical('message of level critical with context: {user}', array('user' => 'Bob'));
$loggerObject->alert('message of level alert with context: {user}', array('user' => 'Bob'));
$loggerObject->error('message of level error with context: {user}', array('user' => 'Bob'));
$loggerObject->warning('message of level warning with context: {user}', array('user' => 'Bob'));
$loggerObject->notice('message of level notice with context: {user}', array('user' => 'Bob'));
$loggerObject->info('message of level info with context: {user}', array('user' => 'Bob'));
$loggerObject->debug('message of level debug with context: {user}', array('user' => 'Bob'));
$exception = new \Exception('invalid foo');
$loggerObject->error($exception->getMessage(), array('exception' => $exception));