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


PHP Logger::getLevels方法代码示例

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


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

示例1: register

 public function register(Neptune $neptune)
 {
     $neptune['logger.name'] = function ($neptune) {
         return $neptune['config']->get('monolog.name', 'neptune');
     };
     $neptune['logger.path'] = function ($neptune) {
         return $neptune['config']->getRequired('monolog.path');
     };
     $neptune['logger.level'] = function ($neptune) {
         $level = $neptune['config']->get('monolog.level', Logger::DEBUG);
         if (is_int($level)) {
             return $level;
         }
         $level = strtoupper($level);
         $levels = Logger::getLevels();
         if (!isset($levels[$level])) {
             throw new \InvalidArgumentException("Invalid log level {$level} provided");
         }
         return $levels[$level];
     };
     $neptune['logger'] = function ($neptune) {
         $logger = new Logger($neptune['logger.name']);
         $logger->pushHandler(new StreamHandler($neptune['logger.path'], $neptune['logger.level']));
         return $logger;
     };
     $neptune['logger.exception_listener'] = function ($neptune) {
         return new LoggerExceptionListener($neptune['logger']);
     };
 }
开发者ID:glynnforrest,项目名称:neptune,代码行数:29,代码来源:MonologService.php

示例2: __construct

 /**
  * Register this plates view provider with a Pimple container
  *
  * @param string $name
  * @param array  $settings
  */
 public function __construct($name = 'slim-app', $settings = [])
 {
     $this->name = $name;
     $this->monolog = new Logger($this->name);
     $this->settings = array_merge($this->settings, $settings);
     if (null !== $this->settings['timezone']) {
         if (is_string($this->settings['timezone'])) {
             $this->settings['timezone'] = new \DateTimeZone($this->settings['timezone']);
         }
         Logger::setTimezone($this->settings['timezone']);
     }
     $this->monolog->setHandlers($this->settings['handlers']);
     $levels = array_keys(Logger::getLevels());
     if (!in_array(strtoupper($this->settings['level']), $levels)) {
         $this->settings['level'] = 'debug';
     }
     if ($path = $this->settings['directory']) {
         if ($path === 'syslog') {
             $this->useSyslog($this->name, $this->settings['level']);
         } elseif (is_dir($path)) {
             $path .= '/' . $this->name;
             $this->useRotatingFiles($path, $this->settings['level']);
         }
     }
 }
开发者ID:creasi,项目名称:slim-monolog,代码行数:31,代码来源:Monolog.php

示例3: __construct

 /**
  * SlackMessageFormatter constructor.
  * @param SlackMessage $initialMessage
  * @param array $colorMap
  */
 public function __construct(SlackMessage $initialMessage, array $colorMap = [])
 {
     $this->slackMessage = $initialMessage;
     if (count($colorMap) == count(Logger::getLevels())) {
         $this->color = $colorMap;
     }
 }
开发者ID:sleipi,项目名称:monolog2slackwebhook,代码行数:12,代码来源:SlackMessageFormatter.php

示例4: getLevel

 /**
  * Get log level.
  *
  * @return int
  *
  * @author Wuhsien Yu <wuhsienyu@gmail.com>
  *
  * @since  2016/03/12
  */
 protected static function getLevel()
 {
     $level = Logger::toMonologLevel(Config::get('log.level'));
     if (!in_array($level, Logger::getLevels())) {
         $level = Logger::INFO;
     }
     return $level;
 }
开发者ID:wuhsien,项目名称:log-level,代码行数:17,代码来源:LogLevelServiceProvider.php

示例5: getLevel

 /**
  * @param string $priority
  * @return int
  */
 protected function getLevel($priority)
 {
     if (isset($this->priorityMap[$priority])) {
         return $this->priorityMap[$priority];
     }
     $levels = $this->monolog->getLevels();
     return isset($levels[$uPriority = strtoupper($priority)]) ? $levels[$uPriority] : Monolog\Logger::INFO;
 }
开发者ID:armpit,项目名称:Monolog,代码行数:12,代码来源:MonologAdapter.php

示例6: mapLevel

 /**
  * @param string $levelName The log level: debug|info|notice|warning|error|critical|alert|emergency
  * @return mixed
  */
 protected function mapLevel($levelName)
 {
     $levels = Logger::getLevels();
     if (array_key_exists(strtoupper($levelName), $levels)) {
         return $levels[strtoupper($levelName)];
     }
     return Logger::INFO;
 }
开发者ID:qshurick,项目名称:logger,代码行数:12,代码来源:Monolog.php

示例7: provideSuiteRecords

 /**
  * Data provider that produce a suite of records in level order.
  *
  * @return array
  * @see GrowlHandlerTest::testIsHandling()
  * @see GrowlHandlerTest::testIsHandlingLevel()
  * @see GrowlHandlerTest::testHandleProcessOnlyNeededLevels()
  * @see GrowlHandlerTest::testHandleProcessAllMatchingRules()
  */
 public function provideSuiteRecords()
 {
     $dataset = array();
     foreach (Logger::getLevels() as $level_name => $level_code) {
         $dataset[] = $this->getRecord($level_code, sprintf('sample of %s message', $level_name));
     }
     return $dataset;
 }
开发者ID:ElectroLutz,项目名称:monolog-growlhandler,代码行数:17,代码来源:TestCase.php

示例8: setColorizeArray

 /**
  * Set the Color Scheme Array
  * @param array $colorScheme The Color Scheme Array
  */
 public function setColorizeArray(array $colorScheme)
 {
     // Only store entries that exist as Monolog\Logger levels
     $allowedLogLevels = array_values(\Monolog\Logger::getLevels());
     $colorScheme = array_intersect_key($colorScheme, array_flip($allowedLogLevels));
     // Store the filtered colorScheme
     $this->colorScheme = $colorScheme;
 }
开发者ID:bramus,项目名称:monolog-colored-line-formatter,代码行数:12,代码来源:ColorSchemeTrait.php

示例9: configure

 /**
  * Provides default options for all commands. This function should be called explicitly (i.e. parent::configure())
  * if the configure function is overridden.
  */
 protected function configure()
 {
     $this->runtimeConfig = new RuntimeConfig($this);
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_CONFIGURE);
     parent::configure();
     $this->addOption('log-level', 'l', InputOption::VALUE_REQUIRED, 'Override the Monolog logging level for this execution of the command. Valid values: ' . implode(',', array_keys(Logger::getLevels())))->addOption('log-filename', null, InputOption::VALUE_REQUIRED, 'Specify a different file (relative to the ' . 'kernel log directory) to send file logs to')->addOption('locking', null, InputOption::VALUE_REQUIRED, 'Switches locking on/off');
     $this->advanceExecutionPhase(RuntimeConfig::PHASE_POST_CONFIGURE);
 }
开发者ID:sarelvdwalt,项目名称:BaseCommandBundle,代码行数:12,代码来源:BaseCommand.php

示例10: index

 /**
  * @param Request $request
  * @param Application $app
  *
  * @return mixed
  */
 public function index(Request $request, Application $app)
 {
     $viewer = new LogViewer();
     $log = $viewer->getLog('elprecursor', 'log');
     if ($log === false) {
         return $app->redirect($app['url_generator']->generate('client', array('clientSlug' => $clientSlug)));
     }
     return $app['twig']->render('backend/log/list.html.twig', array('clients' => $viewer->getClients(), 'logs' => $viewer->getLogs('elprecursor'), 'clientSlug' => $clientSlug, 'logSlug' => 'log', 'log' => $log, 'logLevels' => Logger::getLevels(), 'minLogLevel' => 0));
 }
开发者ID:jamc92,项目名称:precursor-silex,代码行数:15,代码来源:Log.php

示例11: isTriggered

 protected function isTriggered(Entry $entry)
 {
     $emailLevel = env('LOGGER_EMAIL_LEVEL', false);
     if (!$emailLevel || $this->config->get('app.debug')) {
         return false;
     }
     $emailLevelCode = MonologLogger::getLevels()[$emailLevel];
     return $entry->getCode() >= $emailLevelCode;
 }
开发者ID:nztim,项目名称:logger,代码行数:9,代码来源:EmailHandler.php

示例12: setLevel

 /**
  * @param int $level
  *
  * @return self
  */
 private function setLevel($level)
 {
     $availableLevels = array_flip(Logger::getLevels());
     if (!isset($availableLevels[$level])) {
         throw new InvalidLoggerLevelException(sprintf('The level: "%d" does not exist. The available levels are: "%s"', $level, implode(', ', array_keys($availableLevels))), 400);
     }
     $this->level = $level;
     return $this;
 }
