Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
c9bc1bd3
Commit
c9bc1bd3
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Minor enhancements to SimpleSAML_Logger.
parent
2ec19aab
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SimpleSAML/Logger.php
+32
-15
32 additions, 15 deletions
lib/SimpleSAML/Logger.php
with
32 additions
and
15 deletions
lib/SimpleSAML/Logger.php
+
32
−
15
View file @
c9bc1bd3
<?php
<?php
/**
/**
* The main logger class for SimpleSAMLphp.
* The main logger class for SimpleSAMLphp.
*
*
* @author Lasse Birnbaum Jensen, SDU.
* @author Lasse Birnbaum Jensen, SDU.
* @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
* @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
* @package
s
impleSAMLphp
* @package
S
impleSAMLphp
* @version $ID$
* @version $ID$
*/
*/
class
SimpleSAML_Logger
class
SimpleSAML_Logger
{
{
private
static
$loggingHandler
=
NULL
;
private
static
$logLevel
=
NULL
;
/**
private
static
$captureLog
=
FALSE
;
* @var SimpleSAML_Logger_LoggingHandler|false|null
*/
private
static
$loggingHandler
=
null
;
/**
* @var integer|null
*/
private
static
$logLevel
=
null
;
/**
* @var boolean
*/
private
static
$captureLog
=
false
;
/**
* @var array
*/
private
static
$capturedLog
=
array
();
private
static
$capturedLog
=
array
();
/**
/**
...
@@ -34,7 +50,7 @@ class SimpleSAML_Logger
...
@@ -34,7 +50,7 @@ class SimpleSAML_Logger
* This variable holds the track ID we have retrieved from the session class. It can also be NULL, in which case
* This variable holds the track ID we have retrieved from the session class. It can also be NULL, in which case
* we haven't fetched the track ID yet, or TRACKID_FETCHING, which means that we are fetching the track ID now.
* we haven't fetched the track ID yet, or TRACKID_FETCHING, which means that we are fetching the track ID now.
*/
*/
private
static
$trackid
=
NULL
;
private
static
$trackid
=
null
;
/**
/**
* This variable holds the format used to log any message. Its use varies depending on the log handler used (for
* This variable holds the format used to log any message. Its use varies depending on the log handler used (for
...
@@ -129,6 +145,7 @@ class SimpleSAML_Logger
...
@@ -129,6 +145,7 @@ class SimpleSAML_Logger
self
::
log
(
self
::
WARNING
,
$string
);
self
::
log
(
self
::
WARNING
,
$string
);
}
}
/**
/**
* We reserve the notice level for statistics, so do not use this level for other kind of log messages.
* We reserve the notice level for statistics, so do not use this level for other kind of log messages.
*
*
...
@@ -170,7 +187,7 @@ class SimpleSAML_Logger
...
@@ -170,7 +187,7 @@ class SimpleSAML_Logger
*/
*/
public
static
function
stats
(
$string
)
public
static
function
stats
(
$string
)
{
{
self
::
log
(
self
::
NOTICE
,
$string
,
TRUE
);
self
::
log
(
self
::
NOTICE
,
$string
,
true
);
}
}
...
@@ -179,7 +196,7 @@ class SimpleSAML_Logger
...
@@ -179,7 +196,7 @@ class SimpleSAML_Logger
*
*
* @var boolean $val Whether to capture logs or not. Defaults to TRUE.
* @var boolean $val Whether to capture logs or not. Defaults to TRUE.
*/
*/
public
static
function
setCaptureLog
(
$val
=
TRUE
)
public
static
function
setCaptureLog
(
$val
=
true
)
{
{
self
::
$captureLog
=
$val
;
self
::
$captureLog
=
$val
;
}
}
...
@@ -197,7 +214,7 @@ class SimpleSAML_Logger
...
@@ -197,7 +214,7 @@ class SimpleSAML_Logger
private
static
function
createLoggingHandler
()
private
static
function
createLoggingHandler
()
{
{
// set to FALSE to indicate that it is being initialized
// set to FALSE to indicate that it is being initialized
self
::
$loggingHandler
=
FALSE
;
self
::
$loggingHandler
=
false
;
// get the configuration
// get the configuration
$config
=
SimpleSAML_Configuration
::
getInstance
();
$config
=
SimpleSAML_Configuration
::
getInstance
();
...
@@ -219,7 +236,7 @@ class SimpleSAML_Logger
...
@@ -219,7 +236,7 @@ class SimpleSAML_Logger
$sh
=
new
SimpleSAML_Logger_LoggingHandlerErrorLog
();
$sh
=
new
SimpleSAML_Logger_LoggingHandlerErrorLog
();
}
else
{
}
else
{
throw
new
Exception
(
throw
new
Exception
(
'Invalid value for the [logging.handler] configuration option. Unknown handler: '
.
$handler
'Invalid value for the [logging.handler] configuration option. Unknown handler: '
.
$handler
);
);
}
}
...
@@ -231,14 +248,14 @@ class SimpleSAML_Logger
...
@@ -231,14 +248,14 @@ class SimpleSAML_Logger
}
}
private
static
function
log
(
$level
,
$string
,
$statsLog
=
FALSE
)
private
static
function
log
(
$level
,
$string
,
$statsLog
=
false
)
{
{
if
(
php_sapi_name
()
===
'cli'
||
defined
(
'STDIN'
))
{
if
(
php_sapi_name
()
===
'cli'
||
defined
(
'STDIN'
))
{
// we are being executed from the CLI, nowhere to log
// we are being executed from the CLI, nowhere to log
return
;
return
;
}
}
if
(
self
::
$loggingHandler
===
NULL
)
{
if
(
self
::
$loggingHandler
===
null
)
{
/* Initialize logging. */
/* Initialize logging. */
self
::
createLoggingHandler
();
self
::
createLoggingHandler
();
...
@@ -249,7 +266,7 @@ class SimpleSAML_Logger
...
@@ -249,7 +266,7 @@ class SimpleSAML_Logger
self
::
log
(
$msg
[
'level'
],
$msg
[
'string'
],
$msg
[
'statsLog'
]);
self
::
log
(
$msg
[
'level'
],
$msg
[
'string'
],
$msg
[
'statsLog'
]);
}
}
}
}
}
elseif
(
self
::
$loggingHandler
===
FALSE
)
{
}
elseif
(
self
::
$loggingHandler
===
false
)
{
// some error occurred while initializing logging
// some error occurred while initializing logging
if
(
empty
(
self
::
$earlyLog
))
{
if
(
empty
(
self
::
$earlyLog
))
{
// this is the first message
// this is the first message
...
@@ -262,7 +279,7 @@ class SimpleSAML_Logger
...
@@ -262,7 +279,7 @@ class SimpleSAML_Logger
}
}
if
(
self
::
$captureLog
)
{
if
(
self
::
$captureLog
)
{
$ts
=
microtime
(
TRUE
);
$ts
=
microtime
(
true
);
$msecs
=
(
int
)
((
$ts
-
(
int
)
$ts
)
*
1000
);
$msecs
=
(
int
)
((
$ts
-
(
int
)
$ts
)
*
1000
);
$ts
=
GMdate
(
'H:i:s'
,
$ts
)
.
sprintf
(
'.%03d'
,
$msecs
)
.
'Z'
;
$ts
=
GMdate
(
'H:i:s'
,
$ts
)
.
sprintf
(
'.%03d'
,
$msecs
)
.
'Z'
;
self
::
$capturedLog
[]
=
$ts
.
' '
.
$string
;
self
::
$capturedLog
[]
=
$ts
.
' '
.
$string
;
...
@@ -301,7 +318,7 @@ class SimpleSAML_Logger
...
@@ -301,7 +318,7 @@ class SimpleSAML_Logger
return
'NA'
;
return
'NA'
;
}
}
if
(
self
::
$trackid
===
NULL
)
{
if
(
self
::
$trackid
===
null
)
{
// no track ID yet, fetch it from the session class
// no track ID yet, fetch it from the session class
// mark it as currently being fetched
// mark it as currently being fetched
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment