本文整理汇总了PHP中Zend\Log\Logger::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::log方法的具体用法?PHP Logger::log怎么用?PHP Logger::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Log\Logger
的用法示例。
在下文中一共展示了Logger::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: log
protected function log($priority, $message)
{
if ($this->logger !== null) {
$this->logger->log($priority, $message);
}
return $this;
}
示例2: indexAction
public function indexAction()
{
$request = $this->getRequest();
$logContent = '';
// initialize when no submit anymore
$data = [];
$data['logmessage'] = $this->form->get('logmessage')->getValue();
if ($request->isPost()) {
$this->form->setData($request->getPost());
if ($this->form->isValid()) {
$data = $this->form->getData();
$this->loggerPriority = $data['logpriority'];
if ($data['logformat'] !== 'simple') {
$this->loggerConfig['writers'][0]['options']['formatter']['name'] = $data['logformat'];
unset($this->loggerConfig['writers'][0]['options']['formatter']['options']);
}
}
}
$logger = new Logger($this->loggerConfig);
// save log data to buffer and make it variable
ob_start();
$logger->log((int) $this->loggerPriority, $data['logmessage']);
$logContent = ob_get_clean();
return new ViewModel(['form' => $this->form, 'logContent' => $logContent]);
}
示例3: logInfo
public function logInfo($message)
{
$log = new Logger();
$writer = new Stream('pronoi.log');
$log->addWriter($writer);
$log->log(Logger::INFO, $message);
}
示例4: log
public function log($message, $priority, $extras = null, $displayScreen = false)
{
if ($displayScreen) {
echo $message . PHP_EOL;
}
parent::log($message, $priority, $extras);
}
示例5: logTirage
public function logTirage($randomize)
{
$path = __DIR__ . '/../../../../../data/log/log_tirage.php';
$logger = new Logger();
$writer = new Stream($path);
$logger->addWriter($writer);
$logger->log(Logger::INFO, $randomize);
}
示例6: testZf3960
/**
* Test for ZF-3960
*
* Zend_Log_Writer_Firebug should be automatically disabled when
* run from the command line
*/
public function testZf3960()
{
Channel\HttpHeaders::destroyInstance();
FirePhp::destroyInstance();
$log = new Logger();
$writerFirebug = new FirebugWriter();
$log->addWriter($writerFirebug);
$log->log('hi', 2);
}
示例7: log
public function log($priority, $message, $extra = array(), $context = false)
{
// Prepend the context
if ($context === true) {
$context = $this->parseContext();
}
$message = empty($context) ? $message : $context . ' : ' . $message;
// Log the message
parent::log($priority, $message, $extra);
}
示例8: log
public function log($priority, $message, $extra = array())
{
// add details to $extra
$trace = debug_backtrace();
$caller = $trace[1];
$prevCaller = $trace[2];
// simplify $caller
unset($caller['object'], $caller['type'], $caller['args']);
// overriding function and class from $prevCaller
$caller['function'] = $prevCaller['function'];
$caller['class'] = $prevCaller['class'];
$extra = array_merge($extra, $caller);
if (is_string($message)) {
$message = str_replace('<', '--bigger than--', $message);
}
return parent::log($priority, $message, $extra);
}
示例9: registerExceptionHandler
/**
* Registers an exception handler.
*
* @param Logger $logger
*
* @return bool Returna always false to enable other handlers, including the default
*
* @throws Exception\InvalidArgumentException if logger is null
*/
public static function registerExceptionHandler(Logger $logger)
{
// Only register once per instance
if (self::$registeredExceptionHandler) {
return false;
}
if ($logger === null) {
throw new \Zend\Log\Exception\InvalidArgumentException('Invalid Logger specified');
}
set_exception_handler(function (\Exception $exception) use($logger) {
$msg = '';
$prev = $exception->getPrevious();
while ($prev !== null) {
$msg .= PHP_EOL . 'Previous: ' . $prev->getMessage() . ' in ' . $prev->getFile() . ' in line ' . $prev->getLine() . '.';
$prev = $prev->getPrevious();
}
$logger->log(ErrorLogger::ERR, 'Exception: ' . $exception->getMessage() . ' in ' . $exception->getFile() . ' in line ' . $exception->getLine() . '.' . $msg . PHP_EOL . 'Trace:' . PHP_EOL . $exception->getTraceAsString());
});
self::$registeredExceptionHandler = true;
return false;
}
示例10: debug
public function debug($message)
{
return parent::log($message, 7);
}
示例11: SplPriorityQueue
$processor = PROCESSOR_PDFTK;
// Number of documents (populated with random strings) to concatenate.
$iterations = 3;
// -----------------------------------------------------------------------------
// Logger to output status messages
$writerQueue = new SplPriorityQueue();
$writerQueue->insert(new Writer('php://stdout'), 1);
$logger = new Logger();
$logger->setWriters($writerQueue);
// -----------------------------------------------------------------------------
// Create temporary directory
$tempDirectory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . md5(rand(1, 10000) . __FILE__);
if (is_dir($tempDirectory)) {
recursiveRemoveDirectory($tempDirectory);
}
$logger->log(Logger::INFO, sprintf('Making temporary directory %s.', $tempDirectory));
mkdir($tempDirectory);
// -----------------------------------------------------------------------------
// Generate temporary documents
$tempFilenames = array();
$mailMerge = new MailMerge();
$mailMerge->setUsername(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_USERNAME)->setPassword(DEMOS_ZENDSERVICE_LIVEDOCX_FREE_PASSWORD)->setService(MailMerge::SERVICE_FREE);
// for LiveDocx Premium, use MailMerge::SERVICE_PREMIUM;
$mailMerge->setLocalTemplate('template.docx');
for ($iteration = 1; $iteration <= $iterations; $iteration++) {
$tempFilename = sprintf('%s%s%010s.pdf', $tempDirectory, DIRECTORY_SEPARATOR, $iteration);
$tempFilenames[] = $tempFilename;
$mailMerge->assign('software', randomString())->assign('licensee', randomString())->assign('company', randomString())->assign('date', Helper::currentDate())->assign('time', Helper::currentTime())->assign('city', randomString())->assign('country', randomString());
$mailMerge->createDocument();
file_put_contents($tempFilename, $mailMerge->retrieveDocument('pdf'));
$logger->log(Logger::INFO, sprintf('Generating temporary document %s.', $tempFilename));
示例12: log
/**
*
* @param EventInterface $event
*/
public function log(EventInterface $event)
{
$message = $event->getParam('message', 'No message provided');
$priority = $event->getParam('priority', Logger::INFO);
$this->logger->log($priority, $message);
}
示例13: onEvent
public function onEvent(EventInterface $event)
{
if ($event instanceof LogEvent) {
$this->logger->log($event->getPriority(), $event->getMessage(), $event->getParams());
}
}
示例14: log
/**
* @param int $priority
* @param mixed $message
* @param array $extra
*
* @return ZendLogger
*/
public final function log($priority, $message, $extra = array())
{
$customExtra = array('Zf2Logger' => array('sessionId' => session_id(), 'host' => !empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'CLI', 'ip' => !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unavailable'));
return parent::log($priority, $message, array_merge($extra, $customExtra, $this->customExtra));
}
示例15: testPriorityDuplicates
/**
* @group ZF-10170
*/
public function testPriorityDuplicates()
{
$logger = new Logger();
$mock = new Log\Writer\Mock();
$logger->addWriter($mock);
try {
$logger->addPriority('emerg', 8);
$this->fail();
} catch (\Exception $e) {
$this->assertType('Zend\\Log\\Exception', $e);
$this->assertEquals('Existing priorities cannot be overwritten', $e->getMessage());
}
try {
$logger->log('zf10170', 0);
$logger->log('clone zf10170', 8);
$this->fail();
} catch (\Exception $e) {
$this->assertType('Zend\\Log\\Exception', $e);
$this->assertEquals('Bad log priority', $e->getMessage());
}
$this->assertEquals(0, $mock->events[0]['priority']);
$this->assertEquals('EMERG', $mock->events[0]['priorityName']);
$this->assertFalse(array_key_exists(1, $mock->events));
}