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


PHP Monolog\Logger類代碼示例

本文整理匯總了PHP中Monolog\Logger的典型用法代碼示例。如果您正苦於以下問題:PHP Logger類的具體用法?PHP Logger怎麽用?PHP Logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: interventionRequestAction

 /**
  *
  * @param  Request $request
  * @param  string  $queryString
  * @param  string  $filename
  * @return Response
  */
 public function interventionRequestAction(Request $request, $queryString, $filename)
 {
     $log = new Logger('InterventionRequest');
     $log->pushHandler(new StreamHandler(ROADIZ_ROOT . '/logs/interventionRequest.log', Logger::INFO));
     try {
         $cacheDir = ROADIZ_ROOT . '/cache/rendered';
         if (!file_exists($cacheDir)) {
             mkdir($cacheDir);
         }
         $conf = new Configuration();
         $conf->setCachePath($cacheDir);
         $conf->setImagesPath(ROADIZ_ROOT . '/files');
         /*
          * Handle short url with Url rewriting
          */
         $expander = new ShortUrlExpander($request);
         $expander->injectParamsToRequest($queryString, $filename);
         /*
          * Handle main image request
          */
         $iRequest = new InterventionRequest($conf, $request, $log);
         $iRequest->handle();
         return $iRequest->getResponse();
     } catch (\Exception $e) {
         if (null !== $log) {
             $log->error($e->getMessage());
         }
         return new Response($e->getMessage(), Response::HTTP_NOT_FOUND, ['content-type' => 'text/plain']);
     }
 }
開發者ID:justinpocta,項目名稱:roadiz,代碼行數:37,代碼來源:AssetsController.php

示例2: register

 /**
  * Register the application services.
  *
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/sql-logging.php';
     $this->mergeConfigFrom($configPath, 'sql-logging');
     if (config('sql-logging.log', false)) {
         Event::listen('illuminate.query', function ($query, $bindings, $time) {
             $data = compact('bindings', 'time');
             // Format binding data for sql insertion
             foreach ($bindings as $i => $binding) {
                 if ($binding instanceof \DateTime) {
                     $bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
                 } else {
                     if (is_string($binding)) {
                         $bindings[$i] = "'{$binding}'";
                     }
                 }
             }
             // Insert bindings into query
             $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
             $query = vsprintf($query, $bindings);
             $log = new Logger('sql');
             $log->pushHandler(new StreamHandler(storage_path() . '/logs/sql-' . date('Y-m-d') . '.log', Logger::INFO));
             // add records to the log
             $log->addInfo($query, $data);
         });
     }
 }
開發者ID:oscaragcp,項目名稱:sql-logging,代碼行數:32,代碼來源:SqlLoggingServiceProvider.php

示例3: run

 public static function run()
 {
     echo "say hello on " . date('Y-m-d H:i:s');
     $log = new Logger('hello');
     $log->pushHandler(new StreamHandler('app.log', Logger::INFO));
     $log->addInfo("say hello on " . date('Y-m-d H:i:s'));
 }
開發者ID:gudongkun,項目名稱:greeting,代碼行數:7,代碼來源:Hello.php

示例4: setUp

 /**
  * Instantiate mediavorus to register the mime types
  */
 public function setUp()
 {
     parent::setUp();
     $logger = new Logger('test');
     $logger->pushHandler(new NullHandler());
     $mediavorus = new MediaVorus(Reader::create($logger), Writer::create($logger), FFProbe::create());
 }
開發者ID:ilosada,項目名稱:chamilo-lms-icpna,代碼行數:10,代碼來源:FileTest.php

示例5: register

 public function register(Container $container)
 {
     $log = new Logger('grav');
     $log_file = LOG_DIR . 'grav.log';
     $log->pushHandler(new StreamHandler($log_file, Logger::WARNING));
     $container['log'] = $log;
 }
開發者ID:locii,項目名稱:corporation-documentation,代碼行數:7,代碼來源:LoggerServiceProvider.php

示例6: __construct

 /**
  * @param array $config
  * @throws \Exception
  */
 protected function __construct($config)
 {
     parent::__construct($config);
     $this->memcache = new \Memcache();
     /**
      * This is something tricky in PHP. If you use pconnect (p=persistent) the connection will remain open all the time.
      * This is not a bad thing since we're using the cache all the time (you don't turn off the light of the kitchen if you're running in and out, switching it too much would even consume more)
      * In memcache, the old but stable implementation in PHP of memcached the persistent connection works like charm
      * In memcached however there is a severe bug which leads to a memory leak. If you'd take over code from this class to implement memcached, DON'T use the persistent connect!
      */
     if (!isset($this->config["host"])) {
         // the default host for memcached localhost
         $this->config["host"] = "localhost";
     }
     if (!isset($this->config["port"])) {
         // the default port for memcached is 11211
         $this->config["port"] = 11211;
     }
     if (!$this->memcache->pconnect($this->config["host"], $this->config["port"])) {
         if (isset($this->config["log_dir"])) {
             $log_dir = rtrim($this->config["log_dir"], "/");
             $log = new Logger('cache');
             $log->pushHandler(new StreamHandler($log_dir . "/log_" . date('Y-m-d') . ".txt", Logger::CRITICAL));
             $log->addCritical("Could not connect to memcached.", $this->config);
         } else {
             /*
              * if we have no log directory, it's no use to throw a TDTException
              */
             throw new \Exception("No connection could be made to the memcache. Please check your given configuration.");
         }
     }
 }
開發者ID:Tjoosten,項目名稱:cache,代碼行數:36,代碼來源:MemCache.php

示例7: fetchAllRates

 function fetchAllRates(Logger $logger)
 {
     $url = "https://api.vircurex.com/api/get_info_for_currency.json";
     $logger->info($url);
     $json = Fetch::jsonDecode(Fetch::get($url));
     $result = array();
     $ignored = 0;
     foreach ($json as $pair2 => $pairs) {
         if ($pair2 == "status") {
             continue;
         }
         foreach ($pairs as $pair1 => $market) {
             if ($market['last_trade'] == 0 || $market['lowest_ask'] == 0 || $market['highest_bid'] == 0) {
                 // ignore empty markets
                 $ignored++;
                 continue;
             }
             $currency1 = $this->getCurrencyCode($pair1);
             $currency2 = $this->getCurrencyCode($pair2);
             if (CurrencyOrder::hasOrder($currency1) && CurrencyOrder::hasOrder($currency2)) {
                 if (!CurrencyOrder::isOrdered($currency1, $currency2)) {
                     // do not duplicate ordered currencies
                     continue;
                 }
             }
             $rate = array("currency1" => $currency1, "currency2" => $currency2, "last_trade" => $market['last_trade'], "volume" => $market['volume'], 'bid' => $market['highest_bid'], 'ask' => $market['lowest_ask']);
             $result[] = $rate;
         }
     }
     $logger->info("Ignored " . $ignored . " markets with last trade price of 0");
     return $result;
 }
開發者ID:openclerk,項目名稱:exchanges,代碼行數:32,代碼來源:Vircurex.php

示例8: setUp

 function setUp()
 {
     $logger = new \Monolog\Logger("test");
     $logger->pushHandler(new SilentLogger());
     $parser = new Parser($logger);
     $this->result = $parser->load($this->getFile());
 }
開發者ID:soundasleep,項目名稱:phpdoc2,代碼行數:7,代碼來源:DocCommentTest.php

示例9: notify

 public function notify(Service\Record $record, DOMDocument $config, Logger $logger)
 {
     $activity = $config->getElementsByTagName('activity')->item(0);
     if ($activity !== null) {
         $logger->info('Create user activity template');
         try {
             $templates = $activity->childNodes;
             for ($i = 0; $i < $templates->length; $i++) {
                 $template = $templates->item($i);
                 if (!$template instanceof DOMElement) {
                     continue;
                 }
                 if ($template->nodeName == 'template') {
                     $type = $template->getAttribute('type');
                     $verb = $template->getAttribute('verb');
                     $table = $template->getAttribute('table');
                     $path = $template->getAttribute('path');
                     $summary = $template->nodeValue;
                     if (isset($this->registry['table.' . $table])) {
                         $table = $this->registry['table.' . $table];
                     } else {
                         throw new Exception('Invalid table ' . $table);
                     }
                     if (!empty($type) && !empty($verb) && !empty($table) && !empty($summary)) {
                         $this->sql->insert($this->registry['table.user_activity_template'], array('type' => $type, 'verb' => $verb, 'table' => $table, 'path' => $path, 'summary' => $summary));
                         $logger->info('> Created user activity template');
                         $logger->info($summary);
                     }
                 }
             }
         } catch (\Exception $e) {
             $logger->error($e->getMessage());
         }
     }
 }
開發者ID:visapi,項目名稱:amun,代碼行數:35,代碼來源:ConfigListener.php

示例10: setUpBeforeClass

 /**
  * This method is called before the first test of this test class is run.
  */
 public static function setUpBeforeClass()
 {
     // First, generate the INI files
     $buildNumber = time();
     $resourceFolder = __DIR__ . '/../../resources/';
     self::$buildFolder = __DIR__ . '/../../build/browscap-ua-test-' . $buildNumber . '/build/';
     $cacheFolder = __DIR__ . '/../../build/browscap-ua-test-' . $buildNumber . '/cache/';
     // create build folder if it does not exist
     if (!file_exists(self::$buildFolder)) {
         mkdir(self::$buildFolder, 0777, true);
     }
     if (!file_exists($cacheFolder)) {
         mkdir($cacheFolder, 0777, true);
     }
     $logger = new Logger('browscap');
     $logger->pushHandler(new NullHandler(Logger::DEBUG));
     $buildGenerator = new BuildGenerator($resourceFolder, self::$buildFolder);
     $writerCollectionFactory = new PhpWriterFactory();
     $writerCollection = $writerCollectionFactory->createCollection($logger, self::$buildFolder);
     $buildGenerator->setLogger($logger)->setCollectionCreator(new CollectionCreator())->setWriterCollection($writerCollection);
     $buildGenerator->run($buildNumber, false);
     $cache = new File([File::DIR => $cacheFolder]);
     self::$browscap = new Browscap();
     self::$browscap->setCache($cache)->setLogger($logger);
     self::$browscapUpdater = new BrowscapUpdater();
     self::$browscapUpdater->setCache($cache)->setLogger($logger);
     self::$propertyHolder = new PropertyHolder();
 }
開發者ID:browscap,項目名稱:browscap,代碼行數:31,代碼來源:UserAgentsTest.php

示例11: storeSupportedCurrencies

 function storeSupportedCurrencies($currencies, Logger $logger)
 {
     $logger->info("Storing " . count($currencies) . " currencies persistently");
     // find all existing currencies
     $existing = $this->getSupportedCurrencies(true);
     // remove removed currencies
     foreach ($existing as $currency) {
         if (array_search($currency, $currencies) === false) {
             $logger->info("Removing currency {$currency}");
             $q = $this->db->prepare("DELETE FROM account_currencies WHERE exchange=? AND currency=?");
             $q->execute(array($this->exchange->getCode(), $currency));
         }
     }
     // add new currencies
     foreach ($currencies as $currency) {
         if (array_search($currency, $existing) === false) {
             if (strlen($currency) != 3) {
                 $logger->info("Ignoring currency '" . $currency . "': not three characters long");
                 continue;
             }
             $logger->info("Adding currency {$currency}");
             $q = $this->db->prepare("INSERT INTO account_currencies SET exchange=?, currency=?");
             $q->execute(array($this->exchange->getCode(), $currency));
         }
     }
     // reset cache
     $this->cached_currencies = null;
 }
開發者ID:phpsource,項目名稱:openclerk,代碼行數:28,代碼來源:PersistentAccountType.php

示例12: createService

 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @return Logger
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $handler = new Handler\RotatingFileHandler('data/logs/error.log');
     $logger = new Logger('error-handling');
     $logger->pushHandler($handler);
     return $logger;
 }
開發者ID:Tigerlee1987,項目名稱:modules.zendframework.com,代碼行數:11,代碼來源:LoggerFactory.php

示例13: 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

示例14: 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

示例15: testLogsFromListeners

 public function testLogsFromListeners()
 {
     $output = new BufferedOutput();
     $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
     $handler = new ConsoleHandler(null, false);
     $logger = new Logger('app');
     $logger->pushHandler($handler);
     $dispatcher = new EventDispatcher();
     $dispatcher->addListener(ConsoleEvents::COMMAND, function () use($logger) {
         $logger->addInfo('Before command message.');
     });
     $dispatcher->addListener(ConsoleEvents::TERMINATE, function () use($logger) {
         $logger->addInfo('Before terminate message.');
     });
     $dispatcher->addSubscriber($handler);
     $dispatcher->addListener(ConsoleEvents::COMMAND, function () use($logger) {
         $logger->addInfo('After command message.');
     });
     $dispatcher->addListener(ConsoleEvents::TERMINATE, function () use($logger) {
         $logger->addInfo('After terminate message.');
     });
     $event = new ConsoleCommandEvent(new Command('foo'), $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'), $output);
     $dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
     $this->assertContains('Before command message.', $out = $output->fetch());
     $this->assertContains('After command message.', $out);
     $event = new ConsoleTerminateEvent(new Command('foo'), $this->getMock('Symfony\\Component\\Console\\Input\\InputInterface'), $output, 0);
     $dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
     $this->assertContains('Before terminate message.', $out = $output->fetch());
     $this->assertContains('After terminate message.', $out);
 }
開發者ID:egmax,項目名稱:symfony,代碼行數:30,代碼來源:ConsoleHandlerTest.php


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