Improve log file support
This commit is contained in:
parent
aab9ece941
commit
85580fb6ae
2 changed files with 22 additions and 4 deletions
24
index.php
24
index.php
|
@ -32,8 +32,17 @@ $cas_servers=array(
|
|||
// FQDN of CAS server
|
||||
$default_cas_server=key($cas_servers);
|
||||
|
||||
// PhpCAS log file
|
||||
$phpCAS_logfile='cas.log';
|
||||
// PhpCAS debug logs
|
||||
|
||||
// Log directory path
|
||||
$phpCAS_logdir='logs';
|
||||
|
||||
// Log filename format
|
||||
// Compose with :
|
||||
// - {cas_server} : the CAS server
|
||||
// - {remote_addr} : connected user remote IP address
|
||||
// - {session_id} : connected user session_id
|
||||
$phpCAS_logfile_format='{session_id}-{cas_server}.log';
|
||||
|
||||
// Local app URL (auto-detect on first acces if null)
|
||||
$service_url=null;
|
||||
|
@ -207,6 +216,13 @@ foreach($cas_servers as $srv => $opts) {
|
|||
<li><a href='?do=caslogout'>Logout on CAS server</a></li>
|
||||
<li><a href='?do=locallogout'>Logout on local application</a></li>
|
||||
<?php
|
||||
|
||||
// Generate phpCAS debug log file path
|
||||
$phpCAS_logfile="$phpCAS_logdir/$phpCAS_logfile_format";
|
||||
$phpCAS_logfile=str_replace('{cas_server}', $cas_host, $phpCAS_logfile);
|
||||
$phpCAS_logfile=str_replace('{remote_addr}', $_SERVER['REMOTE_ADDR'], $phpCAS_logfile);
|
||||
$phpCAS_logfile=str_replace('{session_id}', session_id(), $phpCAS_logfile);
|
||||
|
||||
if (is_writable($phpCAS_logfile)) {
|
||||
echo "<li><a href='?truncatelog=true'>Truncate Debug log file content</a></li>";
|
||||
}
|
||||
|
@ -224,8 +240,8 @@ $phpCAS_config=array(
|
|||
'Service URL' => $service_url,
|
||||
);
|
||||
|
||||
if (is_writable($phpCAS_logfile)) {
|
||||
if (isset($_REQUEST['truncatelog'])) {
|
||||
if (is_writable($phpCAS_logfile) || (!is_file($phpCAS_logfile) && is_writable(dirname($phpCAS_logfile)))) {
|
||||
if (is_file($phpCAS_logfile) && isset($_REQUEST['truncatelog'])) {
|
||||
$fh = fopen($phpCAS_logfile, 'w');
|
||||
fclose($fh);
|
||||
}
|
||||
|
|
2
logs/.gitignore
vendored
Normal file
2
logs/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.log
|
||||
*.log.*
|
Loading…
Reference in a new issue