本文整理汇总了PHP中Logger::addLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::addLogger方法的具体用法?PHP Logger::addLogger怎么用?PHP Logger::addLogger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger::addLogger方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeLogging
/**
* Initialize logging
*/
protected function initializeLogging()
{
$logger = $this->getLogger();
// hook logger into pimcore
\Logger::addLogger($logger);
// set all priorities
\Logger::setVerbosePriorities();
}
示例2: initializeLogging
/**
* Initialize logging
*/
protected function initializeLogging()
{
$logger = $this->getLogger();
// hook logger into pimcore
\Logger::addLogger($logger);
if ($this->output->isVerbose()) {
\Logger::setPriorities(["info", "notice", "warning", "error", "critical", "alert", "emergency"]);
}
// set all priorities
if ($this->output->isDebug()) {
\Logger::setVerbosePriorities();
}
}
示例3: initializePimcoreLogging
/**
* Hook into the pimcore logger using the Pimcore\Console\Log\Writer
*
* @param int $filterPriority
*/
protected function initializePimcoreLogging($filterPriority = \Zend_Log::INFO)
{
$writer = new Writer($this->output);
$logger = new \Zend_Log($writer);
if ($this->output->isVerbose()) {
$filterPriority = null;
}
if (null !== $filterPriority) {
$logger->addFilter(new \Zend_Log_Filter_Priority($filterPriority));
}
// the filter handles verbosity
\Logger::setVerbosePriorities();
\Logger::addLogger($logger);
}
示例4: catch
echo $e->getMessage();
}
try {
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getMessage();
}
// display help message
if ($opts->getOption("help")) {
echo $opts->getUsageMessage();
exit;
}
if ($opts->getOption("verbose")) {
$writer = new Zend_Log_Writer_Stream('php://output');
$logger = new Zend_Log($writer);
Logger::addLogger($logger);
// set all priorities
Logger::setPriorities(array(Zend_Log::DEBUG, Zend_Log::INFO, Zend_Log::NOTICE, Zend_Log::WARN, Zend_Log::ERR, Zend_Log::CRIT, Zend_Log::ALERT, Zend_Log::EMERG));
}
$forceType = null;
if ($opts->getOption("manager")) {
$forceType = $opts->getOption("manager");
}
$validJobs = array();
if ($opts->getOption("job")) {
$validJobs = explode(",", $opts->getOption("job"));
}
// create manager
$manager = Schedule_Manager_Factory::getManager("maintenance.pid", $forceType);
$manager->setValidJobs($validJobs);
// register scheduled tasks
示例5: initLogger
/**
* @static
*
*/
public static function initLogger()
{
// for forks, etc ...
\Logger::resetLoggers();
// try to load configuration
$conf = Config::getSystemConfig();
if ($conf) {
// redirect php error_log to /website/var/log/php.log
if ($conf->general->custom_php_logfile) {
$phpLog = PIMCORE_LOG_DIRECTORY . "/php.log";
if (!file_exists($phpLog)) {
touch($phpLog);
}
if (is_writable($phpLog)) {
ini_set("error_log", $phpLog);
ini_set("log_errors", "1");
}
}
}
if (!is_file(PIMCORE_LOG_DEBUG)) {
if (is_writable(dirname(PIMCORE_LOG_DEBUG))) {
File::put(PIMCORE_LOG_DEBUG, "AUTOCREATE\n");
}
}
$prioMapping = array("debug" => \Zend_Log::DEBUG, "info" => \Zend_Log::INFO, "notice" => \Zend_Log::NOTICE, "warning" => \Zend_Log::WARN, "error" => \Zend_Log::ERR, "critical" => \Zend_Log::CRIT, "alert" => \Zend_Log::ALERT, "emergency" => \Zend_Log::EMERG);
$prios = array();
if ($conf && $conf->general->debugloglevel) {
$prioMapping = array_reverse($prioMapping);
foreach ($prioMapping as $level => $state) {
$prios[] = $prioMapping[$level];
if ($level == $conf->general->debugloglevel) {
break;
}
}
} else {
// log everything if config isn't loaded (eg. at the installer)
foreach ($prioMapping as $p) {
$prios[] = $p;
}
}
\Logger::setPriorities($prios);
if (is_writable(PIMCORE_LOG_DEBUG)) {
// check for big logfile, empty it if it's bigger than about 200M
if (filesize(PIMCORE_LOG_DEBUG) > 200000000) {
rename(PIMCORE_LOG_DEBUG, PIMCORE_LOG_DEBUG . "-archive-" . date("m-d-Y-H-i"));
// archive log (will be cleaned up by maintenance)
File::put(PIMCORE_LOG_DEBUG, "");
}
if (!empty($prios)) {
$writerFile = new \Zend_Log_Writer_Stream(PIMCORE_LOG_DEBUG);
$loggerFile = new \Zend_Log($writerFile);
\Logger::addLogger($loggerFile);
}
$conf = Config::getSystemConfig();
if ($conf) {
//email logger
if (!empty($conf->general->logrecipient)) {
$user = User::getById($conf->general->logrecipient);
if ($user instanceof User && $user->isAdmin()) {
$email = $user->getEmail();
if (!empty($email)) {
$mail = Tool::getMail(array($email), "pimcore log notification");
$mail->setIgnoreDebugMode(true);
if (!is_dir(PIMCORE_LOG_MAIL_TEMP)) {
File::mkdir(PIMCORE_LOG_MAIL_TEMP);
}
$tempfile = PIMCORE_LOG_MAIL_TEMP . "/log-" . uniqid() . ".log";
$writerEmail = new \Pimcore\Log\Writer\Mail($tempfile, $mail);
$loggerEmail = new \Zend_Log($writerEmail);
\Logger::addLogger($loggerEmail);
}
}
}
}
} else {
// try to use syslog instead
try {
$writerSyslog = new \Zend_Log_Writer_Syslog(array('application' => 'pimcore'));
$loggerSyslog = new \Zend_Log($writerSyslog);
\Logger::addLogger($loggerSyslog);
} catch (\Exception $e) {
}
}
if (array_key_exists("pimcore_log", $_REQUEST) && self::inDebugMode()) {
if (empty($_REQUEST["pimcore_log"])) {
$requestLogName = date("Y-m-d_H-i-s");
} else {
$requestLogName = $_REQUEST["pimcore_log"];
}
$requestLogFile = dirname(PIMCORE_LOG_DEBUG) . "/request-" . $requestLogName . ".log";
if (!file_exists($requestLogFile)) {
File::put($requestLogFile, "");
}
$writerRequestLog = new \Zend_Log_Writer_Stream($requestLogFile);
$loggerRequest = new \Zend_Log($writerRequestLog);
\Logger::addLogger($loggerRequest);
//.........这里部分代码省略.........
示例6: initLogger
/**
* @static
*
*/
public static function initLogger()
{
// try to load configuration
$conf = Pimcore_Config::getSystemConfig();
if ($conf) {
//firephp logger
if ($conf->general->firephp) {
$writerFirebug = new Zend_Log_Writer_Firebug();
$loggerFirebug = new Zend_Log($writerFirebug);
Logger::addLogger($loggerFirebug);
}
}
if (!is_file(PIMCORE_LOG_DEBUG)) {
if (is_writable(dirname(PIMCORE_LOG_DEBUG))) {
file_put_contents(PIMCORE_LOG_DEBUG, "AUTOCREATE\n");
}
}
if (is_writable(PIMCORE_LOG_DEBUG)) {
// check for big logfile, empty it if it's bigger than about 200M
if (filesize(PIMCORE_LOG_DEBUG) > 200000000) {
file_put_contents(PIMCORE_LOG_DEBUG, "");
}
$prioMapping = array("debug" => Zend_Log::DEBUG, "info" => Zend_Log::INFO, "notice" => Zend_Log::NOTICE, "warning" => Zend_Log::WARN, "error" => Zend_Log::ERR, "critical" => Zend_Log::CRIT, "alert" => Zend_Log::ALERT, "emergency" => Zend_Log::EMERG);
$prioConf = array();
$prios = array();
if ($conf && $conf->general->loglevel) {
$prioConf = $conf->general->loglevel->toArray();
if (is_array($prioConf)) {
foreach ($prioConf as $level => $state) {
if ($state) {
$prios[] = $prioMapping[$level];
}
}
}
} else {
// log everything if config isn't loaded (eg. at the installer)
foreach ($prioMapping as $p) {
$prios[] = $p;
}
}
if (!empty($prios)) {
$writerFile = new Zend_Log_Writer_Stream(PIMCORE_LOG_DEBUG);
$loggerFile = new Zend_Log($writerFile);
Logger::addLogger($loggerFile);
Logger::setPriorities($prios);
}
$conf = Pimcore_Config::getSystemConfig();
if ($conf) {
//email logger
if (!empty($conf->general->logrecipient)) {
$user = User::getById($conf->general->logrecipient);
if ($user instanceof User && $user->isAdmin()) {
$email = $user->getEmail();
if (!empty($email)) {
$mail = Pimcore_Tool::getMail(array($email), "pimcore log notification");
if (!is_dir(PIMCORE_LOG_MAIL_TEMP)) {
mkdir(PIMCORE_LOG_MAIL_TEMP, 0755, true);
}
$tempfile = PIMCORE_LOG_MAIL_TEMP . "/log-" . uniqid() . ".log";
$writerEmail = new Pimcore_Log_Writer_Mail($tempfile, $mail);
$loggerEmail = new Zend_Log($writerEmail);
Logger::addLogger($loggerEmail);
}
}
}
}
}
}
示例7: initLogger
/**
* @static
*
*/
public static function initLogger()
{
// for forks, etc ...
\Logger::resetLoggers();
// try to load configuration
$conf = Config::getSystemConfig();
if ($conf) {
// redirect php error_log to /website/var/log/php.log
if ($conf->general->custom_php_logfile) {
$phpLog = PIMCORE_LOG_DIRECTORY . "/php.log";
if (!file_exists($phpLog)) {
touch($phpLog);
}
if (is_writable($phpLog)) {
ini_set("error_log", $phpLog);
ini_set("log_errors", "1");
}
}
}
if (!is_file(PIMCORE_LOG_DEBUG)) {
if (is_writable(dirname(PIMCORE_LOG_DEBUG))) {
File::put(PIMCORE_LOG_DEBUG, "AUTOCREATE\n");
}
}
$prios = [];
$availablePrios = \Logger::getAvailablePriorities();
if ($conf && $conf->general->debugloglevel) {
foreach ($availablePrios as $level) {
$prios[] = $level;
if ($level == $conf->general->debugloglevel) {
break;
}
}
\Logger::setPriorities($prios);
} else {
\Logger::setVerbosePriorities();
}
if (is_writable(PIMCORE_LOG_DEBUG)) {
// check for big logfile, empty it if it's bigger than about 200M
if (filesize(PIMCORE_LOG_DEBUG) > 200000000) {
rename(PIMCORE_LOG_DEBUG, PIMCORE_LOG_DEBUG . "-archive-" . date("m-d-Y-H-i"));
// archive log (will be cleaned up by maintenance)
File::put(PIMCORE_LOG_DEBUG, "");
}
// set default core logger (debug.log)
if (!empty($prios)) {
$loggerFile = new \Monolog\Logger('core');
$loggerFile->pushHandler(new \Monolog\Handler\StreamHandler(PIMCORE_LOG_DEBUG));
\Logger::addLogger($loggerFile);
}
$conf = Config::getSystemConfig();
if ($conf) {
//email logger
if (!empty($conf->general->logrecipient)) {
$user = User::getById($conf->general->logrecipient);
if ($user instanceof User && $user->isAdmin()) {
$email = $user->getEmail();
if (!empty($email)) {
$loggerMail = new \Monolog\Logger('email');
$mailHandler = new \Pimcore\Log\Handler\Mail($email);
$loggerMail->pushHandler(new \Monolog\Handler\BufferHandler($mailHandler));
\Logger::addLogger($loggerMail);
}
}
}
}
} else {
// try to use syslog instead
try {
$loggerSyslog = new \Monolog\Logger('core');
$loggerSyslog->pushHandler(new \Monolog\Handler\SyslogHandler("pimcore"));
\Logger::addLogger($loggerSyslog);
} catch (\Exception $e) {
// nothing to do here
}
}
// special request log -> if parameter pimcore_log is set
if (array_key_exists("pimcore_log", $_REQUEST) && self::inDebugMode()) {
if (empty($_REQUEST["pimcore_log"])) {
$requestLogName = date("Y-m-d_H-i-s");
} else {
$requestLogName = $_REQUEST["pimcore_log"];
}
$requestLogFile = dirname(PIMCORE_LOG_DEBUG) . "/request-" . $requestLogName . ".log";
if (!file_exists($requestLogFile)) {
File::put($requestLogFile, "");
}
$loggerRequest = new \Monolog\Logger('request');
$loggerRequest->pushHandler(new \Monolog\Handler\StreamHandler($requestLogFile));
\Logger::addLogger($loggerRequest);
\Logger::setVerbosePriorities();
}
}