From 85580fb6ae21f7ead7f67bbd16d4c65b28c81609 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 31 Mar 2021 12:45:52 +0200 Subject: [PATCH] Improve log file support --- index.php | 24 ++++++++++++++++++++---- logs/.gitignore | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 logs/.gitignore diff --git a/index.php b/index.php index 432cba4..73457cf 100644 --- a/index.php +++ b/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) {
  • Logout on CAS server
  • Logout on local application
  • Truncate Debug log file content"; } @@ -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); } diff --git a/logs/.gitignore b/logs/.gitignore new file mode 100644 index 0000000..87b94e4 --- /dev/null +++ b/logs/.gitignore @@ -0,0 +1,2 @@ +*.log +*.log.*