本文整理汇总了PHP中Monolog\Logger::addNotice方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::addNotice方法的具体用法?PHP Logger::addNotice怎么用?PHP Logger::addNotice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Logger
的用法示例。
在下文中一共展示了Logger::addNotice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
/**
* Called when this object is called as a function
*
* @param Context $context
* @param OptionsFactory $optionsFactory
* @throws \Exception if haltOnError setting is true
*/
public function __invoke(Context $context, OptionsFactory $optionsFactory)
{
$getopt = $context->getopt(array_keys(self::$options));
// Get directory list
$dirListFactory = new DirectoryListFactory();
$dirListFactory->loadFromCommandline($getopt->get(), 2);
$dirListFactory->loadFromStdin(new StdinReader(3));
$dirList = $dirListFactory->getList();
$this->logger->addDebug('Found directories', [count($dirList)]);
// Load base options
$baseOptions = $optionsFactory->newInstance();
$baseOptions->validateAllRequired();
if ($baseOptions->preview) {
$this->logger->addNotice('PREVIEW MODE');
}
foreach ($dirList as $dir) {
try {
$this->logger->addNotice('In directory', [$dir]);
$this->processDirectory($dir, $baseOptions, $optionsFactory);
} catch (\Exception $e) {
if ($baseOptions->haltOnError) {
throw $e;
} elseif ($baseOptions->verbosity == 2) {
$this->logger->addError($e, []);
} else {
$this->logger->addError($e->getMessage(), []);
}
}
}
}
示例2: writeEntry
protected function writeEntry($level, $message, $indent, $category = "", $additionalData = [])
{
$message = str_pad($category, 16, " ", STR_PAD_RIGHT) . "\t" . str_repeat(" ", $indent) . $message;
switch ($level) {
case Log::BULK_DATA_LEVEL:
$this->logger->addDebug($message, $additionalData);
break;
case Log::DEBUG_LEVEL:
$this->logger->addDebug($message, $additionalData);
break;
case Log::ERROR_LEVEL:
$this->logger->addError($message, $additionalData);
break;
case Log::PERFORMANCE_LEVEL:
$this->logger->addNotice($message, $additionalData);
break;
case Log::WARNING_LEVEL:
$this->logger->addWarning($message, $additionalData);
break;
case Log::REPOSITORY_LEVEL:
$this->logger->addNotice($message, $additionalData);
break;
default:
$this->logger->addNotice($message, $additionalData);
}
}
示例3: log
public function log($message, $priority = self::INFO)
{
if ($message instanceof \Exception) {
$message = $message->getMessage();
$context = [];
} elseif (is_string($message)) {
$context = [];
} else {
$context = $message;
unset($context[0]);
unset($context[1]);
if (isset($message[1])) {
$message = preg_replace('#\\s*\\r?\\n\\s*#', ' ', trim($message[1]));
}
}
switch ($priority) {
case self::DEBUG:
return $this->monolog->addDebug($message, $context);
case self::CRITICAL:
return $this->monolog->addCritical($message, $context);
case self::ERROR:
return $this->monolog->addError($message, $context);
case self::EXCEPTION:
return $this->monolog->addEmergency($message, $context);
case self::WARNING:
return $this->monolog->addWarning($message, $context);
case 'access':
return $this->monolog->addNotice($message, $context);
case 'emergency':
return $this->monolog->addEmergency($message, $context);
default:
return $this->monolog->addInfo($message, $context);
}
}
示例4: log
/**
* Log a message
*
* @param string $message
* @param int $level
* @param array $context
* @return void
*/
public function log($message, $level = Logger::INFO, array $context = [])
{
if (!$this->logger) {
return;
}
if (null === $level) {
$level = Logger::INFO;
}
switch ($level) {
case Logger::DEBUG:
$this->logger->addDebug($message, $context);
break;
case Logger::INFO:
$this->logger->addInfo($message, $context);
break;
case Logger::NOTICE:
$this->logger->addNotice($message, $context);
break;
case Logger::WARNING:
$this->logger->addWarning($message, $context);
break;
case Logger::ERROR:
$this->logger->addError($message, $context);
break;
case Logger::CRITICAL:
$this->logger->addCritical($message, $context);
break;
case Logger::EMERGENCY:
$this->logger->addEmergency($message, $context);
break;
default:
break;
}
}
示例5: findTextByKey
protected function findTextByKey($steps, $count)
{
$node = $this->source;
foreach (explode('.', $steps) as $step) {
if (!isset($node[$step])) {
$this->log->addWarning("Translation for '{$steps}' not found, missing key '{$step}'", [$this->language]);
return NULL;
}
$node = $node[$step];
}
if (!is_array($node)) {
if ($count !== NULL) {
$this->log->addNotice("Translation for '{$steps}' has no plurals, but count '{$count}' was passed", [$this->language]);
}
return $node;
}
if ($count === NULL) {
$this->log->addNotice("Translation for '{$steps}' has plurals, but no count was passed", [$this->language]);
}
$keys = $this->countToKey($count);
foreach ($keys as $key) {
if (isset($node[$key])) {
return $node[$key];
}
}
$this->log->addWarning("Translation for '{$steps}' is missing plurals", [$this->language]);
return NULL;
}
示例6: log
/**
* Отправляет сообщение в лог
*
* @param string $message сообщение
* @param int $level уровень
*
* @return void
*/
public function log($message, $level = AbstractLogger::NOTICE)
{
if ($level < $this->severity) {
return;
}
switch ($level) {
case AbstractLogger::EMERGENCY:
$this->impl->addEmergency($message);
break;
case AbstractLogger::ALERT:
$this->impl->addAlert($message);
break;
case AbstractLogger::CRITICAL:
$this->impl->addCritical($message);
break;
case AbstractLogger::ERROR:
$this->impl->addError($message);
break;
case AbstractLogger::WARNING:
$this->impl->addWarning($message);
break;
case AbstractLogger::NOTICE:
$this->impl->addNotice($message);
break;
case AbstractLogger::INFO:
$this->impl->addInfo($message);
break;
case AbstractLogger::DEBUG:
$this->impl->addDebug($message);
break;
}
}
示例7: run
public function run(Message $message, Discord $discord, WebSocket $webSocket, Logger $log, &$audioStreams, Channel $channel, cURL $curl)
{
$exp = explode(" ", $message->content);
unset($exp[0]);
$youtubeLink = implode(" ", $exp);
// URL Checker
$parts = parse_url($youtubeLink);
if (!stristr($parts["host"], "youtube.com")) {
return $message->reply("Error, you can only use youtube links!");
}
// Generate song md5
$md5 = md5($youtubeLink);
// Now get the mp3 from the cache
$songFile = __DIR__ . "/../../../../../cache/songs/{$md5}.mp3";
$dl = new YoutubeDl(["extract-audio" => true, "audio-format" => "mp3", "audio-quality" => 0, "output" => $songFile]);
$title = "";
try {
$video = $dl->download($youtubeLink);
$title = $video->getTitle();
$log->addNotice("Downloading {$title} from YouTube");
} catch (NotFoundException $e) {
$log->addError("Error: the song was not found: {$e->getMessage()}");
$message->reply("Error: the song was not found: {$e->getMessage()}");
} catch (PrivateVideoException $e) {
$log->addError("Error: song has been made private: {$e->getMessage()}");
$message->reply("Error: song has been made private: {$e->getMessage()}");
} catch (CopyrightException $e) {
$log->addError("Error: song is under copyright: {$e->getMessage()}");
$message->reply("Error: song is under copyright: {$e->getMessage()}");
} catch (\Exception $e) {
$log->addError("Error: {$e->getMessage()}");
$message->reply("Error: {$e->getMessage()}");
}
$webSocket->joinVoiceChannel($channel)->then(function (VoiceClient $vc) use($message, $discord, $webSocket, $log, &$audioStreams, $channel, $curl, $songFile, $title) {
$guildID = $message->getChannelAttribute()->guild_id;
if (file_exists($songFile)) {
// Add this audio stream to the array of audio streams
$audioStreams[$guildID] = $vc;
$vc->setFrameSize(40)->then(function () use($vc, &$audioStreams, $guildID, $songFile, $log, $message, $title, $channel) {
$vc->setBitrate(128000);
$message->reply("Now playing **{$title}** in {$channel->name}");
$vc->playFile($songFile, 2)->done(function () use($vc, &$audioStreams, $guildID) {
unset($audioStreams[$guildID]);
$vc->close();
});
});
}
});
}
示例8: it_correctly_identifies_the_info
/**
* @test
*/
public function it_correctly_identifies_the_info()
{
$bugsnag = new Bugsnag_Client(self::APIKEY);
$logger = new Logger('my_logger');
$logger->pushHandler(new BugsnagHandler(Logger::INFO, true, 'BugsnagMonolog', $bugsnag));
$logger->addInfo('info', ['some' => 'message']);
$logger->addError('error', ['some' => 'message']);
$logger->addAlert('alert', ['some' => 'message']);
$logger->addCritical('critical', ['some' => 'message']);
$logger->addDebug('debug', ['some' => 'message']);
$logger->addWarning('warning', ['some' => 'message']);
$logger->addEmergency('emergency', ['some' => 'message']);
$logger->addNotice('notice', ['some' => 'message']);
$this->assertTrue(true);
}
示例9: saveTaskRun
/**
* Writes log in file. Do NOT actually saves the task run
* @return bool
*/
public function saveTaskRun()
{
//if monolog not found does nothing
if (!class_exists('Monolog\\Logger')) {
return false;
}
$logger = new Logger('cron_logger');
$logger->pushHandler(new RotatingFileHandler($this->logs_folder . $this->log_name));
$task = TaskFile::taskGet($this->task_id);
if (self::RUN_STATUS_STARTED == $this->status) {
$message = 'task ' . $task->getCommand() . ' just started';
} else {
$message = 'task ' . $task->getCommand() . ' ended with status ' . $this->status . ', execution time ' . $this->execution_time . ', output: ' . PHP_EOL . $this->output;
}
return $logger->addNotice($message);
}
示例10: execPlugin
/**
* Execution d'un plugin
*
* @param string $name Nom de l'étape
* @param Command $command Command courante
*
* @return self
* @throws Exception Des plugins
* @throws Stop Lors d'une demande d'arret de l'aspiration
* @throws Abort Pour une annulation de l'ordre d'aspi courant
*/
private function execPlugin($name, Command $command = null)
{
try {
foreach ($this->plugins as $plugin) {
if (method_exists($plugin, $name)) {
$plugin->{$name}($command, $this->curContent, $this);
}
}
} catch (Abort $exc) {
$this->log->addNotice('Annulation ordre', [$command, $exc]);
throw $exc;
} catch (Stop $exc) {
$this->stop();
throw $exc;
}
return $this;
}
示例11: scan
/**
* Scan entire website
* @return void
*/
public function scan()
{
// Add the root URL to the list of pages
if ($this->rootUrl != '*') {
$this->pages[] = $this->rootUrl;
}
// Give feedback on the CLI
$this->logger->addNotice('Scanning ' . $this->rootUrl);
// Current index at $this->pages
$curPageIndex = 0;
// Start looping
while (true) {
// Get the current pageUrl
$curPageUrl = $this->pages[$curPageIndex];
// Scan a single page. Returns the mixed content (if any)
$mixedContent = $this->scanPage($curPageUrl);
// Got mixed content
if ($mixedContent) {
// Add an alert for the URL
$this->logger->addError(sprintf('%05d', $curPageIndex) . ' - ' . $curPageUrl);
foreach ($mixedContent as $url) {
$this->logger->addWarning($url);
}
} else {
$this->logger->addInfo(sprintf('%05d', $curPageIndex) . ' - ' . $curPageUrl);
}
// Done scanning all pages? Then quit! Otherwise: scan the next page
if ($curPageIndex + 1 == sizeof($this->pages)) {
break;
} else {
$curPageIndex++;
}
}
// Give feedback on the CLI
$this->logger->addNotice('Scanned ' . sizeof($this->pages) . ' pages for Mixed Content');
}
示例12: Logger
use sforsman\Rest\Server;
use sforsman\Rest\AbstractJsonService;
use League\Event\Emitter;
use League\Event\AbstractEvent;
use League\Event\CallbackListener;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// Setup a logger
$log = new Logger('API');
$log->pushHandler(new StreamHandler('/tmp/api_log.txt', Logger::WARNING));
// We are interested in some events generated by the server
$emitter = new Emitter();
// This will be emitted right before control is dispatched to the actual service
$callback = function (AbstractEvent $event, $param = null) use($log) {
// In the real world, you would (for an example) validate OAuth2 headers here
$log->addNotice(serialize($param));
};
$emitter->addListener('dispatch', CallbackListener::fromCallable($callback));
// This will be emitted when an exception is going to be processed and "converted" into JSON
$callback = function ($event, $param) use($log) {
$log->addError($param['exception']->getMessage());
};
$emitter->addListener('exception', CallbackListener::fromCallable($callback));
// This will be emitted when an PHP error (warning, notice, fatal) has happened and the processing
$callback = function ($event, $errorStr) use($log) {
$log->addWarning($errorStr);
};
$emitter->addListener('error', CallbackListener::fromCallable($callback));
// Create the actual REST server
$api = new Server($emitter);
// Use the built-in error handlers that prevent any default PHP behavior and ensure all errors are
示例13: matchReportAction
public function matchReportAction(Logger $log, Request $request)
{
$log->addNotice("Match data received from " . $request->getClientIp());
$teamOneBZIDs = $this->params->get('teamOnePlayers');
$teamTwoBZIDs = $this->params->get('teamTwoPlayers');
$teamOnePlayers = $this->bzidsToIdArray($teamOneBZIDs);
$teamTwoPlayers = $this->bzidsToIdArray($teamTwoBZIDs);
$teamOne = $this->getTeam($teamOnePlayers);
$teamTwo = $this->getTeam($teamTwoPlayers);
// If we fail to get the the team ID for either the teams or both reported teams are the same team, we cannot
// report the match due to it being illegal.
// An invalid team could be found in either or both teams, so we need to check both teams and log the match
// failure respectively.
$error = true;
if (!$teamOne->isValid()) {
$log->addNotice("The BZIDs ({$teamOneBZIDs}) were not found on the same team. Match invalidated.");
} elseif (!$teamTwo->isValid()) {
$log->addNotice("The BZIDs ({$teamTwoBZIDs}) were not found on the same team. Match invalidated.");
} else {
$error = false;
}
if ($error) {
throw new ForbiddenException("An invalid player was found during the match. Please message a referee to manually report the match.");
}
if ($teamOne->getId() == $teamTwo->getId()) {
$log->addNotice("The '" . $teamOne->getName() . "' team played against each other in an official match. Match invalidated.");
throw new ForbiddenException("Holy sanity check, Batman! The same team can't play against each other in an official match.");
}
$match = Match::enterMatch($teamOne->getId(), $teamTwo->getId(), $this->params->get('teamOneWins'), $this->params->get('teamTwoWins'), $this->params->get('duration'), null, $this->params->get('matchTime'), $teamOnePlayers, $teamTwoPlayers, $this->params->get('server'), $this->params->get('port'), $this->params->get('replayFile'), $this->params->get('mapPlayed'));
$log->addNotice("Match reported automatically", array('winner' => array('name' => $match->getWinner()->getName(), 'score' => $match->getScore($match->getWinner())), 'loser' => array('name' => $match->getLoser()->getName(), 'score' => $match->getScore($match->getLoser())), 'eloDiff' => $match->getEloDiff()));
// Output the match stats that will be sent back to BZFS
return $match->getName();
}
示例14: notice
public function notice($message, $array = array())
{
$log = new Logger($this->logName);
$log->pushHandler(new StreamHandler($this->logFile, Logger::NOTICE));
$log->addNotice($message, $array);
}
示例15: addNotice
/**
* Adds a log record at the NOTICE level.
*
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
* @static
*/
public static function addNotice($message, $context = array())
{
return \Monolog\Logger::addNotice($message, $context);
}