當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LoggerInterface::pushHandler方法代碼示例

本文整理匯總了PHP中Psr\Log\LoggerInterface::pushHandler方法的典型用法代碼示例。如果您正苦於以下問題:PHP LoggerInterface::pushHandler方法的具體用法?PHP LoggerInterface::pushHandler怎麽用?PHP LoggerInterface::pushHandler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Log\LoggerInterface的用法示例。


在下文中一共展示了LoggerInterface::pushHandler方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('file');
     if (!is_file($file)) {
         throw new RuntimeException('File does not exists');
     }
     $verbose = $output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL;
     if (!$verbose) {
         $this->logger->pushHandler(new NullHandler());
     }
     try {
         $this->connection->beginTransaction();
         $result = $this->importService->import(file_get_contents($file));
         $this->connection->commit();
         $output->writeln('Import successful!');
         $output->writeln('The following actions were done:');
         $output->writeln('');
         foreach ($result as $message) {
             $output->writeln('- ' . $message);
         }
     } catch (\Exception $e) {
         $this->connection->rollback();
         $output->writeln('An exception occured during import. No changes are applied to the database.');
         $output->writeln('');
         $output->writeln('Message: ' . $e->getMessage());
         $output->writeln('Trace: ' . $e->getTraceAsString());
     }
     if (!$verbose) {
         $this->logger->popHandler();
     }
 }
開發者ID:apioo,項目名稱:fusio-impl,代碼行數:31,代碼來源:ImportCommand.php

示例2: setUp

 /**
  * Set up test environment
  */
 public function setUp()
 {
     parent::setUp();
     $this->link = new \MySQLi('localhost', 'root', '');
     if ($this->link->connect_error) {
         throw new \RuntimeException('Failed to connect to database. MySQL said: ' . $this->link->connect_error);
     }
     if (!$this->link->select_db('activecollab_jobs_queue_commands_test')) {
         throw new \RuntimeException('Failed to select database.');
     }
     $this->connection = new MysqliConnection($this->link);
     $this->queue = new MySqlQueue($this->connection);
     $this->dispatcher = new Dispatcher($this->queue);
     $this->log_file_path = dirname(__DIR__) . '/logs/' . date('Y-m-d') . '.txt';
     if (is_file($this->log_file_path)) {
         unlink($this->log_file_path);
     }
     $this->log = new Logger('cli');
     $handler = new StreamHandler($this->log_file_path, Logger::DEBUG);
     $formatter = new LineFormatter();
     $formatter->includeStacktraces(true);
     $handler->setFormatter($formatter);
     $this->log->pushHandler($handler);
     $this->container = new Container(['dispatcher' => $this->dispatcher, 'log' => $this->log]);
 }
開發者ID:activecollab,項目名稱:jobsqueuecommands,代碼行數:28,代碼來源:TestCase.php

示例3: collect

 /**
  * {@inheritdoc}
  */
 public function collect(RequestObject $requestObject, array $parameters = [])
 {
     $parameters = $this->resolveCollectorParameters($parameters);
     $logFile = sprintf('%s/%s.%s', $this->logFolder, $this->kernelEnvironment, $parameters['logFile']);
     $this->logger->pushHandler(new StreamHandler($logFile));
     $this->logger->info('request_collector.collect', $this->serializer->normalize($requestObject));
 }
開發者ID:deuzu,項目名稱:request-collector-bundle,代碼行數:10,代碼來源:LoggerCollector.php

示例4: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->log = $log = new Logger('Insight test');
     $this->log->pushHandler(new NullHandler());
     $this->current_timestamp = new DateTimeValue();
     DateTimeValue::setTestNow($this->current_timestamp);
 }
開發者ID:activecollab,項目名稱:insight,代碼行數:11,代碼來源:TestCase.php

示例5: setUp

 /**
  * @inheritdoc
  */
 public function setUp()
 {
     $this->handler = new ArrayHandler();
     $this->handler->setFormatter(new LineFormatter('%level_name% %message%'));
     $this->logger = new Logger('test');
     $this->logger->pushHandler($this->handler);
     $this->logger->pushProcessor(new ContextReplacementProcessor());
 }
開發者ID:oqq,項目名稱:minc-log,代碼行數:11,代碼來源:LoggerTest.php

示例6: __construct

 public function __construct($logger = null, $formatter = null)
 {
     if ($logger instanceof LoggerInterface) {
         $this->logger = $logger;
     } else {
         $this->logger = new Logger('EvaOAuth');
         $this->logger->pushHandler(new StreamHandler($logger, Logger::DEBUG));
     }
     $this->formatter = $formatter instanceof Formatter ? $formatter : new Formatter($formatter);
 }
開發者ID:assad2012,項目名稱:EvaOAuth,代碼行數:10,代碼來源:LogSubscriber.php

示例7: __construct

 /**
  * @param LoggerInterface $logger
  */
 public function __construct(LoggerInterface $logger = null)
 {
     if (is_null($logger)) {
         $this->logger = new Logger("monitor");
         $this->logger->pushHandler(new NullHandler());
     } else {
         $this->logger = $logger;
     }
     $this->pool = new Pool();
 }
開發者ID:huyanping,項目名稱:log-monitor,代碼行數:13,代碼來源:Monitor.php

示例8: __construct

 /**
  * @param LoggerInterface|null $logger
  * @param Mission[]|null $missions
  */
 public function __construct(LoggerInterface $logger = null, $missions = null)
 {
     set_time_limit(0);
     if (is_null($logger)) {
         $this->logger = new Logger(self::NAME);
         $this->logger->pushHandler(new NullHandler());
     } else {
         $this->logger = $logger;
     }
     $this->batchAddMissions($missions);
 }
開發者ID:u0mo5,項目名稱:php_crontab,代碼行數:15,代碼來源:Crontab.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $parameters = ['host' => $input->getArgument('host'), 'user' => $input->getArgument('username'), 'password' => $input->getArgument('password'), 'dbname' => $input->getArgument('database'), 'driver' => $input->getArgument('driver'), 'charset' => 'utf8'];
     $this->connection = $this->getContainer()->get('doctrine.dbal.connection_factory')->createConnection($parameters);
     $this->em = $this->getContainer()->get('doctrine.orm.entity_manager');
     $path = $this->getContainer()->getParameter('kernel.root_dir') . '/logs/import.log';
     $this->logger = $this->getContainer()->get('logger');
     $this->logger->pushHandler(new StreamHandler($path, Logger::INFO));
     if ($input->getOption('disable-logging')) {
         $this->disableLoggableExtension();
     }
 }
開發者ID:okulbilisim,項目名稱:ojs-tools-bundle,代碼行數:12,代碼來源:ImportCommand.php

示例10: __construct

 public function __construct($config = [])
 {
     $this->parentConstruct($config);
     if (isset($this->logger)) {
         return;
     }
     $this->logger = new Logger('Rock');
     if (!$this->handlers) {
         $this->handlers = $this->defaultHandlers();
     }
     foreach ($this->handlers as $level => $ahndler) {
         $this->logger->pushHandler($ahndler);
     }
 }
開發者ID:romeoz,項目名稱:rock,代碼行數:14,代碼來源:Log.php

示例11: getLogger

 public static function getLogger()
 {
     if (!self::$logger) {
         self::$logger = new Logger(KBGDC_APP_NAME);
         if (getenv('KBGDC_PAPERTRAIL_PORT')) {
             $handler = new SyslogUdpHandler("logs.papertrailapp.com", getenv('KBGDC_PAPERTRAIL_PORT'));
         } else {
             $handler = new SyslogHandler(KBGDC_APP_NAME);
         }
         $handler->setFormatter(new JsonFormatter());
         self::$logger->pushHandler($handler);
     }
     return self::$logger;
 }
開發者ID:keboola,項目名稱:gooddata-php-client,代碼行數:14,代碼來源:Helper.php

示例12: create

 /**
  * @param string $name
  * @param bool   $saveOnRedis
  *
  * @return LoggerInterface
  */
 public static function create($name = 'EloGankAPI', $saveOnRedis = false)
 {
     if (!isset(self::$logger)) {
         $verbosity = constant('Monolog\\Logger::' . strtoupper(ConfigurationLoader::get('log.verbosity')));
         self::$logger = new Logger($name, array(new ConsoleHandler(new ConsoleOutput(), true, array(OutputInterface::VERBOSITY_NORMAL => $verbosity, OutputInterface::VERBOSITY_VERBOSE => Logger::DEBUG, OutputInterface::VERBOSITY_VERY_VERBOSE => Logger::DEBUG, OutputInterface::VERBOSITY_DEBUG => Logger::DEBUG)), new RotatingFileHandler(ConfigurationLoader::get('log.path'), ConfigurationLoader::get('log.max_file'), $verbosity)));
         // Allow the server to retrieve clients logs
         if (true === ConfigurationLoader::get('client.async.enabled')) {
             self::$redisClient = new Client(sprintf('tcp://%s:%s', ConfigurationLoader::get('client.async.redis.host'), ConfigurationLoader::get('client.async.redis.port')));
             if ($saveOnRedis) {
                 self::$logger->pushHandler(new RedisHandler(self::$redisClient, ConfigurationLoader::get('client.async.redis.key') . '.client.logs', $verbosity));
             }
         }
     }
     return self::$logger;
 }
開發者ID:phxlol,項目名稱:lol-php-api,代碼行數:21,代碼來源:LoggerFactory.php

示例13: __construct

 /**
  * @param $app
  */
 public function __construct(RenaApp $app)
 {
     $this->app = $app;
     $this->logger = new Logger('projectRena');
     $logFile = $this->app->baseConfig->getConfig('logFile', 'Logging', __DIR__ . '/../../logs/app.log');
     // Make sure the logfile exists and is writeable
     if (!is_writable($logFile)) {
         chmod($logFile, 0777);
     }
     if (!file_exists($logFile)) {
         file_put_contents($logFile, "");
     }
     // Setup the push handler
     $this->logger->pushHandler(new StreamHandler($logFile, $this->app->baseConfig->getConfig("logLevel", "Logging", 100), true, 0777));
 }
開發者ID:bllevy2,項目名稱:projectRena,代碼行數:18,代碼來源:Logging.php

示例14: debugFilePath

 /**
  * Set different debug file location.
  *
  * @access  public
  * @param   string          $path  File path
  * @return  \carteiro\Mail
  */
 public function debugFilePath($path)
 {
     $this->debug(true);
     $this->logger->popHandler();
     $this->logger->pushHandler(new StreamHandler($path, Logger::DEBUG));
     return $this;
 }
開發者ID:aldoanizio,項目名稱:carteiro,代碼行數:14,代碼來源:Mail.php

示例15: getLogger

 /**
  * @codeCoverageIgnore
  * @return LoggerInterface
  */
 public function getLogger()
 {
     if (!$this->logger instanceof LoggerInterface) {
         $this->logger = new Logger(__CLASS__);
         $this->logger->pushHandler(new NullHandler());
     }
     return $this->logger;
 }
開發者ID:leadtech,項目名稱:boot-rabbit-mq,代碼行數:12,代碼來源:AbstractConsumer.php


注:本文中的Psr\Log\LoggerInterface::pushHandler方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。