Created
August 2, 2018 15:07
-
-
Save lrdgz/03e3132c0585e1f3b8e93a326d1d8970 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Log { | |
private $handle, $dateFormat; | |
public function __construct($file, $mode = "a") { | |
$this->handle = fopen($file, $mode); | |
$this->dateFormat = "d/M/Y H:i:s"; | |
} | |
public function dateFormat($format) { | |
$this->dateFormat = $format; | |
} | |
public function getDateFormat() { | |
return $this->dateFormat; | |
} | |
public function log($entries) { | |
if(is_string($entries)) { | |
fwrite($this->handle, "Error: [" . date($this->dateFormat) . "] " . $entries . "\n"); | |
} else { | |
foreach($entries as $value) { | |
fwrite($this->handle, "Error: [" . date($this->dateFormat) . "] " . $value . "\n"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment