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


PHP Logger::addRecord方法代码示例

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


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

示例1: doLog

 public static function doLog($logmethod, array $data, &$output)
 {
     $log = new Logger('ezperflogger');
     // constructor args for the specific handler can be set via ini
     /// @todo how to create resources instead?
     foreach (eZPerfLoggerINI::variable('MonologSettings', 'LogHandlers') as $handlerName) {
         $handlerClass = 'Monolog\\Handler\\' . $handlerName . "Handler";
         if (eZPerfLoggerINI::hasVariable('MonologSettings', 'LogHandler_' . $handlerName)) {
             $r = new ReflectionClass($handlerClass);
             $handler = $r->newInstanceArgs(eZPerfLoggerINI::variable('MonologSettings', 'LogHandler_' . $handlerName));
         } else {
             $handler = new $handlerClass();
         }
         $log->pushHandler($handler);
     }
     // the default severity level: taken from config file
     $level = (int) eZPerfLoggerINI::variable('MonologSettings', 'SeverityLevel');
     // either coalesce messages or not: taken from config file
     if (eZPerfLoggerINI::variable('MonologSettings', 'Coalescevariables') == 'enabled') {
         /// @todo allow via ini file the specification of custom formatters?
         $msg = array();
         foreach ($data as $varname => $value) {
             $msg[] = "{$varname}: {$value}";
         }
         $log->addRecord($level, implode(', ', $msg));
     } else {
         foreach ($data as $varname => $value) {
             $log->addRecord($level, "{$varname}: {$value}");
         }
     }
 }
开发者ID:gggeek,项目名称:ezperformancelogger,代码行数:31,代码来源:ezperfloggermonologlogger.php

示例2: log

 /**
  * {@inheritdoc}
  */
 public function log($message, $priority = LOG_INFO)
 {
     if (!isset(self::$mapping[$priority])) {
         throw new \InvalidArgumentException('Invalid priority ' . $priority);
     }
     $this->logger->addRecord(self::$mapping[$priority], $message);
 }
开发者ID:phpi,项目名称:log,代码行数:10,代码来源:MonologLogAdapter.php

示例3: write

 /**
  * Write to log
  *
  * @param string $message
  * @param int    $level
  * @param array  $context
  *
  * @return void
  */
 public function write($level, $message, array $context = array())
 {
     if (!$this->resource) {
         // create a log channel
         $this->makeResource();
     }
     // Don't bother typesetting $message, Monolog will do this for us
     $this->resource->addRecord($this->getLogLevel($level, Logger::WARNING), $message, $context);
 }
开发者ID:krisanalfa,项目名称:b-comp,代码行数:18,代码来源:LogWriter.php

示例4: log

 public function log($message, $priority = self::INFO)
 {
     $context = ['at' => Helpers::getSource()];
     if ($message instanceof Throwable) {
         $context['exception'] = $message;
         $message = '';
     }
     $this->monolog->addRecord(self::PRIORITY_MAP[$priority] ?? Monolog\Logger::ERROR, $message, $context);
 }
开发者ID:nextras,项目名称:tracy-monolog-adapter,代码行数:9,代码来源:Logger.php

示例5: log

 /**
  * @param string $message
  * @param int $priority Priority is ignored, since its value is extracted from the response
  * @param null $extras
  */
 public function log($message, $priority = LOG_INFO, $extras = null)
 {
     /** @var Response $response */
     $response = $extras['response'];
     $priority = $this->getPriorityFromResponse($response);
     $context = $this->getContextFromResponse($response);
     $context['event'] = 'request.complete';
     $this->log->addRecord($priority, $message, $context);
     if ($response->isError()) {
         /** @var Request $request */
         $request = $extras['request'];
         $context['event'] = 'request.error';
         $this->log->addRecord($response->isClientError() ? Logger::WARNING : Logger::ERROR, sprintf('Request failed with code %s: %s %s', $response->getStatusCode(), $request->getMethod(), $request->getUrl()), $context);
     }
 }
开发者ID:robertpisano,项目名称:LeeLee,代码行数:20,代码来源:MonologGuzzleLogAdapter.php

