本文整理汇总了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']);
};
}
示例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']);
}
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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;
}
示例13: logLevelProvider
public function logLevelProvider()
{
$levels = array();
$monologLogger = new Logger('');
foreach ($monologLogger->getLevels() as $levelName => $level) {
$levels[] = array($levelName, $level);
}
return $levels;
}
示例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);
}
示例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());
}