3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"; } } }
based on 72KOL
Output for 5.1.0 - 7.2.0
Warning: require_once(_variables.php): failed to open stream: No such file or directory in /in/uLBqV on line 14 Fatal error: require_once(): Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV on line 14
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: main(_variables.php): failed to open stream: No such file or directory in /in/uLBqV on line 14 Fatal error: main(): Failed opening required '_variables.php' (include_path='.:') in /in/uLBqV on line 14
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/uLBqV on line 22
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/uLBqV on line 22
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/uLBqV on line 22
Process exited with code 255.