本文整理汇总了PHP中Logger::logger方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::logger方法的具体用法?PHP Logger::logger怎么用?PHP Logger::logger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::logger方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
private function __construct()
{
// setup file error logging
$file_writer = new Logger_Errorlog();
if (Config::get_optional("DEBUG_LOG") == false) {
$file_writer->addFilter(Zend_Log::INFO);
}
$log = new Zend_Log();
$log->addWriter($file_writer);
// setup email error logging
if (Config::get_optional("log_to_email") == true) {
$mail = new Zend_Mail();
$mail->setFrom(Config::get_mandatory('log_email_from'));
$mail->addTo(Config::get_mandatory('log_email_to'));
// setup email template
$layout = new Zend_Layout();
$layout->setLayoutPath(DOCUMENT_ROOT . Config::get_mandatory("log_email_template"));
$layout->setLayout('error-logger');
$layout_formatter = new Zend_Log_Formatter_Simple('<li>.' . Zend_Log_Formatter_Simple::DEFAULT_FORMAT . '</li>');
// Use default HTML layout.
$email_writer = new Zend_Log_Writer_Mail($mail, $layout);
$email_writer->setLayoutFormatter($layout_formatter);
$email_writer->setSubjectPrependText(Config::get_mandatory('log_email_subject_prepend'));
$email_writer->addFilter(Zend_Log::ERR);
$log->addWriter($email_writer);
}
self::$logger = $log;
}
示例2: addLogger
public static function addLogger($logger, $reset = false)
{
if ($reset) {
self::$logger = array();
}
self::$logger[] = $logger;
self::$enabled = true;
}
示例3: L
public static function L($logpath = '', $clear = false)
{
if (self::$logger === null) {
self::$logger = new Logger($logpath, $clear);
}
self::$logger->setClear($clear);
return self::$logger;
}
示例4: addLogger
public static function addLogger($logger, $reset = false)
{
if ($reset) {
self::$logger = array();
}
self::$logger[] = $logger;
self::$dummyMode = false;
}
示例5:
static function __callStatic($name, $args)
{
if (!self::$logger) {
self::$logger = new Monolog\Logger('debug');
self::$logger->pushHandler(new Monolog\Handler\StreamHandler(__DIR__ . '/../log/debug.log'));
}
return call_user_func_array([self::$logger, $name], $args);
}
示例6: addLogger
/**
* @param $logger
* @param bool|false $reset
* @throws Exception
*/
public static function addLogger($logger, $reset = false)
{
if (!$logger instanceof \Zend_Log && !$logger instanceof \Psr\Log\LoggerInterface) {
throw new \Exception("Logger must be either an instance of Zend_Log or needs to implement Psr\\Log\\LoggerInterface");
}
if ($reset) {
self::$logger = array();
}
self::$logger[] = $logger;
self::$enabled = true;
}
示例7: getLogger
/**
* Retrieve the singleton logger instance, creating it if necessary.
*
* @return Returns the logger.
*/
public static function getLogger()
{
// Make sure the logger has been created.
if (self::$logger === null) {
// Define the logging format.
$format = '%timestamp% %priorityName% %message%' . PHP_EOL;
// Create the formatter.
$formatter = new Zend_Log_Formatter_Simple($format);
// Create the new writer for the log file.
$writer = new Zend_Log_Writer_Stream(Bootstrap::$root . '/logs/app.log');
// Set the writer format.
$writer->setFormatter($formatter);
// Create the logger.
self::$logger = new Zend_Log($writer);
}
// Return the logger.
return self::$logger;
}