开发者ID:Pageon,项目名称:SlackWebhookMonolog,代码行数:14,代码来源:Config.php

示例13: logLevelProvider

 public function logLevelProvider()
 {
     $levels = array();
     $monologLogger = new Logger('');
     foreach ($monologLogger->getLevels() as $levelName => $level) {
         $levels[] = array($levelName, $level);
     }
     return $levels;
 }
开发者ID:ngitimfoyo,项目名称:Nyari-AppPHP,代码行数:9,代码来源:PsrHandlerTest.php

示例14: __call

 /**
  * Calls the named method which is not a class method.
  *
  * This method will check whether PSR-3 or Yii2 format is used and will execute the corresponding method.
  *
  * @param string $name The method name.
  * @param array $arguments Method arguments.
  *
  * @return mixed The method return value.
  */
 public function __call($name, array $arguments)
 {
     // Intercept calls to the "log()" method
     if ($name === 'log' && !empty($arguments)) {
         // PSR-3 format
         $reflection = new ReflectionClass(YiiLogger::className());
         if (in_array($arguments[0], array_keys($this->_monolog->getLevels())) && !in_array($arguments[1], array_keys($reflection->getConstants())) && (!isset($arguments[3]) || isset($arguments[3]) && is_array($arguments[3]))) {
             return call_user_func_array([$this, 'log'], $arguments);
         }
         // Yii2 format
         return call_user_func_array([$this, 'yiiLog'], $arguments);
     }
     // Execute Monolog methods, if they exists
     if (method_exists($this->_monolog, $name) && !method_exists($this, $name)) {
         return call_user_func_array([$this->_monolog, $name], $arguments);
     }
     return parent::__call($name, $arguments);
 }
开发者ID:uniconstructor,项目名称:yii2-monolog,代码行数:28,代码来源:Logger.php

示例15: testSetColorSchemeFilter

 public function testSetColorSchemeFilter()
 {
     $dummyArray = array(Logger::DEBUG => $this->ansi->sgr(array(SGR::COLOR_FG_GREEN, SGR::STYLE_INTENSITY_FAINT))->get(), '123' => 'foo', 9000 => 'bar', Logger::INFO => $this->ansi->sgr(array(SGR::COLOR_FG_GREEN, SGR::STYLE_INTENSITY_NORMAL))->get(), Logger::NOTICE => $this->ansi->sgr(array(SGR::COLOR_FG_GREEN, SGR::STYLE_INTENSITY_BRIGHT))->get(), 'foo' => 200, Logger::WARNING => $this->ansi->sgr(array(SGR::COLOR_FG_YELLOW, SGR::STYLE_INTENSITY_FAINT))->get(), Logger::ERROR => $this->ansi->sgr(array(SGR::COLOR_FG_YELLOW, SGR::STYLE_INTENSITY_NORMAL))->get(), Logger::CRITICAL => $this->ansi->sgr(array(SGR::COLOR_FG_RED, SGR::STYLE_INTENSITY_NORMAL))->get(), Logger::ALERT => $this->ansi->sgr(array(SGR::COLOR_FG_RED_BRIGHT, SGR::STYLE_INTENSITY_BRIGHT))->get(), Logger::EMERGENCY => $this->ansi->sgr(array(SGR::COLOR_FG_RED_BRIGHT, SGR::STYLE_INTENSITY_BRIGHT, SGR::STYLE_BLINK))->get());
     $this->clf->getColorScheme()->setColorizeArray($dummyArray);
     foreach (Logger::getLevels() as $level) {
         $this->assertArrayHasKey($level, $this->clf->getColorScheme()->getColorizeArray());
     }
     $this->assertArrayNotHasKey('123', $this->clf->getColorScheme()->getColorizeArray());
     $this->assertArrayNotHasKey('foo', $this->clf->getColorScheme()->getColorizeArray());
     $this->assertArrayNotHasKey(9000, $this->clf->getColorScheme()->getColorizeArray());
 }
开发者ID:bramus,项目名称:monolog-colored-line-formatter,代码行数:11,代码来源:ColoredLineFormatterTest.php


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