/** * Tell Blode to record this run of the application. * Child classes of Application can call this as-appropriate. */ protected function blodeRun() { $run = ['event' => 'app.run', 'app' => get_class($this)]; Event::debug($run); }
public function __construct($message, $code = 0, Exception $previous = null) { Event::debug(array('event' => 'SparkException:' . $message, 'app' => get_class($this), 'path' => $_SERVER['REQUEST_URI'], 'remote_addr' => $_SERVER['REMOTE_ADDR'])); parent::__construct($message, $code, $previous); }
/** * Log an arbitrary string or Exception. * * @param $message string|Exception message to log * @param $type string optional type of message */ public static function log($message, $type = 'error') { // Did we get an Exception? if ($message instanceof \Exception) { // Get a unique string - we can log this, and then display it to the // user as a reference number. self::$reference .= substr(sha1(time() . __FILE__), 0, 10) . ' '; self::$exceptionCount++; $message_text = self::$reference . ':: Uncaught ' . get_class($message) . ' - ' . $message->getMessage() . "\n" . $message->getTraceAsString(); } elseif (is_array($message) || is_object($message)) { $message_text = print_r($message, 1); } else { $message_text = $message; } // if we're grepping for something specific, make sure this message matches: if (isset(static::$grep) && !preg_match(static::$grep, $message_text)) { return; } // If blode is sitting around, send it our message. if (class_exists('Event')) { Event::err($message_text); } if (static::$logUserAgent && isset($_SERVER['HTTP_USER_AGENT'])) { $message_text .= ' [' . $_SERVER['HTTP_USER_AGENT'] . ']'; } $message_text .= "\n"; self::$failCount++; self::$failText .= $message_text; if (isset(self::$logFile)) { // Note deliberate error suppression; there's a good chance this // write will fail from the command line. @file_put_contents(self::$logFile, $message_text, \FILE_APPEND); } else { error_log($message_text); } }
/** * Log some write operation to the database. */ protected function logWrite($action, $payload = array()) { Event::info(array('event' => 'sparkrecord.write', 'type' => get_class($this), 'id' => $this->getId(), 'action' => $action, 'payload' => $payload)); if (defined('\\FLAG_NOTIFY') && constant('\\FLAG_NOTIFY')) { $dino_name = get_class($this); if (\Spark\Notify::validDino($dino_name)) { $payload = array('id' => $this->getId(), 'record' => $this->getRecord(), 'changes' => $this->changes(), 'originalValues' => $this->originalValues()); \Spark\Notify::emit($dino_name, $action, $payload); } } }