本文整理汇总了PHP中Logging::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Logging::log方法的具体用法?PHP Logging::log怎么用?PHP Logging::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logging
的用法示例。
在下文中一共展示了Logging::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: forward
/**
* Forward the user to a specified url
*
* @param string $url The URL to forward to
* @param integer $code [optional] HTTP status code
*/
public function forward($url, $code = 200)
{
if (Context::getRequest()->isAjaxCall() || Context::getRequest()->getRequestedFormat() == 'json') {
$this->getResponse()->ajaxResponseText($code, Context::getMessageAndClear('forward'));
}
Logging::log("Forwarding to url {$url}");
Logging::log('Triggering header redirect function');
$this->getResponse()->headerRedirect($url, $code);
}
示例2: add
public static function add($key, $value)
{
if (!self::isInMemorycacheEnabled()) {
Logging::log('Key "' . $key . '" not cached (cache disabled)', 'cache');
return false;
}
apc_store($key, $value);
Logging::log('Caching value for key "' . $key . '"', 'cache');
return true;
}
示例3: manufacture
public function manufacture($classname, $id, $row = null)
{
// Check that the id is valid
if ((int) $id == 0) {
throw new \Exception('Invalid id');
}
// Set up the name for the factory array
$factory_array_name = "_{$classname}s";
$item = null;
// Set up the manufactured array if it doesn't exist
if (!isset($this->{$factory_array_name})) {
Logging::log("Setting up manufactured array for {$classname}");
$this->{$factory_array_name} = array();
}
// If the current id doesn't exist in the manufactured array, manufacture it
if (!array_key_exists($id, $this->{$factory_array_name})) {
// Initialize a position for the item in the manufactured array
$this->{$factory_array_name}[$id] = null;
try {
// Check if the class is cacheable as well
$cacheable = in_array($classname, array('TBGProject', 'TBGStatus', 'TBGPriority', 'TBGCategory', 'TBGUserstate'));
$item = null;
// If the class is cacheable, check if it exists in the cache
if ($cacheable) {
if ($item = Cache::get("TBGFactory_cache{$factory_array_name}_{$id}")) {
Logging::log("Using cached {$classname} with id {$id}");
}
}
// If we didn't get an item from the cache, manufacture it
if (!$cacheable || !is_object($item)) {
$item = new $classname($id, $row);
Logging::log("Manufacturing {$classname} with id {$id}");
// Add the item to the cache if it's cacheable
if ($cacheable) {
Cache::add("TBGFactory_cache{$factory_array_name}_{$id}", $item);
}
}
// Add the manufactured item to the manufactured array
$this->{$factory_array_name}[$id] = $item;
} catch (Exception $e) {
throw $e;
}
} else {
Logging::log("Using previously manufactured {$classname} with id {$id}");
}
// Return the item at that id in the manufactured array
return $this->{$factory_array_name}[$id];
}
示例4: write
public function write($q)
{
global $conf;
try {
$db = new PDO('sqlite:' . $this->dbLocation);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$results = $db->exec($q);
$db = NULL;
} catch (Exception $e) {
echo "Can't write in SQLite database. Please check you have granted write permissions to <tt>meta/</tt> and <tt>meta/db.sqlite</tt>.<br/>Also you can check a list of <a href='https://github.com/alangrafu/lodspeakr/wiki/CommonErrors'>common errors</a> and how to <a href='https://github.com/alangrafu/lodspeakr/wiki/Wipe-out-the-database'>wipe out the database</a>'";
if ($conf['debug']) {
Logging::log('Exception exec: ' . $e->getMessage(), E_USER_ERROR);
}
exit(1);
}
return $results;
}
示例5: execute
public function execute($file)
{
global $conf;
global $localUri;
global $uri;
global $acceptContentType;
global $endpoints;
global $lodspk;
$extension = array_pop(explode(".", $file));
$ct = $this->getContentType($extension);
header("Content-type: " . $ct);
$uri = $localUri;
if ($conf['debug']) {
Logging::log("In " . $conf['static']['directory'] . " static file {$file}");
}
$htmlExtension = 'html';
if ($conf['static']['haanga'] && substr_compare($file, $htmlExtension, -strlen($htmlExtension), strlen($htmlExtension)) === 0) {
$lodspk['home'] = $conf['basedir'];
$lodspk['baseUrl'] = $conf['basedir'];
$lodspk['module'] = 'static';
$lodspk['root'] = $conf['root'];
$lodspk['contentType'] = $acceptContentType;
$lodspk['ns'] = $conf['ns'];
$lodspk['this']['value'] = $localUri;
$lodspk['this']['curie'] = Utils::uri2curie($localUri);
$lodspk['local']['value'] = $localUri;
$lodspk['local']['curie'] = Utils::uri2curie($localUri);
$lodspk['contentType'] = $acceptContentType;
$lodspk['endpoint'] = $conf['endpoint'];
$lodspk['type'] = $modelFile;
$lodspk['header'] = $prefixHeader;
$lodspk['baseUrl'] = $conf['basedir'];
Utils::processDocument($conf['static']['directory'] . $file, $lodspk, null);
} else {
echo file_get_contents($conf['static']['directory'] . $file);
}
}
示例6: execute
public function execute($service)
{
global $conf;
global $localUri;
global $uri;
global $acceptContentType;
global $endpoints;
global $lodspk;
global $firstResults;
global $results;
$context = array();
$context['contentType'] = $acceptContentType;
$context['endpoints'] = $endpoints;
//$f = $this->getFunction($localUri);
$params = array();
$params = $this->getParams($localUri);
//$params[] = $context;
//$acceptContentType = Utils::getBestContentType($_SERVER['HTTP_ACCEPT']);
$extension = Utils::getExtension($acceptContentType);
$args = array();
list($modelFile, $viewFile) = $service;
try {
$prefixHeader = array();
for ($i = 0; $i < sizeof($params); $i++) {
if ($conf['mirror_external_uris'] != false) {
$altUri = Utils::curie2uri($params[$i]);
$altUri = preg_replace("|^" . $conf['basedir'] . "|", $conf['ns']['local'], $altUri);
$params[$i] = Utils::uri2curie($altUri);
}
}
$segmentConnector = "";
for ($i = 0; $i < sizeof($params); $i++) {
Utils::curie2uri($params[$i]);
//echo $params[$i]." ".Utils::curie2uri($params[$i]);exit(0);
$auxPrefix = Utils::getPrefix($params[$i]);
if ($auxPrefix['ns'] != NULL) {
$prefixHeader[] = $auxPrefix;
}
$args["arg" . $i] = $params[$i];
$args["all"] .= $segmentConnector . $params[$i];
if ($segmentConnector == "") {
$segmentConnector = "/";
}
}
$results['params'] = $params;
$lodspk['home'] = $conf['basedir'];
$lodspk['baseUrl'] = $conf['basedir'];
$lodspk['module'] = 'service';
$lodspk['root'] = $conf['root'];
$lodspk['contentType'] = $acceptContentType;
$lodspk['ns'] = $conf['ns'];
$lodspk['this']['value'] = $uri;
$lodspk['this']['curie'] = Utils::uri2curie($uri);
$lodspk['local']['value'] = $localUri;
$lodspk['local']['curie'] = Utils::uri2curie($localUri);
$lodspk['contentType'] = $acceptContentType;
$lodspk['endpoint'] = $conf['endpoint'];
$lodspk['type'] = $modelFile;
$lodspk['header'] = $prefixHeader;
$lodspk['args'] = $args;
$lodspk['add_mirrored_uris'] = false;
$lodspk['baseUrl'] = $conf['basedir'];
$lodspk['this']['value'] = $uri;
if ($viewFile == null) {
$lodspk['transform_select_query'] = true;
}
// chdir($lodspk['model']);
Utils::queryFile($modelFile, $endpoints['local'], $results, $firstResults);
if (!$lodspk['resultRdf']) {
$results = Utils::internalize($results);
$firstAux = Utils::getfirstResults($results);
// chdir($conf['home']);
if (is_array($results)) {
$resultsObj = Convert::array_to_object($results);
$results = $resultsObj;
} else {
$resultsObj = $results;
}
$lodspk['firstResults'] = Convert::array_to_object($firstAux);
} else {
$resultsObj = $results;
}
//Need to redefine viewFile as 'local' i.e., inside service.foo/ so I can load files with the relative path correctly
//$viewFile = $extension.".template";
//chdir($conf['home']);
Utils::processDocument($viewFile, $lodspk, $results);
} catch (Exception $ex) {
echo $ex->getMessage();
if ($conf['debug']) {
Logging::log($ex->getMessage(), E_ERROR);
}
HTTPStatus::send500($uri);
}
}
示例7: activate
public static function activate($code)
{
$RS = database::Query('SELECT id FROM users WHERE accesscode=:var1 AND status=0', array('var1' => $code), $stats);
if ($stats == 1) {
$user = new self($RS[0]['id']);
$user->set('status', 1);
$user->save();
Logging::log(2, $user);
} else {
$user = new self();
$user->errmsg = Texter::get('user|activationFail');
}
return $user;
}
示例8: headerRedirect
/**
* Forward the user to a different URL
*
* @param string $url the url to forward to
* @param integer $code HTTP status code
*/
public function headerRedirect($url, $code = 302)
{
Logging::log('Running header redirect function');
$this->clearHeaders();
$this->setHttpStatus($code);
if (Caspar::getRequest()->isAjaxCall() || Caspar::getRequest()->getRequestedFormat() == 'json') {
$this->renderHeaders();
} else {
$this->addHeader("Location: {$url}");
$this->renderHeaders();
}
exit;
}
示例9: Db
<?php
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Scoreboard");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Users");
$RULES = new Rules(1, "scoreboard");
$REQUEST = new Request();
$quantity = intval($REQUEST->get("quantity", "1"));
$asset_id = $REQUEST->get("asset_id");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$inc' => array("assets." . $asset_id . ".quantity" => $quantity)));
$LOG = new Logging("Scoreboard.asset");
$LOG->log($RULES->getId(), 61, $REQUEST->get("asset_id"), $quantity, "User added item to scoreboard Possessions");
$OUTPUT->success(0, $document, null);
示例10: Db
<?php
// Helper functions and includs
include_once '/var/www/html/Lux/Core/Helper.php';
$db = new Db("Inventory");
$OUTPUT = new Output();
$REQUEST = new Request();
$collection = $db->selectCollection("Cart");
$RULES = new Rules(1, "cart");
$REQUEST = new Request();
// get the asset, push it into the cart that is selected
$collectionName = $REQUEST->get("collection", "Standard");
$cartName = $REQUEST->get("wishlist", "Default");
$document = $collection->findAndModify(array("user_id" => $RULES->getId()), array('$push' => array("wishlist." . $cartName => MongoDBRef::create($collectionName, $REQUEST->get("id"), "Assets"))));
// Used for analytics
$LOG = new Logging("Cart.order");
$LOG->log($RULES->getId(), 43, $REQUEST->get("id"), 100, "User Wished for item");
$OUTPUT->success(0, $document, null);
示例11: Db
<?php
/* Reformatted 12.11.2015 */
// helpers nad includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$db = new Db("SocialNetwork");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// No privleges Required
$RULES = new Rules(0, "profile");
// Selects collection from Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Groups");
$collection = $db->selectCollection($collectionName);
// Format Query
$query = Helper::formatQuery($REQUEST, "group_id");
// Used for anayltics
$LOG = new Logging("Groups.query");
$LOG->log($RULES->getId(), 72, $query, 100, "Groups Queried");
// Find Documents in Collection
$documents = $collection->find($query);
// Output
$OUTPUT->success(1, $documents);
?>
示例12: getModelandView
private static function getModelandView($t, $extension)
{
global $conf;
global $results;
global $rPointer;
global $lodspk;
$objResult = array('modelFile' => null, 'viewFile' => null);
//Defining default views and models
$curieType = "";
//Get the firstResults type available
$typesAndValues = array('rdfs:Resource' => -1, 'rdfs__Resource' => -1);
if (!isset($conf['disableComponents']) || $conf['disableComponents'] != true) {
foreach ($t as $v) {
$curie = Utils::uri2curie($v);
$typesAndValues[$curie] = 0;
$typesAndValues[str_replace(":", "__", $curie)] = 0;
if (isset($conf['type']['priority'][$curie]) && $conf['type']['priority'][$curie] >= 0) {
$typesAndValues[$curie] = $conf['type']['priority'][$curie];
$typesAndValues[str_replace(":", "__", $curie)] = $conf['type']['priority'][$curie];
}
}
}
arsort($typesAndValues);
$extensionView = $extension . ".";
$extensionModel = '';
if ($extension != 'html') {
$extensionModel = $extension . '.';
}
foreach ($typesAndValues as $v => $w) {
$auxViewFile = $conf['home'] . $conf['view']['directory'] . '/' . $conf['type']['prefix'] . '/' . $v . '/' . $extension . '.template';
$auxModelFile = $conf['home'] . $conf['model']['directory'] . '/' . $conf['type']['prefix'] . '/' . $v . '/' . $extension . '.queries';
if ($v == null) {
continue;
}
$lodspk['componentName'] = $v;
if (file_exists($auxModelFile)) {
$objResult['modelFile'] = $auxModelFile;
//$conf['type']['prefix'].'/'.$v.'/'.$extensionModel.'queries';
if (file_exists($auxViewFile)) {
$objResult['viewFile'] = $auxViewFile;
//$conf['type']['prefix'].'/'.$v.'/'.$extensionView.'template';
} elseif ($extension != 'html') {
//View doesn't exists (and is not HTML)
$objResult['viewFile'] = null;
}
break;
//return $objResult;
} elseif (file_exists($conf['home'] . $conf['model']['directory'] . '/' . $conf['type']['prefix'] . '/' . $v . '/queries')) {
$objResult['modelFile'] = $conf['home'] . $conf['model']['directory'] . '/' . $conf['type']['prefix'] . '/' . $v . '/queries';
if (file_exists($auxViewFile)) {
$objResult['viewFile'] = $auxViewFile;
} else {
$lodspk['transform_select_query'] = true;
$objResult['viewFile'] = null;
}
if ($conf['debug']) {
Logging::log("LODSPeaKr can't find the proper query. Using HTML query instead.", E_USER_NOTICE);
}
break;
} else {
$found = false;
if (sizeof($conf['components']['types']) > 0) {
foreach ($conf['components']['types'] as $type) {
$typeArray = explode("/", $type);
$typeName = end($typeArray);
if ($v == $typeName && file_exists($type)) {
array_pop($typeArray);
$conf['type']['prefix'] = array_pop($typeArray);
$conf['model']['directory'] = join("/", $typeArray);
$conf['view']['directory'] = $conf['model']['directory'];
$lodspk['model'] = $conf['model']['directory'] . '/' . $conf['type']['prefix'] . '/' . $typeName . '/queries';
$lodspk['view'] = $conf['view']['directory'] . '/' . $conf['type']['prefix'] . '/' . $typeName . '/' . $extension . '.template';
$objResult['viewFile'] = $lodspk['view'];
$objResult['modelFile'] = $lodspk['model'];
$found = true;
if (!file_exists($objResult['viewFile'])) {
$lodspk['transform_select_query'] = true;
$objResult['viewFile'] = null;
}
return $objResult;
}
}
}
if ($found) {
break;
}
}
/*if($objResult['viewFile'] == null && $extensionView == 'html'){
$objResult['viewFile'] = 'html.template';
}*/
}
return $objResult;
}
示例13: processIncomingEmailAccount
public function processIncomingEmailAccount(IncomingEmailAccount $account)
{
$count = 0;
if ($emails = $account->getUnprocessedEmails()) {
try {
$current_user = framework\Context::getUser();
foreach ($emails as $email) {
$user = $this->getOrCreateUserFromEmailString($email->from);
if ($user instanceof User) {
if (framework\Context::getUser()->getID() != $user->getID()) {
framework\Context::switchUserContext($user);
}
$message = $account->getMessage($email);
$data = $message->getBodyPlain() ? $message->getBodyPlain() : strip_tags($message->getBodyHTML());
if ($data) {
if (mb_detect_encoding($data, 'UTF-8', true) === false) {
$data = utf8_encode($data);
}
$new_data = '';
foreach (explode("\n", $data) as $line) {
$line = trim($line);
if ($line) {
$line = preg_replace('/^(_{2,}|-{2,})$/', "<hr>", $line);
$new_data .= $line . "\n";
} else {
$new_data .= "\n";
}
}
$data = nl2br($new_data, false);
}
// Parse the subject, and obtain the issues.
$parsed_commit = Issue::getIssuesFromTextByRegex(mb_decode_mimeheader($email->subject));
$issues = $parsed_commit["issues"];
// If any issues were found, add new comment to each issue.
if ($issues) {
foreach ($issues as $issue) {
$text = preg_replace('#(^\\w.+:\\n)?(^>.*(\\n|$))+#mi', "", $data);
$text = trim($text);
if (!$this->processIncomingEmailCommand($text, $issue) && $user->canPostComments()) {
$comment = new Comment();
$comment->setContent($text);
$comment->setPostedBy($user);
$comment->setTargetID($issue->getID());
$comment->setTargetType(Comment::TYPE_ISSUE);
$comment->save();
}
}
} else {
if ($user->canReportIssues($account->getProject())) {
$issue = new Issue();
$issue->setProject($account->getProject());
$issue->setTitle(mb_decode_mimeheader($email->subject));
$issue->setDescription($data);
$issue->setPostedBy($user);
$issue->setIssuetype($account->getIssuetype());
$issue->save();
// Append the new issue to the list of affected issues. This
// is necessary in order to process the attachments properly.
$issues[] = $issue;
}
}
// If there was at least a single affected issue, and mail
// contains attachments, add those attachments to related issues.
if ($issues && $message->hasAttachments()) {
foreach ($message->getAttachments() as $attachment_no => $attachment) {
echo 'saving attachment ' . $attachment_no;
$name = $attachment['filename'];
$new_filename = framework\Context::getUser()->getID() . '_' . NOW . '_' . basename($name);
if (framework\Settings::getUploadStorage() == 'files') {
$files_dir = framework\Settings::getUploadsLocalpath();
$filename = $files_dir . $new_filename;
} else {
$filename = $name;
}
Logging::log('Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no);
echo 'Creating issue attachment ' . $filename . ' from attachment ' . $attachment_no;
$content_type = $attachment['type'] . '/' . $attachment['subtype'];
$file = new File();
$file->setRealFilename($new_filename);
$file->setOriginalFilename(basename($name));
$file->setContentType($content_type);
$file->setDescription($name);
$file->setUploadedBy(framework\Context::getUser());
if (framework\Settings::getUploadStorage() == 'database') {
$file->setContent($attachment['data']);
} else {
Logging::log('Saving file ' . $new_filename . ' with content from attachment ' . $attachment_no);
file_put_contents($new_filename, $attachment['data']);
}
$file->save();
// Attach file to each related issue.
foreach ($issues as $issue) {
$issue->attachFile($file);
}
}
}
$count++;
}
}
} catch (\Exception $e) {
//.........这里部分代码省略.........
示例14: Db
<?php
/* Reformatted 12.11.2015 */
// Helper functions adn includes
include_once '/var/www/html/Lux/Core/Helper.php';
// Create Database Connection
$DB = new Db("Auth");
$OUTPUT = new Output();
// Get Request Data
$REQUEST = new Request();
// Admin Privleges required
$RULES = new Rules(5, "providers");
// Selects Collection From Database Connection
$collectionName = Helper::getCollectionName($REQUEST, "Providers");
$collection = $DB->selectCollection($collectionName);
// provider name required for specific query (otherwise all will be returned)
$query = Helper::formatQuery($REQUEST, "provider_name", null, array("protocol" => "OAuth2"));
// Used for analytics
$LOG = new Logging("Auth2.query");
$LOG->log($RULES->getId(), 112, $query, 100, "User viewed items in cart/wishlist");
// Find Documents in Collection
$documents = $collection->find($query);
// Output
$OUTPUT->success(1, $documents);
示例15: json_encode
$return = $this->user->createPassword($_POST['values']['password_new1'], $this->user->get('id'));
if ($return['success'] == 1) {
if (isset($_COOKIE['authCookie'])) {
$this->user->verifyPassword($this->user->get('mail'), $_POST['values']['password_new1'], 1);
} else {
$this->user->verifyPassword($this->user->get('mail'), $_POST['values']['password_new1'], 0);
}
} else {
$errmsg[] = $return['errmsg'];
}
}
if ($return['success'] == 0 && count($errmsg) > 0) {
echo json_encode(array('success' => 0, 'errmsg' => $errmsg));
} else {
echo json_encode(array('success' => 1));
Logging::log(7, $this->user);
}
break;
case 'sendNewPassword':
$user = new user($_POST['values']['clientId']);
$newPassword = $user->generateRandomPassword();
$loginCredentials = $user->createPassword($newPassword);
if ($loginCredentials['success'] === 1) {
$result = mailer::sendNewPasswordMail($user, $newPassword);
if ($result === true) {
$user->set('salt', $loginCredentials['salt']);
$user->set('password', $loginCredentials['password']);
$user->save();
echo json_encode(array('status' => 'correct', 'msg' => Texter::get('client|sendNewPassword')));
} else {
echo json_encode(array('status' => Texter::get('client|sendNewPasswordfail')));