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


PHP Logger::pushHandler方法代码示例

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


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

示例1: pushLogHandler

 public function pushLogHandler(HandlerInterface $handler)
 {
     if (!isset($this->logger)) {
         $this->logger = new Logger('byjg-anydataset');
     }
     $this->logger->pushHandler($handler);
 }
开发者ID:byjg,项目名称:anydataset,代码行数:7,代码来源:LogHandler.php

示例2: execute

 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $origin = $input->getOption('origin');
     $force = $input->getOption('force');
     $interactive = $input->isInteractive();
     $this->logger->pushHandler(new ConsoleHandler($output));
     $dispatcher = $this->sourceCleaner->getEventDispatcher();
     // listen to clean event
     $dispatcher->addListener(IoEvents::PRE_CLEAN_SOURCE, function (SourceEvent $event) use($output) {
         $source = $event->getSource();
         $output->writeln(sprintf('<fg=red>- %s:%s</>', $source->getOrigin()->getName(), $source->getOriginalId()));
     });
     if ($force) {
         $voter = new ThresholdVoter(function () {
             return true;
         }, $dispatcher);
     } else {
         $voter = new ThresholdVoter(function ($count, $total, $max, $message) use($output, $interactive) {
             $output->writeln($message);
             // see if we can ask the user to confirm cleanup
             $question = '<question>> Clean these sources anyway? [y]</question> ';
             return $interactive && $this->getDialogHelper()->askConfirmation($output, $question);
         }, $dispatcher);
     }
     $numCleaned = $this->clean($voter, $origin);
     $output->writeln(sprintf('<info>%s</info> sources cleaned', $numCleaned));
     return 0;
 }
开发者ID:mvanduijker,项目名称:FMIoBundle,代码行数:31,代码来源:SourceCleanupCommand.php

示例3: itShouldCollect

 /**
  * @test
  */
 public function itShouldCollect()
 {
     $this->serializer->normalize(Argument::any())->shouldBeCalled()->willReturn([]);
     $this->logger->pushHandler(Argument::any())->shouldBeCalled()->willReturn(true);
     $this->logger->info(Argument::type('string'), Argument::type('array'))->shouldBeCalled();
     $this->collector->collect($this->requestObject, ['logFile' => 'test.log']);
 }
开发者ID:deuzu,项目名称:request-collector-bundle,代码行数:10,代码来源:LoggerCollectorTest.php

示例4: beforeTest

 public function beforeTest(TestEvent $e)
 {
     $this->logger = new \Monolog\Logger(Descriptor::getTestFileName($e->getTest()));
     $this->logger->pushHandler($this->logHandler);
     $this->logger->info('------------------------------------');
     $this->logger->info("STARTED: " . ucfirst(Descriptor::getTestAsString($e->getTest())));
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:7,代码来源:Logger.php

示例5: execute

 /**
  * @see Console\Command\Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $start = microtime(true);
     $this->output = $output;
     $this->output->write('Extracting datas... ');
     $logger = new Logger('Builder');
     $logger->pushHandler(new NullHandler());
     if ($input->getOption('verbose')) {
         $logger->pushHandler(new StreamHandler('php://stdout'));
     }
     $dumper = new InformationDumper(new Exiftool($logger));
     $dump = $dumper->listDatas(InformationDumper::LISTTYPE_SUPPORTED_XML);
     $this->output->writeln('Done !');
     $this->output->writeln('Generating classes... ');
     $this->extractDump($dump);
     if (!$input->getOption('write')) {
         $this->output->writeln('These classes were not written. Use --write to write on disk');
     } else {
         $this->output->writeln('Erasing previous files... ');
         system('rm -R ' . __DIR__ . '/../../Driver/Tag/*');
         system('rm -R ' . __DIR__ . '/../../Driver/Type/*');
         $this->output->writeln('Writing files... ');
         $this->writeClasses($input->getOption('force'));
     }
     $this->output->writeln(sprintf('%d classes generated in %d seconds (%d Mb)', count($this->classes), microtime(true) - $start, memory_get_peak_usage() >> 20));
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:29,代码来源:ClassesBuilder.php

示例6: register

 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['hipchat'] = $app->share(function () use($app) {
         if (empty($app['hipchat.rooms'])) {
             return new NullLogger();
         }
         $log = new TargetMappingLogger();
         $app['hipchat.configure']($log);
         return $log;
     });
     $app['hipchat.configure'] = $app->protect(function (TargetMappingLogger $log) use($app) {
         $roomConfigs = $app['hipchat.rooms'];
         $defaults = ['targets' => [], 'name' => 'HipChat', 'notify' => false, 'level' => Logger::INFO, 'bubble' => true, 'useSSL' => true, 'format' => 'text', 'host' => 'api.hipchat.com', 'version' => HipChatHandler::API_V2, 'guzzle' => false];
         if (isset($roomConfigs['_default'])) {
             $defaults = $roomConfigs['_default'] + $defaults;
             unset($roomConfigs['_default']);
         }
         foreach ($roomConfigs as $roomConfig) {
             $roomConfig += $defaults;
             $logger = new Logger('hcm');
             if (!isset($roomConfig['room']) || !isset($roomConfig['token'])) {
                 throw new InvalidArgumentException('missing room/token configuration');
             }
             if (isset($roomConfig['guzzle']) && is_array($roomConfig['guzzle'])) {
                 $logger->pushHandler(new GuzzleHipChatHandler(new Client('', $this->prepareGuzzleOptions($roomConfig['guzzle'])), $roomConfig['token'], $roomConfig['room'], $roomConfig['name'], $roomConfig['notify'], $roomConfig['level'], $roomConfig['bubble'], $roomConfig['useSSL'], $roomConfig['format'], $roomConfig['host'], $roomConfig['version']));
             } else {
                 $logger->pushHandler(new HipChatHandler($roomConfig['token'], $roomConfig['room'], $roomConfig['name'], $roomConfig['notify'], $roomConfig['level'], $roomConfig['bubble'], $roomConfig['useSSL'], $roomConfig['format'], $roomConfig['host'], $roomConfig['version']));
             }
             $log->addLogger($logger, $roomConfig['targets']);
         }
     });
 }
开发者ID:perbility,项目名称:cilex-extensions,代码行数:37,代码来源:HipChatMonologServiceProvider.php

示例7: __construct

 /**
  * @param Config $config
  */
 public function __construct(Config $config)
 {
     $this->config = $config;
     // Set up logging
     $this->log = new Logger('GeoPalMap');
     $this->log->pushHandler(new StreamHandler($this->config->getLogFilePath(), Logger::WARNING));
 }
开发者ID:tymiles003,项目名称:geopal-map-tracker,代码行数:10,代码来源:Tracker.php

示例8: register

 public function register(Container $container)
 {
     $logger = new Logger('app');
     $logger->pushHandler(new StreamHandler(__DIR__ . '/../../data/debug.log', Logger::DEBUG));
     $logger->pushHandler(new SyslogHandler('kanboard', LOG_USER, Logger::DEBUG));
     $container['logger'] = $logger;
 }
开发者ID:andrearruda,项目名称:kanboard,代码行数:7,代码来源:Logging.php

示例9: ins

 public static function ins($space = 'default')
 {
     //获取配置
     $config = \Yaf\Application::app()->getConfig();
     //项目名
     $projName = isset($config->projName) ? strtolower($config->projName) : 'default';
     $channel = $projName . '/' . $space;
     $channelAll = $projName . '/_all';
     if (isset(self::$ins[$channel])) {
         return self::$ins[$channel];
     }
     //日志配置
     if (!isset($config->log)) {
         throw new Exception('must config the logger first.');
     }
     $logger = new MonoLogger($space);
     $syslog = new SyslogHandler($channel, LOG_LOCAL6, self::$logLevels[$config->log->level]);
     $syslogAll = new SyslogHandler($channelAll, LOG_LOCAL6, self::$logLevels[$config->log->level]);
     //设置日志格式
     $formatter = new LineFormatter("%channel% %level_name%: %message% %context% %extra%");
     $syslog->setFormatter($formatter);
     $syslogAll->setFormatter($formatter);
     $logger->pushHandler($syslog);
     $logger->pushHandler($syslogAll);
     //增加pid
     $processor = new ProcessIdProcessor();
     $logger->pushProcessor($processor);
     //与psr3 context保持一致
     $processor = new PsrLogMessageProcessor();
     $logger->pushProcessor($processor);
     self::$ins[$channel] = $logger;
     return self::$ins[$channel];
 }
开发者ID:qinyuguang,项目名称:libyaf,代码行数:33,代码来源:Logger.php

示例10: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $configuration = new Configuration(file_get_contents(__DIR__ . '/../../../config/config.json'));
     $resolver = new SpawnResolver($configuration, CpuInfo::detect());
     $factory = new Factory();
     $classname = $resolver->getClassName();
     if ($input->getOption('verbose')) {
         $outputLogger = new StreamHandler('php://stdout');
     } else {
         $outputLogger = new NullHandler();
     }
     $workers = new \ArrayIterator();
     for ($i = 1; $i <= $resolver->getSpawnQuantity(); $i++) {
         $output->write("Launching Worker <info>{$i}</info> ...");
         $logger = new Logger('Worker-' . $i);
         $logger->pushHandler($outputLogger);
         $logger->pushHandler(new RotatingFileHandler(__DIR__ . '/../../../logs/worker-' . $i . '.logs', 3));
         $worker = new Worker('Worker-' . $i, new \GearmanWorker(), $logger);
         foreach ($configuration['gearman-servers'] as $server) {
             $worker->addServer($server['host'], $server['port']);
         }
         $worker->setFunction(new $classname($configuration, $logger, $factory));
         $workers->append($worker);
         $output->writeln("Success !");
     }
     $manager = new ProcessManager(new EventDispatcher());
     $manager->process($workers, function (Worker $worker) {
         $worker->run();
     });
 }
开发者ID:nlegoff,项目名称:Worker,代码行数:30,代码来源:RunWorkers.php

示例11: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     self::$logger = new Logger('filefindtest');
     self::$logger->pushHandler(new TestHandler());
     self::$logger->pushHandler(new StreamHandler('test.log'));
 }
开发者ID:ubermichael,项目名称:filefinder,代码行数:7,代码来源:FileFindTest.php

示例12: setUp

 public function setUp()
 {
     parent::setUp();
     $this->monolog = new Monolog\Logger('log-decorator');
     $this->handler = new Monolog\Handler\TestHandler();
     $this->monolog->pushHandler($this->handler);
 }
开发者ID:olegpopadko,项目名称:log-decorator,代码行数:7,代码来源:Test.php

示例13: work

 public function work()
 {
     $identity = $this->identify();
     $this->logger->notice(sprintf('%s waiting for work on queue(s) [%s]', $identity, join(', ', $this->queues)));
     for (;;) {
         $job = $this->metro->pop($this->queues, $this);
         if (null !== $job) {
             $jobHandler = $this->metro->createTaskLogHander($job->getId());
             $this->logger->pushHandler($jobHandler);
             $this->logger->pushProcessor(function ($record) use($job) {
                 $record['extra']['job_id'] = $job->getId();
                 return $record;
             });
             $this->workOn($job, $jobHandler);
             $this->logger->popHandler();
             $this->logger->popProcessor();
         }
         if ($this->interval <= 0) {
             return;
         }
         if (null === $job) {
             if ($this->drainMode) {
                 $this->logger->notice(sprintf('%s exiting because all queues are empty', $identity));
                 return;
             }
             usleep($this->interval * 1000.0);
         }
     }
 }
开发者ID:metro-q,项目名称:metro,代码行数:29,代码来源:Worker.php

示例14: addDBHandler

 /**
  * @param resource $stream
  * @param integer  $level  The minimum logging level at which this handler will be triggered
  * @param Boolean  $bubble Whether the messages that are handled can bubble up the stack or not
  */
 public function addDBHandler($stream = null, $level = \Monolog\Logger::DEBUG, $bubble = true)
 {
     if (empty($stream)) {
         $stream = new DBHandler($this->logger->getName() . '_log', $level, $bubble);
     }
     $this->logger->pushHandler($stream);
 }
开发者ID:panvagenas,项目名称:wp-plugin-core,代码行数:12,代码来源:Logger.php

示例15: __construct

 /**
  * @param string $versionType
  */
 public function __construct($versionType = 'master')
 {
     $this->errorStackTraces = [];
     $this->logger = new Logger('Exceptions');
     $this->logger->pushHandler(new StreamHandler(__DIR__ . '/../data/logs/exceptions.log', Logger::DEBUG));
     $this->versionType = $versionType;
 }
开发者ID:robotomize,项目名称:fujes,代码行数:10,代码来源:ExceptionWrap.php


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