Skip to content

Instantly share code, notes, and snippets.

@lgoldstien
Last active December 19, 2015 07:09
Show Gist options
  • Save lgoldstien/5916349 to your computer and use it in GitHub Desktop.
Save lgoldstien/5916349 to your computer and use it in GitHub Desktop.
<?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