summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzytzagoo <zytzagoo@gmail.com>2017-10-04 12:32:36 +0200
committerzytzagoo <zytzagoo@gmail.com>2017-10-04 12:32:36 +0200
commitfc4cc5a7f844feea3ed7e4c00a6d953b9361de53 (patch)
treed391d222146859a29f6497bda2d036a588bc0008
parentfed998a7aef5fb40d4e691a4209f9f6b1ca749f1 (diff)
downloadsmtp-validate-email-fc4cc5a7f844feea3ed7e4c00a6d953b9361de53.zip
smtp-validate-email-fc4cc5a7f844feea3ed7e4c00a6d953b9361de53.tar.gz
smtp-validate-email-fc4cc5a7f844feea3ed7e4c00a6d953b9361de53.tar.bz2
add timestamps into debug log messages
-rw-r--r--smtp-validate-email.php16
1 files changed, 15 insertions, 1 deletions
diff --git a/smtp-validate-email.php b/smtp-validate-email.php
index be0ed71..85b2d66 100644
--- a/smtp-validate-email.php
+++ b/smtp-validate-email.php
@@ -815,6 +815,7 @@ class SMTP_Validate_Email {
* @return void
*/
private function debug($str) {
+ $str = $this->stamp($str);
$this->log($str);
if ($this->debug == true) {
if (PHP_SAPI != 'cli') {
@@ -833,6 +834,20 @@ class SMTP_Validate_Email {
}
/**
+ * Prepends the given $msg with the current date and time inside square brackets.
+ *
+ * @param string $msg
+ *
+ * @return string
+ */
+ private function stamp($msg) {
+ $date = \DateTime::createFromFormat('U.u', sprintf('%.f', microtime(true)))->format('Y-m-d\TH:i:s.uO');
+ $line = '[' . $date . '] ' . $msg;
+
+ return $line;
+ }
+
+ /**
* Returns the log array
*/
public function get_log() {
@@ -845,5 +860,4 @@ class SMTP_Validate_Email {
public function clear_log() {
$this->log = array();
}
-
}