@ 2015-04-09T15:10:42Z <?php
/*
* class.MarsLogger.php
*
* CreatedBy: dbuchanan@cotterweb.net
* CreatedOn: 4/3/15
*
* Requires: _variables.php (BatchProcessLogging)
*
* This class created for MarketResearch, to simplify logging to BatchProcess and Email Alerts
*
*/
///Required for doing batchProcessLogging
require_once '_variables.php';
/* ------------------------------------------------------------- */
/*
* This class handles logging, emailing alerts, tracking debug, env, site, name stuff
*/
/* ------------------------------------------------------------- */
class MarketResearch_logger {
protected $env;
protected $debug=0;
protected $site;
protected $name;
protected $admin_email='techadmin@cotterweb.net';
protected $dev_email='dbuchanan@cotterweb.net';
protected $batchProcessLogging;
protected $finish_comment = array();
public function getSite() {
return $this->site;
}
public function getEnv() {
return $this->env;
}
/*
public function getDebug() {
return $this->debug;
}
*/
public function getAdminEmail() {
if($this->getEnv()=='dev')
return $this->dev_email;
else
return $this->admin_email;
}
public function alreadyRunning() {
/* See if cron is already running */
$exec_results = array();
exec("ps -ef | grep \"{$this->name}*{$this->getSite()}\" | grep -v grep | wc -l", $exec_results);
return $exec_results;
}
protected function initLog($name) {
$this->name=$name;
$this->batchProcessLogging = new BatchProcessLogging($name, 'CRON');
}
protected function setDebug($debug) {
$this->debug=$debug;
}
public function startLog() {
if($this->debug==0)
$this->batchProcessLogging->logBatchStart();
else if($this->debug==1) {
$this->batchProcessLogging->logBatchStart();
echo "\nStart Market Research Import";
}
else {
echo "\nStart Market Research Import";
}
}
public function logComment($message) {
if($this->debug==0)
$this->batchProcessLogging->logBatchComment($message);
else if($this->debug==1) {
$this->batchProcessLogging->logBatchComment($message);
echo "\n$message";
}
else {
echo "\n$message";
}
}
public function addFinishComment($message) {
array_push($this->finish_comment,$message);
}
public function sendEmailFinish($message) {
$recipients = $this->getAdminEmail();
$subject = $this->site. ' Success: '.$this->name;
$from = 'From: ' . $this->site . ' Cron Results';
$email_body = $this->site . ' '. $message;
mail($recipients, $subject, $email_body, $from);
}
public function sendEmailAlert($message) {
$recipients = $this->getAdminEmail();
$subject = $this->site. ' Problem Alert: '.$this->name;
$from = 'From: ' . $this->site . ' Cron Results';
$email_body = $this->site . ' '. $message;
mail($recipients, $subject, $email_body, $from);
}
public function endLog($message) {
if($this->debug==0) {
$this->batchProcessLogging->logBatchFinish($message . $this->batchProcessLogging->getElapsedBatchExecutionTime(true), 0, 0);
}
else if($this->debug==1) {
foreach($this->finish_comment as $m) {
$this->logComment($m);
}
$this->batchProcessLogging->logBatchFinish($message . $this->batchProcessLogging->getElapsedBatchExecutionTime(true), 0, 0);
var_dump($this->finish_comment);
echo "\n$message END LOG";
}
else {
var_dump($this->finish_comment);
echo "\n$message";
}
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Warning: require_once(): open_basedir restriction in effect. File(_variables.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/uLBqV on line 14
Warning: require_once(_variables.php): Failed to open stream: Operation not permitted in /in/uLBqV on line 14
Fatal error: Uncaught Error: Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV:14
Stack trace:
#0 {main}
thrown in /in/uLBqV on line 14
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
42.13 ms | 401 KiB | 8 Q