PHP has no standard logging interface (unlike Python's robust logging module). All it has is error_log() which dumps a string out to the php_errors file. We use this feature in several places in the code to log things:
$ grep -R error_log *
accounts/activate.php: error_log("activate.php - Error activating $reg_token: $create_user_status");
api/index.php: error_log("api/index.php - Error setting $key:count=$count in memcache");
pinc/base.inc: error_log("base.inc - $error_message");
pinc/DPDatabase.inc: error_log("DPDatabase.inc - log_error from $caller: $error");
pinc/send_mail.inc: error_log("send_email.inc - Message could not be sent. PHPMailer Error: {$mail->ErrorInfo}");
pinc/upload_file.inc: error_log("upload_file.inc - zip error: " . $exception->getMessage());
pinc/upload_file.inc: error_log($reporting_string);
tasks.php: error_log("tasks.php - task $tid is linked to non-existent topic $topic_id");
tools/project_manager/add_files.php: error_log("add_files.php - error running \"$cmd\"; exit code: $exit_status");
tools/upload_resumable_file.php: error_log("upload_resumable_file.php - $error");
We also have various forms of adhoc logging like DPDatabase->log_trace().
What we need is a logging interface that we can use instead of php_errors for things that aren't actually errors (although they might be) that we want to keep track of. Like the Python logging library it needs to:
PHP has no standard logging interface (unlike Python's robust logging module). All it has is error_log() which dumps a string out to the
php_errors
file. We use this feature in several places in the code to log things:We also have various forms of adhoc logging like DPDatabase->log_trace().
What we need is a logging interface that we can use instead of
php_errors
for things that aren't actually errors (although they might be) that we want to keep track of. Like the Python logging library it needs to:DPLogger::info("log this message")
)There may be existing logging packages out there although I didn't find a lightweight one on packagist.