示例6: addRecord

 /**
  * Adds a log record.
  *
  * @param  integer $level   The logging level
  * @param  string  $message The log message
  * @param  array   $context The log context
  * @return Boolean Whether the record has been processed
  */
 public function addRecord($level, $message, array $context = array())
 {
     if ($message instanceof \Exception) {
         $message = MutedException::encapsulate($message);
     }
     return parent::addRecord($level, $message, $context);
 }
开发者ID:tmountjr,项目名称:muted-log,代码行数:15,代码来源:MutedLogger.php

示例7: handleError

 /**
  * Handle PHP error
  * Takes input from PHPs built in error handler logs it
  * throws a jazzee exception to handle if the error reporting level is high enough
  * @param $code
  * @param $message
  * @param $file
  * @param $line
  * @throws \Jazzee\Exception
  */
 public function handleError($code, $message, $file, $line)
 {
     /* Map the PHP error to a Log priority. */
     switch ($code) {
         case E_WARNING:
         case E_USER_WARNING:
             $priority = \Monolog\Logger::WARNING;
             break;
         case E_NOTICE:
         case E_USER_NOTICE:
             $priority = \Monolog\Logger::INFO;
             break;
         case E_ERROR:
         case E_USER_ERROR:
             $priority = \Monolog\Logger::ERROR;
             break;
         default:
             $priority = \Monolog\Logger::INFO;
     }
     // Error reporting is currently turned off or suppressed with @
     if (error_reporting() === 0) {
         $this->_log->debug('Supressed error: ' . $message . ' in ' . $file . ' at line ' . $line);
         return false;
     }
     $this->_log->addRecord($priority, $message . ' in ' . $file . ' at line ' . $line);
     throw new \Exception('Jazzee caught a PHP error: ' . $message . ' in ' . $file . ' at line ' . $line);
 }
开发者ID:Jazzee,项目名称:Jazzee,代码行数:37,代码来源:JazzeePageController.php

示例8: log

 /**
  * {@InheritDoc}
  */
 public static function log($message, $level = Logger::INFO, $context = array())
 {
     static $_firstRun = true;
     if ($_firstRun || !static::$_logFileValid) {
         static::_checkLogFile();
         $_firstRun = false;
     }
     //	Get the indent, if any
     $_unindent = ($_newIndent = static::_processMessage($message)) > 0;
     //	Indent...
     if (0 > ($_tempIndent = static::$_currentIndent - ($_unindent ? 1 : 0))) {
         $_tempIndent = 0;
     }
     $_message = str_repeat('  ', $_tempIndent) . $message;
     if (!is_numeric($level)) {
         $level = LoggingLevels::toNumeric($level);
     }
     if (static::$_logger) {
         static::$_logger->addRecord($level, $_message, !is_array($context) ? array() : $context);
     } elseif (static::$_fallbackLogger) {
         static::$_fallbackLogger->addRecord($level, $_message, $context);
     }
     //	Set indent level...
     static::$_currentIndent += $_newIndent;
     //	Anything over a warning returns false so you can chain
     return Logger::WARNING > $level;
 }
开发者ID:kisma,项目名称:kisma,代码行数:30,代码来源:Log.php

示例9: log

 /**
  * {@inheritDoc}
  */
 public function log($level, $message, array $context = [])
 {
     if (!$this->options['logging_enabled']) {
         return false;
     }
     // Add the queue name and provider to the context
     $context = array_merge(['queue' => $this->name, 'provider' => $this->getProvider()], $context);
     return $this->logger->addRecord($level, $message, $context);
 }
开发者ID:uecode,项目名称:qpush-bundle,代码行数:12,代码来源:AbstractProvider.php

示例10: addRecord

 /**
  * @see Monolog\Logger::addRecord()
  */
 public function addRecord($level, $message, array $context = array())
 {
     // 配列のメッセージに対応させる
     if (!is_array($message)) {
         $message = array($message);
     }
     foreach ($message as $_message) {
         parent::addRecord($level, $_message, $context);
     }
 }
开发者ID:iwatea,项目名称:Swim,代码行数:13,代码来源:CLogger.php

示例11: export

 /**
  * Writes log messages to a LogEntriesHandler Monolog handler.
  */
 public function export()
 {
     $monolog = new Logger('Logentries');
     $monolog->pushHandler(new LogEntriesHandler($this->logToken));
     foreach ($this->messages as $message) {
         if (array_key_exists($message[1], $this->_monologLevels)) {
             $monolog->addRecord($this->_monologLevels[$message[1]], $this->formatMessage($message), isset($message[4]) && is_array($message[4]) ? $message[4] : []);
         }
     }
 }
开发者ID:kop,项目名称:yii2-logentries,代码行数:13,代码来源:LogentriesTarget.php

示例12: addRecord

 public function addRecord($level, $message, array $context = array())
 {
     if ($message instanceof \Exception) {
         $context['title'] = $message->getMessage();
         $handler = new ExceptionHandler($this);
         $message = $handler->renderExceptionForLogger($message);
     } else {
         $context['title'] = $message;
     }
     return parent::addRecord($level, $message, $context);
 }
开发者ID:swayok,项目名称:laravel-extended-errors,代码行数:11,代码来源:Logger.php

示例13: testHandleWithException

 public function testHandleWithException()
 {
     $app = $this->getApp();
     $app['request'] = Request::createFromGlobals("/");
     $log = new Logger('logger.system');
     $log->pushHandler(new SystemHandler($app));
     $mocker = new DoctrineMockBuilder();
     $db = $mocker->getConnectionMock();
     $db->expects($this->any())->method('insert')->with($this->equalTo("bolt_log_system"));
     $app['db'] = $db;
     $log->addRecord(Logger::DEBUG, 'test', array('event' => '', 'exception' => new \Exception()));
 }
开发者ID:aaleksu,项目名称:bolt_cm,代码行数:12,代码来源:SystemHandlerTest.php

示例14: log

 public function log($message, $priority = self::INFO)
 {
     if (!is_array($message) && method_exists($this, 'logException')) {
         // forward BC with Nette in 2.3-dev
         $exceptionFile = $message instanceof \Exception ? $this->logException($message) : NULL;
         $message = array(@date('[Y-m-d H-i-s]'), $this->formatMessage($message), ' @ ' . self::getSource(), $exceptionFile ? ' @@ ' . basename($exceptionFile) : NULL);
         if (in_array($priority, array(self::ERROR, self::EXCEPTION, self::CRITICAL), TRUE)) {
             $this->sendEmail(implode('', $message));
         }
     }
     $normalised = $message;
     $context = array('at' => self::getSource());
     if (is_array($message)) {
         // bc with Nette until 2.3
         if (count($message) >= 2 && preg_match('~\\[[\\d+ -]+\\]~i', $message[0])) {
             array_shift($message);
             // first entry is probably time
         }
         if (isset($message[1]) && preg_match('~\\@\\s+https?:\\/\\/.+~', $message[1]) || preg_match('~CLI:.+~i', $message[1])) {
             $context['at'] = ltrim($message[1], '@ ');
             unset($message[1]);
         }
         if (isset($message[2]) && preg_match('~\\@\\@\\s+exception\\-[^\\s]+\\.html~', $message[2])) {
             $context['tracy'] = ltrim($message[2], '@ ');
             unset($message[2]);
         }
         $normalised = implode($message);
     }
     $levels = $this->monolog->getLevels();
     $level = isset($levels[$uPriority = strtoupper($priority)]) ? $levels[$uPriority] : Monolog\Logger::INFO;
     switch ($priority) {
         case 'access':
             $this->monolog->addInfo($normalised, array('priority' => $priority) + $context);
             break;
         default:
             $this->monolog->addRecord($level, $normalised, array('priority' => $priority) + $context);
     }
     return isset($context['tracy']) ? $context['tracy'] : '';
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:39,代码来源:MonologAdapter.php

示例15: write

 public function write(Entry $entry)
 {
     if (!$this->isTriggered($entry)) {
         return;
     }
     $output = "%channel%.%level_name%: %message%";
     $formatter = new LineFormatter($output);
     $name = env('LOGGER_APP_NAME') . '-' . $entry->getChannel();
     $log = new MonologLogger($name);
     $syslogHandler = new SyslogUdpHandler(env('LOGGER_PAPERTRAIL_HOST'), env('LOGGER_PAPERTRAIL_PORT'));
     $syslogHandler->setFormatter($formatter);
     $log->pushHandler($syslogHandler);
     $log->addRecord($entry->getCode(), $entry->getMessage(), $entry->getContext());
 }
开发者ID:nztim,项目名称:logger,代码行数:14,代码来源:PapertrailHandler.php


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