Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I may understand you correctly, what you're trying to do is to have some sort of per-session error log, which can be read later on. </p> <p>My suggestion is to create separate log file per session, you can identify the log file by using the session id, which is unique per session.</p> <pre><code>&lt;?php define('PER_SESSION_LOG_PATH', '/tmp/logs/'); //or whatever path /* return log handle */ class SessionLogger { static $fh; static function log_path() { return PER_SESSION_LOG_PATH . session_id() . '.log'; } static function log_open() { if (!self::$fh) { self::$fh = fopen(self::log_path(), 'a+'); } return self::$fh; } static function add_log($errors) { if (self::log_open()) { fwrite(self::$fh, serialize($errors) . PHP_EOL); } } static function log_close() { if (self::$fh) { fclose(self::$fh); } } //note that if the size of the log file is larger than memory_limit, you //may run into problems. //returns all the logs static function get_logs($truncate = TRUE) { $logs = array(); if (self::log_open()) { while (!feof(self::$fh)) { $logs[] = unserialize(fgets(self::$fh)); } //if the logs should be clear, then... if ($truncate) { fclose(self::$fh); //close and nullify handle self::$fh = null; unlink(self::log_path()); //then delete log file. } } return $logs; } } </code></pre> <p>Then you can add errors by doing</p> <pre><code>SessionLogger::add_log($error); </code></pre> <p>You can also read the logs by doing</p> <pre><code>SessionLogger::get_logs(true); //or false if you don't want to delete file. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload