/** * {@inheritdoc} */ public function process($annotation, $context) { if ($annotation instanceof Info && $annotation->validate()) { $root = $context->getRootContext(); if ($root->info !== null) { Logger::notice('Overwriting ' . $annotation->identity() . ': "' . $root->info->_context . '" with "' . $annotation->_context . '"'); } $root->info = $annotation; } }
public function helper($name) { $path = SYS_PATH . DS . 'helpers' . DS . $name . '.helper.php'; if (!file_exists($path)) { if (!file_exists($path)) { return Logger::notice('Can\'t load helper ' . $name . '.helper.php'); } $path = APP_PATH . DS . 'helpers' . DS . $name . '.helper.php'; } include $path; }
/** * Checks if data for this field is valid and removes broken dependencies * * @param Object_Abstract $object * @return bool */ public function sanityCheck($object) { $key = $this->getName(); $sane = true; try { $this->checkValidity($object->{$key}, true); } catch (Exception $e) { Logger::notice("Detected insane relation, removing reference to non existent user with username [" . $object->{$key} . "]"); $object->{$key} = null; $sane = false; } return $sane; }
public function set($key, $obj, $expire = 0) { if (!$this->enabled) { return false; } $success = $this->memcache->set($key, $obj, 0, $expire); if ($success) { Logger::info("Cache stored memcache key: {$key}"); } else { Logger::notice("Cache failed to store memcache key: {$key}"); } Cache::$sets[] = array('key' => $key, 'expire' => $expire, 'success' => $success); return $success; }
public function test_methods_Magento() { $CONFIG_FILE_NAME = __DIR__ . '/logging_exception.yaml'; $LOGGER_NAME = 'defaultLoggerName'; /** * Perform testing. */ $log = new Logger($CONFIG_FILE_NAME, $LOGGER_NAME); $context = ['test' => true, 'env' => ['param1' => 'value1']]; $log->debug('debug', $context); $log->info('info', $context); $log->notice('notice', $context); $log->warning('warning', $context); $log->error('error', $context); $log->alert('alert', $context); $log->critical('critical', $context); $log->emergency('emergency', $context); }
public static function logError($type, $msg, $file, $line) { $str = LogVars::$friendlyErrorType[$type] . ': ' . $msg . ' ' . $file . ':' . $line; if (in_array($type, LogVars::$warnType)) { Logger::warn('handle', $str); } else { if (in_array($type, LogVars::$errorType)) { Logger::error('handle', $str); Url::redirect404(); } else { if (in_array($type, LogVars::$noticeType)) { Logger::notice('handle', $str); } else { Logger::fatal('handle', $str); Url::redirect404(); } } } return true; }
private static function log($type, $msg, $errorNo, $params) { if (class_exists('Xiaoju\\Beatles\\Utils\\Logger')) { switch ($type) { case 'debug': Logger::debug($msg, $errorNo, $params); break; case 'trace': Logger::trace($msg, $errorNo, $params); break; case 'notice': Logger::notice($msg, $errorNo, $params); break; case 'warning': Logger::warning($msg, $errorNo, $params); break; case 'fatal': Logger::fatal($msg, $errorNo, $params); break; } } }
function initialized() { $ret = false; if (is_writable($this->locations["tmp"])) { if (!file_exists($this->locations["tmp"] . "/initialized.txt")) { umask(02); Logger::notice("App instance has not been initialized yet - doing so now"); if (extension_loaded("apc")) { Logger::notice("Flushing APC cache"); apc_clear_cache(); } // Create required directories for program execution if (!file_exists($this->locations["tmp"] . "/compiled/")) { mkdir($this->locations["tmp"] . "/compiled/", 02775); } $ret = touch($this->locations["tmp"] . "/initialized.txt"); } else { $ret = true; } } return $ret; }
/** * Redirect, but only to a safe domain. * * @param string $Destination Where to redirect. * @param int $StatusCode The status of the redirect. Defaults to 302. */ function safeRedirect($Destination = false, $StatusCode = null) { if (!$Destination) { $Destination = Url('', true); } else { $Destination = Url($Destination, true); } $trustedDomains = TrustedDomains(); $isTrustedDomain = false; foreach ($trustedDomains as $trustedDomain) { if (urlMatch($trustedDomain, $Destination)) { $isTrustedDomain = true; break; } } if ($isTrustedDomain) { redirect($Destination, $StatusCode); } else { Logger::notice('Redirect to untrusted domain: {url}.', ['url' => $Destination]); redirect(url("/home/leaving?Target=" . urlencode($Destination))); } }
/** * Normal but significant events. * * @param string $message * @param array $context * * @return null */ public function notice($message, array $context = array()) { \Logger::notice($message); }
/** * @TODO comment this function */ protected function sendMailFromTemplate($recipients, $subject, $params, $templateFilename, $plaintext = true) { $fullTemplateFilename = dirname(__FILE__) . "/../templates/{$templateFilename}.txt"; Logger::debug("Template: {$fullTemplateFilename}"); $template = file_get_contents($fullTemplateFilename); // @TODO Replace this with proper template stuff $mailBody = $this->replaceTokens($template, $params); if (true === $plaintext) { $this->sendPlainTextMail($this->from, $recipients, $subject, $mailBody); Logger::notice("Sent plaintext mail to [{$recipients}] with subject \"{$subject}\""); } else { $mailStatus = $this->sendHtmlMail($this->from, $recipients, $subject, $mailBody); } }
} } public function getLevelName($level) { return $this->logLevels[$level]; } } // testing if (isset($_SERVER["argv"][1]) && $_SERVER["argv"][1] == "__main__") { $logger = new Logger(); for ($i = 0; $i < 6; $i++) { $logger->setLevel($i); error_log("############## Level now: " . $i); $logger->debug(""); $logger->info(""); $logger->notice(""); $logger->warn(""); $logger->error(""); $logger->critical(""); } error_log("############# With Level Names"); for ($i = 0; $i < 6; $i++) { $logger->setLevel($logger->getLevelName($i)); error_log("############## Level now: " . $logger->getLevelName($i)); $logger->debug(""); $logger->info("", __FILE__, __LINE__); $logger->notice(""); $logger->warn(""); $logger->error(""); $logger->critical(""); }
$prepayItem = $txn->getPrepayItem($oneType); if (true === is_null($prepayItem)) { //Logger::debug("No match for $oneType"); continue; } $templateFound = true; $params['quantity'] = $prepayItem['quantity']; $params['item_name'] = $prepayItem['item_name']; $mail = SingletonFactory::getInstance()->getSingleton('MailManager'); if ("Completed" === $payment_status) { try { $status = $mail->sendConfirmationMailToUser($to, $params, $oneType); } catch (Exception $e) { kaput($e->getMessage()); } Logger::notice("Sent confirmation mail (type={$oneType}) successfully to {$to}"); } $params['payment_status'] = $payment_status; try { $mail->sendTransactionMailToAdmins($params); } catch (Exception $e) { kaput($e->getMessage()); } Logger::debug("Sent notification mail to admins successfully, payment_status={$payment_status}"); } if (false === $templateFound) { Logger::error("Unable to find e-mail template"); } } else { Logger::debug("Mail disabled, not sending mail"); }
<?php $userId = null; $basic = new Uauth\Basic("Secured Area", array()); $basic->verify(function ($username, $password) use(&$userId) { $select = PicDB::newSelect(); $select->cols(array("id"))->from("users")->where("username = :username")->where("password = :password")->bindValues(array("username" => $username, "password" => $password)); $id = PicDB::fetch($select, "value"); if ($id) { $userId = (int) $id; return true; } else { return false; } }); $basic->deny(function ($username) { if ($username !== null) { Logger::notice("main", "Failed login", array("username" => $username)); } }); $basic->auth(); define("USERNAME", $basic->getUser()); define("USER_ID", $userId); Logger::debug("main", "Successful authentication"); header("Content-Security-Policy: script-src 'self' https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com");
function shutdownHandler() { if ($this->debug && !empty($res)) { $res = $this->timer->getResult(); $str[] = '[time:'; foreach ($res as $time) { $str[] = ' ' . $time[0] . '=' . $time[1]; } $str[] = ']'; Logger::notice(implode('', $str) . ' status=' . $this->status); Logger::flush(); } $this->_clearDbOrCache(); $this->_end(); }
/** * Checks if data for this field is valid and removes broken dependencies * * @param Object_Abstract $object * @return bool */ public function sanityCheck($object) { $sane = true; $name = $this->getName(); $getter = "get" . ucfirst($name); $data = $object->{$getter}(); $objectRelationIds = array(); if (is_array($data)) { foreach ($data as $o) { if ($o instanceof Element_Interface) { $objectRelationIds[] = $o->getId(); } } } else { if ($data instanceof Element_Interface) { $objectRelationIds[] = $data->getId(); } } $resourceRelationIds = $object->getResource()->getRelationIds($this->getName()); $diff = array_diff($objectRelationIds, $resourceRelationIds); if (count($diff) > 0) { $sane = false; Logger::notice("Detected insane relation(s), removing reference to non existent elements with ids [" . implode(',', $diff) . "]"); } return $sane; }
public function testNotice() { $this->object->notice('message'); }
/** * @return bool */ public function sanityCheck() { $sane = true; if ($this->data["internal"]) { if ($this->data["internalType"] == "document") { $doc = Document::getById($this->data["internalId"]); if (!$doc) { $sane = false; Logger::notice("Detected insane relation, removing reference to non existent document with id [" . $this->getDocumentId() . "]"); $new = Document_Tag::factory($this->getType(), $this->getName(), $this->getDocumentId()); $this->data = $new->getData(); } } else { if ($this->data["internalType"] == "asset") { $asset = Asset::getById($this->data["internalId"]); if (!$asset) { $sane = false; Logger::notice("Detected insane relation, removing reference to non existent asset with id [" . $this->getDocumentId() . "]"); $new = Document_Tag::factory($this->getType(), $this->getName(), $this->getDocumentId()); $this->data = $new->getData(); } } } } return $sane; }
protected function serveCacheFile() { Logger::notice("Serving {$this->cachefile}"); if (!is_file($this->cachefile)) { $this->error("serveCacheFile called in thumcno but we couldn't find the cached file."); return false; } $fp = fopen($this->cachefile, 'rb'); if (!$fp) { return $this->error('Could not open cachefile.'); } fseek($fp, strlen($this->filePrependSecurityBlock), SEEK_SET); $imgType = fread($fp, 3); fseek($fp, 3, SEEK_CUR); if (ftell($fp) != strlen($this->filePrependSecurityBlock) + 6) { @unlink($this->cachefile); return $this->error('The cached image file seems to be corrupt.'); } $imageDataSize = filesize($this->cachefile) - (strlen($this->filePrependSecurityBlock) + 6); $this->sendImageHeaders($imgType, $imageDataSize); $bytesSent = @fpassthru($fp); fclose($fp); if ($bytesSent > 0) { return true; } $content = file_get_contents($this->cachefile); if ($content != false) { $content = substr($content, strlen($this->filePrependSecurityBlock) + 6); echo $content; Logger::info('Served using file_get_contents and echo'); return true; } else { $this->error('Cache file could not be loaded.'); return false; } }
/** * @return bool */ public function checkValidity() { $sane = true; if ($this->id) { $el = Element\Service::getElementById($this->type, $this->id); if (!$el instanceof Element\ElementInterface) { $sane = false; \Logger::notice("Detected insane relation, removing reference to non existent " . $this->type . " with id [" . $this->id . "]"); $this->id = null; $this->type = null; $this->o = null; $this->subtype = null; } } return $sane; }
public function getOriginalObject() { Logger::notice("Getting original object {$this->id}."); return \Pimcore\Model\Object\AbstractObject::getById($this->id); }
/** * The next non-whitespace, non-comment token. * * @param array $tokens * @param Context $context * @return string|array The next token (or false) */ private function nextToken(&$tokens, $context) { $token = next($tokens); if ($token[0] === T_WHITESPACE) { return $this->nextToken($tokens, $context); } if ($token[0] === T_COMMENT) { $pos = strpos($token[1], '@SWG\\'); if ($pos) { $line = $context->line ? $context->line + $token[2] : $token[2]; $commentContext = new Context(['line' => $line], $context); Logger::notice('Annotations are only parsed inside `/**` DocBlocks, skipping ' . $commentContext); } return $this->nextToken($tokens, $context); } return $token; }
public function testNoticeLevel() { $this->expectOutputString('notice: Message contents'); $echo = new Adaptors\EchoAdaptor('debug', '{level}: {message}'); $logger = new Logger($echo); $logger->notice('Message contents'); }
/** * @return bool */ public function checkValidity() { $sane = true; if (!empty($this->id)) { $el = Asset::getById($this->id); if (!$el instanceof Asset) { $sane = false; \Logger::notice("Detected insane relation, removing reference to non existent asset with id [" . $this->id . "]"); $this->id = null; } } return $sane; }
/** * Checks if data for this field is valid and removes broken dependencies * * @param Object_Abstract $object * @return bool */ public function sanityCheck($object) { $key = $this->getName(); $originalText = $object->{$key}; $sane = true; $dependencies = Pimcore_Tool_Text::getDependenciesOfWysiwygText($object->{$key}); $cleanedText = Pimcore_Tool_Text::cleanWysiwygTextOfDependencies($object->{$key}, $dependencies); $object->{$key} = $cleanedText; if ($originalText != $cleanedText) { $sane = false; Logger::notice("Detected insane relation, removed invalid links in html"); } return $sane; }