48 $this->logFile = $config->
getPathValue(
'loggingdir',
'log/').
49 $config->
getString(
'logging.logfile',
'simplesamlphp.log');
50 $this->processname = $config->
getString(
'logging.processname',
'SimpleSAMLphp');
52 if (@file_exists($this->logFile)) {
53 if (!@is_writeable($this->logFile)) {
54 throw new \Exception(
"Could not write to logfile: ".$this->logFile);
57 if (!@touch($this->logFile)) {
59 "Could not create logfile: ".$this->logFile.
60 " The logging directory is not writable for the web server user." 86 public function log($level, $string)
88 if (!is_null($this->logFile)) {
90 $levelName = sprintf(
'UNKNOWN%d', $level);
91 if (array_key_exists($level, self::$levelNames)) {
92 $levelName = self::$levelNames[$level];
96 $replacements =
array($this->processname, $levelName);
99 if (preg_match(
'/%date(?:\{([^\}]+)\})?/', $this->
format, $matches)) {
101 if (isset($matches[1])) {
106 array_push($replacements, strftime(
$format));
109 $string = str_replace(
$formats, $replacements, $string);
110 file_put_contents($this->logFile, $string.PHP_EOL, FILE_APPEND);
__construct(\SimpleSAML_Configuration $config)
Build a new logging handler based on files.
getPathValue($name, $default=null)
Retrieve a path configuration option set in config.php.
setLogFormat($format)
Set the format desired for the logs.
static initTimezone()
Initialize the timezone.
log($level, $string)
Log a message to the log file.
Create styles array
The data for the language used.
static $levelNames
This array contains the mappings from syslog log levels to names.
Write to Excel2007 format
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.