Created
July 9, 2014 04:24
-
-
Save besingamkb/ca4447cf3293068f2d2a to your computer and use it in GitHub Desktop.
saving logs in codeigniter
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
/*audit trail*/ | |
private $logdir = "application/logs/"; | |
private $logfile; | |
private $logs; | |
private function writeFile($logs) { | |
$fileOpen = fopen($this->logdir . $this->logfile, 'a+'); | |
fwrite($fileOpen, $logs); | |
fclose($fileOpen); | |
} | |
protected function saveLogs($action = "null", $comment = "null") { | |
$datetime = time(); | |
$this->logfile = "audittrail_" . date("mdY", $datetime) . ".csv"; | |
$this->logs = $datetime . ','; | |
$this->logs .= $_SERVER['SERVER_ADDR'] . ','; | |
$this->logs .= self::ez_decrypt($this->session->userdata('user_id')) . ','; | |
$this->logs .= '"' . self::ez_decrypt($this->session->userdata('user_email')) . '",'; | |
$this->logs .= '"' . $action .'",'; | |
$this->logs .= '"' . $comment . '",'; | |
$this->logs .= '"http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '"'; | |
$this->writeFile("\r" . $this->logs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment