Last active
December 19, 2015 07:09
-
-
Save lgoldstien/5916349 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Log | |
* A class for logging output to a file | |
*/ | |
class Log { | |
/** | |
* @var string | |
*/ | |
public $file; | |
function __construct() { | |
} | |
public function putLog( $app, $content, $level="log" ) { | |
$strLogEntry = "[" . date("D M j G:i:s T Y") . "] "; | |
$strLogEntry .= "{$app} - {$level} - {$content}"; | |
return $strLogEntry; | |
} | |
public function logToFile( $line ) { | |
file_put_contents($this->file, $line . "\n", FILE_APPEND | LOCK_EX); | |
} | |
} | |
$log = new Log(); | |
$log->file = "/home/lgoldstien/logs/ocp.log"; | |
$line = $log->putLog( "OCPTest", "This is a test log to see if the system works.", "info" ); | |
$log->logToFile( $line ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment