• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Handler\ErrorLogHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Monolog\Handler\ErrorLogHandler的典型用法代码示例。如果您正苦于以下问题:PHP ErrorLogHandler类的具体用法?PHP ErrorLogHandler怎么用?PHP ErrorLogHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: testShouldLogMessagesUsingErrorLogFuncion

 /**
  * @covers Monolog\Handler\ErrorLogHandler::write
  */
 public function testShouldLogMessagesUsingErrorLogFuncion()
 {
     $type = ErrorLogHandler::OPERATING_SYSTEM;
     $handler = new ErrorLogHandler($type);
     $handler->handle($this->getRecord(Logger::ERROR));
     $this->assertStringMatchesFormat('[%s] test.ERROR: test [] []', $GLOBALS['error_log'][0]);
     $this->assertSame($GLOBALS['error_log'][1], $type);
 }
开发者ID:no-chris,项目名称:connector,代码行数:11,代码来源:ErrorLogHandlerTest.php


示例2: setLogger

 protected function setLogger(&$c)
 {
     $c['Logger'] = function () {
         $log = new Logger('ErrorLogger');
         $handler = new ErrorLogHandler();
         $formatter = new LineFormatter();
         $formatter->includeStacktraces();
         $handler->setFormatter($formatter);
         $log->pushHandler($handler);
         return $log;
     };
 }
开发者ID:jhnbrnn,项目名称:Sloop,代码行数:12,代码来源:Sloop.php


示例3: testShouldLogMessagesUsingErrorLogFuncion

 /**
  * @covers Monolog\Handler\ErrorLogHandler::write
  */
 public function testShouldLogMessagesUsingErrorLogFuncion()
 {
     $type = ErrorLogHandler::OPERATING_SYSTEM;
     $handler = new ErrorLogHandler($type);
     $handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true));
     $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
     $this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]);
     $this->assertSame($GLOBALS['error_log'][0][1], $type);
     $handler = new ErrorLogHandler($type, Logger::DEBUG, true, true);
     $handler->setFormatter(new LineFormatter(null, null, true));
     $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz"));
     $this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]);
     $this->assertSame($GLOBALS['error_log'][1][1], $type);
     $this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]);
     $this->assertSame($GLOBALS['error_log'][2][1], $type);
     $this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]);
     $this->assertSame($GLOBALS['error_log'][3][1], $type);
 }
开发者ID:saj696,项目名称:pipe,代码行数:21,代码来源:ErrorLogHandlerTest.php


示例4: register

 public function register(Container $app)
 {
     $app['logger'] = function () use($app) {
         return $app['monolog'];
     };
     $app['monolog'] = function ($app) {
         $logger = new Logger($app['monolog.name']);
         $rotate = $app['config']->get('app.log.rotate', 'single');
         $logger->pushHandler($app['monolog.handler.' . $rotate]);
         return $logger;
     };
     $app['monolog.formatter'] = function () {
         return new LineFormatter();
     };
     $app['monolog.handler.single'] = function ($app) {
         $handler = new StreamHandler($app['monolog.logfile'], $app['monolog.level']);
         $handler->setFormatter($app['monolog.formatter']);
         return $handler;
     };
     $app['monolog.handler.daily'] = function ($app) {
         $maxFiles = $app['config']->get('app.log.max_files', 5);
         $handler = new RotatingFileHandler($app['monolog.logfile'], $maxFiles, $app['monolog.level']);
         $handler->setFormatter($app['monolog.formatter']);
         return $handler;
     };
     $app['monolog.handler.error'] = function ($app) {
         $handler = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, $app['monolog.level']);
         $handler->setFormatter($app['monolog.formatter']);
         return $handler;
     };
     $app['monolog.handler.syslog'] = function ($app) {
         $handler = new SyslogHandler($app['monolog.name'], LOG_USER, $app['monolog.level']);
         $handler->setFormatter($app['monolog.formatter']);
         return $handler;
     };
     $level = $app['config']->get('app.log.level', 'debug');
     $app['monolog.level'] = $this->parseLevel($level);
     $app['monolog.logfile'] = $app['path.logs'] . $this->getSettings('app.log.logfile');
     $app['monolog.name'] = $this->getSettings('monolog.name', 'app.name');
 }
开发者ID:speedwork,项目名称:framework,代码行数:40,代码来源:MonologServiceProvider.php


示例5: useErrorLog

 public function useErrorLog($level = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM)
 {
     $level = $this->parseLevel($level);
     $this->monolog->pushHandler($handler = new ErrorLogHandler($messageType, $level));
     $handler->setFormatter($this->getDefaultFormatter());
 }
开发者ID:devhrmx,项目名称:kraken,代码行数:6,代码来源:compiled.php


示例6: die

 * You are free to copy this file as "loghandler.php" and make any
 * modification you need.  This allows you to make customization that will not
 * be overwritten during an update.
 *
 * WHMCS will attempt to load your custom "loghandler.php" instead of this
 * file ("dist.loghandler.php").
 *
 ****************************
 ** DO NOT EDIT THIS FILE! **
 ****************************
 *
 * The WHMCS initializes a Monolog logger, exposing the handler for customization.
 *
 * You are free to customize the handlers by modify this file to your needs.
 *
 * By default, WHMCS will log all messages to the configured PHP error log
 * (i.e., the Apache webserver error log).
 *
 * NOTE:
 * * The applications handler by default, as defined here, will log at the
 *   'warning' level, if most verbose is required, consider 'info' or 'debug'
 *
 * Please see Monolog documentation for usage of handlers and log levels
 * @link https://github.com/Seldaek/monolog
 */
if (!defined("ROOTDIR")) {
    die("This file cannot be accessed directly");
}
$handle = new ErrorLogHandler(ErrorLogHandler::OPERATING_SYSTEM, Logger::WARNING);
$handle->setFormatter(new LineFormatter('[%channel%] %level_name%: %message% %context% %extra%'));
Log::pushHandler($handle);
开发者ID:MarcelaGotta,项目名称:Webty,代码行数:31,代码来源:dist.loghandler.php


示例7: getLogger

 /**
  * @return \Psr\Log\LoggerInterface
  */
 public function getLogger()
 {
     $handler = new MonologHandler\ErrorLogHandler(MonologHandler\ErrorLogHandler::OPERATING_SYSTEM, Logger::ERROR, true, true);
     $handler->setFormatter(new ErrorFormatter());
     $logger = new Logger('psx');
     $logger->pushHandler($handler);
     return $logger;
 }
开发者ID:seytar,项目名称:psx,代码行数:11,代码来源:DefaultContainer.php


示例8: build

 public function build(ContainerBuilder $builder)
 {
     $builder->bind(LoggerInterface::class)->scoped(new Singleton())->to(function (TestSystem $system) {
         $handler = new ErrorLogHandler(ErrorLogHandler::SAPI, Logger::toMonologLevel(strtolower($system->getLogLevel())));
         $handler->pushProcessor(new PsrLogMessageProcessor());
         $monolog = new Logger('System');
         $monolog->pushHandler($handler);
         return $monolog;
     });
 }
开发者ID:koolkode,项目名称:k2,代码行数:10,代码来源:TestSystem.php


示例9: handle

 public function handle(array $record)
 {
     if ($record['channel'] === $this->appName) {
         $this->setFormatter($this->defaultFormatter);
         $record['filename'] = strtolower($record['level_name']);
     } else {
         $this->setFormatter($this->priorityFormatter);
         $record['filename'] = $record['channel'];
     }
     return parent::handle($record);
 }
开发者ID:pepakriz,项目名称:Monolog,代码行数:11,代码来源:FallbackNetteHandler.php


示例10: setLevel

 public function setLevel($level)
 {
     if (!is_string($level)) {
         parent::setLevel((int) $level);
         return;
     }
     if (!defined('\\Monolog\\Logger::' . $level)) {
         return;
     }
     parent::setLevel(constant('\\Monolog\\Logger::' . $level));
 }
开发者ID:cloudfoundry-community,项目名称:cf-helper-php,代码行数:11,代码来源:CloudFoundryHandler.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Handler\RotatingFileHandler类代码示例发布时间:2022-05-23
下一篇:
PHP Handler\AbstractProcessingHandler类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap