本文整理汇总了PHP中Logging类的典型用法代码示例。如果您正苦于以下问题:PHP Logging类的具体用法?PHP Logging怎么用?PHP Logging使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logging类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send($to, $subject, $message, $from = NULL, $attachments = NULL)
{
if ($attachments != NULL) {
throw new ServiceException("INVALID_CONFIGURATION", "Default mailer does not support sending attachments");
}
if (Logging::isDebug()) {
Logging::logDebug("Sending mail to [" . Util::array2str($to) . "]: [" . $message . "]");
}
if (!$this->enabled) {
return;
}
$isHtml = stripos($message, "<html>") !== FALSE;
$f = $from != NULL ? $from : $this->env->settings()->setting("mail_notification_from");
$validRecipients = $this->getValidRecipients($to);
if (count($validRecipients) === 0) {
Logging::logDebug("No valid recipient email addresses, no mail sent");
return;
}
$toAddress = '';
$headers = $isHtml ? 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=utf-8' . "\r\n" : 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n";
$headers .= 'From:' . $f;
if (count($validRecipients) == 1) {
$toAddress = $this->getRecipientString($validRecipients[0]);
} else {
$headers .= PHP_EOL . $this->getBccHeaders($validRecipients);
}
mail($toAddress, $subject, $isHtml ? $message : str_replace("\n", "\r\n", wordwrap($message)), $headers);
}
示例2: writeLog
/**
* Writes the given log entry using the logger. Or writes it to stdout if logger is null.
*
* @param int $level The level of the log entry
* @param string $msg The message of the log entry
* @param Logging $logger The logger object to use to log the message
*/
public static function writeLog($level, $msg, $logger)
{
if ($logger == null) {
printf("[Level: %d][Time: %s][IP: %s][Message: %s]", $level, date('d-m-Y H:i:s', time()), $_SERVER['REMOTE_ADDR'], $message);
// if ($level == LoggingImpl::LEVEL_ERROR) {
// die;
// }
}
$logger->logEntry($level, $msg);
if ($level == LoggingImpl::LEVEL_ERROR) {
die;
}
}
示例3: processAPI
public function processAPI()
{
if ($this->sqlInjection($_SERVER['REQUEST_URI'])) {
$log = new Logging();
$log->lfile('/var/www/web1162/html/tankUp/log_error.txt');
$log->lwrite("SQL_Injection?: " . $_SERVER['REQUEST_URI']);
$log->lclose();
return $this->_response("Unexpected Parameters", 400);
}
if ((int) method_exists($this, $this->endpoint) > 0) {
return $this->_response($this->{$this->endpoint}($this->args));
}
return $this->_response("No Endpoint: {$this->endpoint}", 404);
}
示例4: GetDataByCoords
public function GetDataByCoords($article, $distance, $sortBy, location $coords)
{
try {
$log = new Logging();
$log->lfile('/var/www/web1162/html/tankUp/log_debug.txt');
$log->lwrite($article . $distance . $sortBy . $coords->latitude . $coords->longitude);
$log->lclose();
$param = new GetDataByCoordsRequest($article, $distance, $coords, $sortBy);
$response = $this->__construct()->__soapCall("getDataByCoords", array($param));
return $response->petrolStation;
} catch (Exception $e) {
// Umwandlung Soap-Exception zu HTTP
return $e;
}
}
示例5: __toString
public function __toString()
{
//if show error or save in logfile
$msg = "[{$this->code}]: {$this->message}\n";
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
$config = new Config();
if ($config->logfile == true) {
$logfile = new Logging();
$logfile->lwrite($msg);
return "";
}
if ($config->showerror == true) {
return $msg;
}
}
示例6: beforeControllerAction
public function beforeControllerAction($controller, $action)
{
if (parent::beforeControllerAction($controller, $action)) {
if ($controller->getId() != 'index' && $action->getId() != 'index') {
$logging = new Logging();
$app = Yii::app();
$request = $app->getRequest();
$user = $app->getUser();
$logging->attributes = ['user_id' => $user->getState('id', 0), 'username' => $user->getState('username', '匿名'), 'request' => $request->getRequestUrl(), 'param' => $request->getParamString(), 'type' => $request->getRequestType(), 'controller' => $controller->getId(), 'action' => $action->getId(), 'time' => time(), 'date' => date('Y-m-d'), 'ip' => $request->getUserHostAddress()];
$logging->save();
}
return true;
} else {
return false;
}
}
示例7: processPost
public function processPost()
{
$data = $this->request->data;
if (!isset($data['to']) or !isset($data['title']) or !isset($data['msg']) or !isset($data['items'])) {
throw $this->invalidRequestException("Data missing");
}
$to = $data['to'];
$message = $data['msg'];
$title = $data['title'];
$items = $this->items($data['items']);
if (count($items) == 0) {
throw $this->invalidRequestException("Items missing");
}
if (Logging::isDebug()) {
Logging::logDebug("SENDVIAEMAIL: Sending mail " . $to . ":" . Util::array2str($items));
}
$attachments = array();
foreach ($items as $i) {
$attachments[] = $i->internalPath();
}
//TODO stream
if ($this->env->mailer()->send(array($to), $title, $message, NULL, $attachments)) {
$this->response()->success(array());
} else {
$this->response()->error("REQUEST_FAILED", NULL);
}
}
示例8: onResponseSent
public function onResponseSent()
{
if (!$this->settings->hasSetting("debug_log") or !$this->environment->request()) {
return;
}
$path = $this->environment->request()->path();
if (count($path) > 0 and strcasecmp($path[0], "debug") == 0) {
return;
}
$log = $this->settings->setting("debug_log");
$handle = @fopen($log, "a");
if (!$handle) {
Logging::logError("Could not write to log file: " . $log);
return;
}
$trace = Logging::getTrace();
try {
foreach ($trace as $d) {
fwrite($handle, Util::toString($d));
}
fclose($handle);
} catch (Exception $e) {
Logging::logError("Could not write to log file: " . $log);
Logging::logException($e);
}
}
示例9: StoreFile
function StoreFile($_visitor, $_browserId, $_partner, $_fullname, $_chatId)
{
$filename = IOStruct::GetNamebase($_FILES['form_userfile']['name']);
Logging::GeneralLog($filename);
if (!IOStruct::IsValidUploadFile($filename)) {
return false;
}
if (empty($_fullname)) {
$_fullname = Visitor::GetNoName($_visitor->UserId . Communication::GetIP());
}
$fileid = md5($filename . $_visitor->UserId . $_browserId);
$fileurid = EX_FILE_UPLOAD_REQUEST . "_" . $fileid;
$filemask = $_visitor->UserId . "_" . $fileid;
$request = new FileUploadRequest($fileurid, $_partner, $_chatId);
$request->Load();
if ($request->Permission == PERMISSION_FULL) {
if (move_uploaded_file($_FILES["form_userfile"]["tmp_name"], PATH_UPLOADS . $request->FileMask)) {
KnowledgeBase::CreateFolders($_partner, false);
KnowledgeBase::Process($_partner, $_visitor->UserId, $_fullname, 0, $_fullname, 0, 5, 3);
KnowledgeBase::Process($_partner, $fileid, $filemask, 4, $_FILES["form_userfile"]["name"], 0, $_visitor->UserId, 4, $_FILES["form_userfile"]["size"]);
$request->Download = true;
$request->Save();
return true;
} else {
$request->Error = true;
$request->Save();
}
}
return false;
}
示例10: testImport
public function testImport()
{
print "\n" . "Testing import ... ";
$response = RequestResponse::ImportConceptRequest(self::$client, self::$postData, self::$boundaryNumeric);
Logging::var_error_log("\n Response body ", $response->getBody(), __DIR__ . "/ImportResponse.html");
$this->AssertEquals(200, $response->getStatus(), 'Failed to import concept');
$output = array('0' => "The ouput of sending jobs: ");
$retvar = 0;
$sendjob = exec(PHP_JOBS_PROCESS, $output, $retvar);
// check via spraql query
//$sparqlResult = $this ->sparqlRetrieveTriplesForNotation(self::$notation);
//var_dump($sparqlResult);
self::$client->setUri(BASE_URI_ . '/public/api/find-concepts?q=prefLabel:' . self::$prefLabel);
$responseGet = self::$client->request(Zend_Http_Client::GET);
$this->AssertEquals(200, $responseGet->getStatus(), $responseGet->getMessage());
$dom = new Zend_Dom_Query();
$namespaces = RequestResponse::setNamespaces();
$dom->registerXpathNamespaces($namespaces);
$xml = $responseGet->getBody();
$dom->setDocumentXML($xml);
var_dump($xml);
$results1 = $dom->query('rdf:RDF');
$this->AssertEquals(1, $results1->current()->getAttribute('openskos:numFound'));
$results2 = $dom->queryXpath('/rdf:RDF/rdf:Description');
$this->AssertEquals(1, count($results2));
}
示例11: log
function log()
{
if (!Logging::isDebug()) {
return;
}
Logging::logDebug("PLUGIN (" . get_class($this) . ")");
}
示例12: send
public function send($to, $subject, $message, $from = NULL, $attachments = NULL)
{
if (!$this->enabled) {
return;
}
$isHtml = stripos($message, "<html>") !== FALSE;
$f = $from != NULL ? $from : $this->env->settings()->setting("mail_notification_from");
$validRecipients = $this->getValidRecipients($to);
if (count($validRecipients) === 0) {
Logging::logDebug("No valid recipient email addresses, no mail sent");
return;
}
if (Logging::isDebug()) {
Logging::logDebug("Sending mail from [" . $f . "] to [" . Util::array2str($validRecipients) . "]: [" . $message . "]");
}
set_include_path("vendor/PHPMailer" . DIRECTORY_SEPARATOR . PATH_SEPARATOR . get_include_path());
require 'class.phpmailer.php';
$mailer = new PHPMailer();
$smtp = $this->env->settings()->setting("mail_smtp");
if ($smtp != NULL and isset($smtp["host"])) {
$mailer->isSMTP();
$mailer->Host = $smtp["host"];
if (isset($smtp["username"]) and isset($smtp["password"])) {
$mailer->SMTPAuth = true;
$mailer->Username = $smtp["username"];
$mailer->Password = $smtp["password"];
}
if (isset($smtp["secure"])) {
$mailer->SMTPSecure = $smtp["secure"];
}
}
$mailer->From = $f;
foreach ($validRecipients as $recipient) {
$mailer->addBCC($recipient["email"], $recipient["name"]);
}
if (!$isHtml) {
$mailer->WordWrap = 50;
} else {
$mailer->isHTML(true);
}
if ($attachments != NULL) {
//TODO use stream
foreach ($attachments as $attachment) {
$mailer->addAttachment($attachment);
}
}
$mailer->Subject = $subject;
$mailer->Body = $message;
try {
if (!$mailer->send()) {
Logging::logError('Message could not be sent: ' . $mailer->ErrorInfo);
return FALSE;
}
return TRUE;
} catch (Exception $e) {
Logging::logError('Message could not be sent: ' . $e);
return FALSE;
}
}
示例13: putToCache
private function putToCache($name, $subject, $value)
{
if (!array_key_exists($name, $this->permissionCaches)) {
$this->permissionCaches[$name] = array();
}
$this->permissionCaches[$name][$subject] = $value;
Logging::logDebug("Permission cache put [" . $name . "/" . $subject . "]=" . $value);
}
示例14: chkCSRFToken
/**
* CSRF対策のトークンをチェックする。
* 異常時はログに書き込む
* @return boolean
*/
static function chkCSRFToken($file = null, $line = null)
{
if (ENABLE_CSRF == TRUE) {
return true;
}
if ($_POST) {
// CSRF トークンが正しいかチェック
if (\Security::check_token()) {
return true;
}
}
$msg2 = 'Invalid CSRF Token';
// Log::error($msg2);
$log = new Logging();
$log->writeLog_Warning($msg2, $file, $line);
return false;
}
示例15: getShareItem
public function getShareItem($id)
{
$ic = $this->dao()->getItemCollection($id);
if (!$ic) {
Logging::logDebug("Invalid share request, no item collection found with id " . $id);
return NULL;
}
return array("name" => $ic["name"]);
}