当前位置: 首页>>代码示例>>PHP>>正文


PHP Logger::log方法代码示例

本文整理汇总了PHP中Zend\Log\Logger::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::log方法的具体用法?PHP Logger::log怎么用?PHP Logger::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Log\Logger的用法示例。


在下文中一共展示了Logger::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: log

 protected function log($priority, $message)
 {
     if ($this->logger !== null) {
         $this->logger->log($priority, $message);
     }
     return $this;
 }
开发者ID:jaaksarv,项目名称:id-services,代码行数:7,代码来源:AbstractService.php

示例2: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $logContent = '';
     // initialize when no submit anymore
     $data = [];
     $data['logmessage'] = $this->form->get('logmessage')->getValue();
     if ($request->isPost()) {
         $this->form->setData($request->getPost());
         if ($this->form->isValid()) {
             $data = $this->form->getData();
             $this->loggerPriority = $data['logpriority'];
             if ($data['logformat'] !== 'simple') {
                 $this->loggerConfig['writers'][0]['options']['formatter']['name'] = $data['logformat'];
                 unset($this->loggerConfig['writers'][0]['options']['formatter']['options']);
             }
         }
     }
     $logger = new Logger($this->loggerConfig);
     // save log data to buffer and make it variable
     ob_start();
     $logger->log((int) $this->loggerPriority, $data['logmessage']);
     $logContent = ob_get_clean();
     return new ViewModel(['form' => $this->form, 'logContent' => $logContent]);
 }
开发者ID:shitikovkirill,项目名称:LearnZF2,代码行数:25,代码来源:IndexController.php

示例3: logInfo

 public function logInfo($message)
 {
     $log = new Logger();
     $writer = new Stream('pronoi.log');
     $log->addWriter($writer);
     $log->log(Logger::INFO, $message);
 }
开发者ID:ingzepe,项目名称:ProNoi,代码行数:7,代码来源:EmpleadoController.php

示例4: log

 public function log($message, $priority, $extras = null, $displayScreen = false)
 {
     if ($displayScreen) {
         echo $message . PHP_EOL;
     }
     parent::log($message, $priority, $extras);
 }
开发者ID:niconoe-,项目名称:core-log,代码行数:7,代码来源:Log.php

示例5: logTirage

 public function logTirage($randomize)
 {
     $path = __DIR__ . '/../../../../../data/log/log_tirage.php';
     $logger = new Logger();
     $writer = new Stream($path);
     $logger->addWriter($writer);
     $logger->log(Logger::INFO, $randomize);
 }
开发者ID:sgourier,项目名称:projet-zend,代码行数:8,代码来源:NumbersGameController.php

示例6: testZf3960

 /**
  * Test for ZF-3960
  *
  * Zend_Log_Writer_Firebug should be automatically disabled when
  * run from the command line
  */
 public function testZf3960()
 {
     Channel\HttpHeaders::destroyInstance();
     FirePhp::destroyInstance();
     $log = new Logger();
     $writerFirebug = new FirebugWriter();
     $log->addWriter($writerFirebug);
     $log->log('hi', 2);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:15,代码来源:FirebugTest.php

示例7: log

 public function log($priority, $message, $extra = array(), $context = false)
 {
     // Prepend the context
     if ($context === true) {
         $context = $this->parseContext();
     }
     $message = empty($context) ? $message : $context . ' : ' . $message;
     // Log the message
     parent::log($priority, $message, $extra);
 }
开发者ID:anukat2015,项目名称:xmlps,代码行数:10,代码来源:Logger.php

示例8: log

 public function log($priority, $message, $extra = array())
 {
     // add details to $extra
     $trace = debug_backtrace();
     $caller = $trace[1];
     $prevCaller = $trace[2];
     // simplify $caller
     unset($caller['object'], $caller['type'], $caller['args']);
     // overriding function and class from $prevCaller
     $caller['function'] = $prevCaller['function'];
     $caller['class'] = $prevCaller['class'];
     $extra = array_merge($extra, $caller);
     if (is_string($message)) {
         $message = str_replace('<', '--bigger than--', $message);
     }
     return parent::log($priority, $message, $extra);
 }
开发者ID:pkamps,项目名称:basexms,代码行数:17,代码来源:Logger.php

示例9: registerExceptionHandler

 /**
  * Registers an exception handler.
  *
  * @param Logger $logger
  *
  * @return bool Returna always false to enable other handlers, including the default
  *
  * @throws Exception\InvalidArgumentException if logger is null
  */
 public static function registerExceptionHandler(Logger $logger)
 {
     // Only register once per instance
     if (self::$registeredExceptionHandler) {
         return false;
     }
     if ($logger === null) {
         throw new \Zend\Log\Exception\InvalidArgumentException('Invalid Logger specified');
     }
     set_exception_handler(function (\Exception $exception) use($logger) {
         $msg = '';
         $prev = $exception->getPrevious();
         while ($prev !== null) {
             $msg .= PHP_EOL . 'Previous: ' . $prev->getMessage() . ' in ' . $prev->getFile() . ' in line ' . $prev->getLine() . '.';
             $prev = $prev->getPrevious();
         }
         $logger->log(ErrorLogger::ERR, 'Exception: ' . $exception->getMessage() . ' in ' . $exception->getFile() . ' in line ' . $exception->getLine() . '.' . $msg . PHP_EOL . 'Trace:' . PHP_EOL . $exception->getTraceAsString());
     });
     self::$registeredExceptionHandler = true;
     return false;
 }
开发者ID:lafaiDev,项目名称:suive_com,代码行数:30,代码来源:ErrorLogger.php

示例10: debug

 public function debug($message)
 {
     return parent::log($message, 7);
 }
开发者ID:bill97420,项目名称:symfony,代码行数:4,代码来源:Logger.php

示例11: SplPriorityQueue

$processor = PROCESSOR_PDFTK;
// Number of documents (populated with random strings) to concatenate.
$iterations = 3;
// -----------------------------------------------------------------------------
// Logger to output status messages
$writerQueue = new SplPriorityQueue();
$writerQueue->insert(new Writer('php://stdout'), 1);
$logger = new Logger();
$logger->setWriters($writerQueue);
// -----------------------------------------------------------------------------
// Create temporary directory
$tempDirectory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(rand(1, 10000) . __FILE__);
if (is_dir($tempDirectory)) {
    recursiveRemoveDirectory($tempDirectory);
}
$logger->log(Logger::INFO, sprintf('Making temporary directory %s.', $tempDirectory));
mkdir($tempDirectory);
// -----------------------------------------------------------------------------
// Generate temporary documents
$tempFilenames = array();
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_PASSWORD)->setService(MailMerge::SERVICE_FREE);
// for LiveDocx Premium, use MailMerge::SERVICE_PREMIUM;
$mailMerge->setLocalTemplate('template.docx');
for ($iteration = 1; $iteration <= $iterations; $iteration++) {
    $tempFilename = sprintf('%s%s%010s.pdf', $tempDirectory, DIRECTORY_SEPARATOR, $iteration);
    $tempFilenames[] = $tempFilename;
    $mailMerge->assign('software', randomString())->assign('licensee', randomString())->assign('company', randomString())->assign('date', Helper::currentDate())->assign('time', Helper::currentTime())->assign('city', randomString())->assign('country', randomString());
    $mailMerge->createDocument();
    file_put_contents($tempFilename, $mailMerge->retrieveDocument('pdf'));
    $logger->log(Logger::INFO, sprintf('Generating temporary document %s.', $tempFilename));
开发者ID:2UP,项目名称:podio-doc-to-pdf,代码行数:31,代码来源:generate-document-concat.php

示例12: log

 /**
  * 
  * @param EventInterface $event
  */
 public function log(EventInterface $event)
 {
     $message = $event->getParam('message', 'No message provided');
     $priority = $event->getParam('priority', Logger::INFO);
     $this->logger->log($priority, $message);
 }
开发者ID:cyawman,项目名称:event-logger,代码行数:10,代码来源:AppListener.php

示例13: onEvent

 public function onEvent(EventInterface $event)
 {
     if ($event instanceof LogEvent) {
         $this->logger->log($event->getPriority(), $event->getMessage(), $event->getParams());
     }
 }
开发者ID:alex-oleshkevich,项目名称:zf-extras,代码行数:6,代码来源:LogEventListener.php

示例14: log

 /**
  * @param int   $priority
  * @param mixed $message
  * @param array $extra
  *
  * @return ZendLogger
  */
 public final function log($priority, $message, $extra = array())
 {
     $customExtra = array('Zf2Logger' => array('sessionId' => session_id(), 'host' => !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'CLI', 'ip' => !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unavailable'));
     return parent::log($priority, $message, array_merge($extra, $customExtra, $this->customExtra));
 }
开发者ID:eddiejaoude,项目名称:zf2-logger,代码行数:12,代码来源:Logger.php

示例15: testPriorityDuplicates

 /**
  * @group ZF-10170
  */
 public function testPriorityDuplicates()
 {
     $logger = new Logger();
     $mock = new Log\Writer\Mock();
     $logger->addWriter($mock);
     try {
         $logger->addPriority('emerg', 8);
         $this->fail();
     } catch (\Exception $e) {
         $this->assertType('Zend\\Log\\Exception', $e);
         $this->assertEquals('Existing priorities cannot be overwritten', $e->getMessage());
     }
     try {
         $logger->log('zf10170', 0);
         $logger->log('clone zf10170', 8);
         $this->fail();
     } catch (\Exception $e) {
         $this->assertType('Zend\\Log\\Exception', $e);
         $this->assertEquals('Bad log priority', $e->getMessage());
     }
     $this->assertEquals(0, $mock->events[0]['priority']);
     $this->assertEquals('EMERG', $mock->events[0]['priorityName']);
     $this->assertFalse(array_key_exists(1, $mock->events));
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:27,代码来源:LoggerTest.php


注:本文中的Zend\Log\Logger::log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。