Skip to content
Snippets Groups Projects
Commit e570cf86 authored by Olav Morken's avatar Olav Morken
Browse files

SimpleSAML_Logger: Fix log levels on Windows.

PHP on Windows does not differentiate between all the different log
levels, which means that attempting to specify the 'logging.level'
option will not work properly. This patch replaces the use of the
syslog constants with custom constants.

Thanks to Ryan Panning for fixing this bug!

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2981 44740490-163a-0410-bde0-09ae8108e29a
parent 3a08025d
No related branches found
No related tags found
No related merge requests found
......@@ -104,18 +104,18 @@ $config = array (
* Logging.
*
* define the minimum log level to log
* LOG_ERR No statistics, only errors
* LOG_WARNING No statistics, only warnings/errors
* LOG_NOTICE Statistics and errors
* LOG_INFO Verbose logs
* LOG_DEBUG Full debug logs - not reccomended for production
* SimpleSAML_Logger::ERR No statistics, only errors
* SimpleSAML_Logger::WARNING No statistics, only warnings/errors
* SimpleSAML_Logger::NOTICE Statistics and errors
* SimpleSAML_Logger::INFO Verbose logs
* SimpleSAML_Logger::DEBUG Full debug logs - not reccomended for production
*
* Choose logging handler.
*
* Options: [syslog,file,errorlog]
*
*/
'logging.level' => LOG_NOTICE,
'logging.level' => SimpleSAML_Logger::NOTICE,
'logging.handler' => 'syslog',
/*
......
......@@ -50,25 +50,33 @@ class SimpleSAML_Logger {
* LOG_DEBUG Full debug logs - not reccomended for production
*/
const EMERG = 0;
const ALERT = 1;
const CRIT = 2;
const ERR = 3;
const WARNING = 4;
const NOTICE = 5;
const INFO = 6;
const DEBUG = 7;
static function emergency($string) {
self::log_internal(LOG_EMERG,$string);
self::log_internal(self::EMERG,$string);
}
static function critical($string) {
self::log_internal(LOG_CRIT,$string);
self::log_internal(self::CRIT,$string);
}
static function alert($string) {
self::log_internal(LOG_ALERT,$string);
self::log_internal(self::ALERT,$string);
}
static function error($string) {
self::log_internal(LOG_ERR,$string);
self::log_internal(self::ERR,$string);
}
static function warning($string) {
self::log_internal(LOG_WARNING,$string);
self::log_internal(self::WARNING,$string);
}
/**
......@@ -76,7 +84,7 @@ class SimpleSAML_Logger {
* this level for other kind of log messages.
*/
static function notice($string) {
self::log_internal(LOG_NOTICE,$string);
self::log_internal(self::NOTICE,$string);
}
/**
......@@ -84,7 +92,7 @@ class SimpleSAML_Logger {
* for tracing a session.
*/
static function info($string) {
self::log_internal(LOG_INFO,$string);
self::log_internal(self::INFO,$string);
}
/**
......@@ -92,14 +100,14 @@ class SimpleSAML_Logger {
* what is neccessary for a production system.
*/
static function debug($string) {
self::log_internal(LOG_DEBUG,$string);
self::log_internal(self::DEBUG,$string);
}
/**
* Statisitics
*/
static function stats($string) {
self::log_internal(LOG_NOTICE,$string,true);
self::log_internal(self::NOTICE,$string,true);
}
......@@ -119,7 +127,7 @@ class SimpleSAML_Logger {
/*
* setting minimum log_level
*/
self::$logLevel = $config->getInteger('logging.level',LOG_INFO);
self::$logLevel = $config->getInteger('logging.level',self::INFO);
$handler = strtolower($handler);
......
......@@ -15,14 +15,14 @@ class SimpleSAML_Logger_LoggingHandlerErrorLog implements SimpleSAML_Logger_Logg
* This array contains the mappings from syslog loglevel to names.
*/
private static $levelNames = array(
LOG_EMERG => 'EMERG',
LOG_ALERT => 'ALERT',
LOG_CRIT => 'CRIT',
LOG_ERR => 'ERR',
LOG_WARNING => 'WARNING',
LOG_NOTICE => 'NOTICE',
LOG_INFO => 'INFO',
LOG_DEBUG => 'DEBUG',
SimpleSAML_Logger::EMERG => 'EMERG',
SimpleSAML_Logger::ALERT => 'ALERT',
SimpleSAML_Logger::CRIT => 'CRIT',
SimpleSAML_Logger::ERR => 'ERR',
SimpleSAML_Logger::WARNING => 'WARNING',
SimpleSAML_Logger::NOTICE => 'NOTICE',
SimpleSAML_Logger::INFO => 'INFO',
SimpleSAML_Logger::DEBUG => 'DEBUG',
);
......
......@@ -16,14 +16,14 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH
* more or less directly from SimpleSAML_Logger_LoggingHandlerErrorLog.
*/
private static $levelNames = array(
LOG_EMERG => 'EMERGENCY',
LOG_ALERT => 'ALERT',
LOG_CRIT => 'CRITICAL',
LOG_ERR => 'ERROR',
LOG_WARNING => 'WARNING',
LOG_NOTICE => 'NOTICE',
LOG_INFO => 'INFO',
LOG_DEBUG => 'DEBUG',
SimpleSAML_Logger::EMERG => 'EMERGENCY',
SimpleSAML_Logger::ALERT => 'ALERT',
SimpleSAML_Logger::CRIT => 'CRITICAL',
SimpleSAML_Logger::ERR => 'ERROR',
SimpleSAML_Logger::WARNING => 'WARNING',
SimpleSAML_Logger::NOTICE => 'NOTICE',
SimpleSAML_Logger::INFO => 'INFO',
SimpleSAML_Logger::DEBUG => 'DEBUG',
);
private $logFile = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment