本文整理汇总了PHP中eZLog类的典型用法代码示例。如果您正苦于以下问题:PHP eZLog类的具体用法?PHP eZLog怎么用?PHP eZLog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZLog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeAudit
/**
* Writes $auditName with $auditAttributes as content
* to file name that will be fetched from ini settings by auditNameSettings() for logging.
*
* @param string $auditName
* @param array $auditAttributes
* @return bool
*/
static function writeAudit($auditName, $auditAttributes = array())
{
$enabled = eZAudit::isAuditEnabled();
if (!$enabled) {
return false;
}
$auditNameSettings = eZAudit::auditNameSettings();
if (!isset($auditNameSettings[$auditName])) {
return false;
}
$ip = eZSys::clientIP();
if (!$ip) {
$ip = eZSys::serverVariable('HOSTNAME', true);
}
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
$userLogin = $user->attribute('login');
$message = "[{$ip}] [{$userLogin}:{$userID}]\n";
foreach (array_keys($auditAttributes) as $attributeKey) {
$attributeValue = $auditAttributes[$attributeKey];
$message .= "{$attributeKey}: {$attributeValue}\n";
}
$logName = $auditNameSettings[$auditName]['file_name'];
$dir = $auditNameSettings[$auditName]['dir'];
eZLog::write($message, $logName, $dir);
return true;
}
示例2: logMessage
/**
* Generic method for logging a message
*
* @param string $msg
* @param bool $bPrintMsg
* @param string $logType
*/
public static function logMessage($msg, $bPrintMsg = true, $logType = self::NOTICELOG)
{
switch ($logType) {
case self::ERRORLOG:
$logFile = self::ERRORLOG_FILE;
if ($bPrintMsg) {
self::writeError($msg);
}
break;
case self::WARNINGLOG:
$logFile = self::WARNINGLOG_FILE;
if ($bPrintMsg) {
self::writeWarning($msg);
}
break;
case self::NOTICELOG:
default:
$logFile = self::NOTICELOG_FILE;
if ($bPrintMsg) {
self::writeNotice($msg);
}
break;
}
eZLog::write($msg, $logFile);
}
示例3: __construct
/**
* @param int $objectID ContentObjectID
*/
public function __construct($objectID)
{
$userID = eZUser::currentUserID();
$message = ezpI18n::tr('design/standard/error/kernel', 'Access denied') . '. ' . ezpI18n::tr('design/standard/error/kernel', 'You do not have permission to access this area.');
eZLog::write("Access denied to content object #{$objectID} for user #{$userID}", 'error.log');
parent::__construct($message);
}
示例4: write_invalid_checkcreditcard_log
public static function write_invalid_checkcreditcard_log($order_id, $response = array("errorcode" => "unknown", "errormessage" => "unknown"))
{
$http = eZHTTPTool::instance();
//set fallbacks for direct ajax request
if (!isset($order_id) or is_array($order_id) and count($order_id) == 0) {
$order_id = $http->postVariable('order_id');
}
if (!isset($response) or is_array($response) and count($response) == 0) {
$response = $http->postVariable('response');
}
eZLog::write("FAILED in step 1 ('checkcreditcard') for order ID " . $order_id . " with ERRORCODE " . $response["errorcode"] . " Message: " . $response["errormessage"], $logName = 'xrowpayone.log', $dir = 'var/log');
}
示例5: modify
function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
{
switch ($operatorName) {
case 'hashcreate':
$algorithm = $namedParameters['algorithm'];
$hash_array = $namedParameters['hash_array'];
$key = $namedParameters['key'];
$operatorValue = xrowPayoneHelper::generate_hash($algorithm, $hash_array, $key);
break;
case 'payone_info_by_order':
$order = $namedParameters['order'];
$payone_info = array();
if ($order instanceof eZOrder) {
$doc = new DOMDocument('1.0', 'utf-8');
$doc->loadXML($order->DataText1);
//try to fetch txid
$txid_element = $doc->getElementsByTagName('txid');
if ($txid_element->length >= 1) {
$payone_info["txid"] = (string) $txid_element->item(0)->nodeValue;
}
//try to fetch txid
$truncatedcardpan_element = $doc->getElementsByTagName('truncatedcardpan');
if ($txid_element->length >= 1) {
$payone_info["truncatedcardpan"] = (string) $truncatedcardpan_element->item(0)->nodeValue;
}
//try to fetch userid
$userid_element = $doc->getElementsByTagName('userid');
if ($userid_element->length >= 1) {
$payone_info["userid"] = (string) $userid_element->item(0)->nodeValue;
}
//try to fetch 3d secure payment status
$cc3d_reserved_element = $doc->getElementsByTagName('cc3d_reserved');
if ($cc3d_reserved_element->length >= 1) {
$payone_info["cc3d_reserved"] = (string) $cc3d_reserved_element->item(0)->nodeValue;
}
//try to fetch the paymentgateway
$paymentmethod_element = $doc->getElementsByTagName('paymentmethod');
if ($paymentmethod_element->length >= 1) {
$payone_info["paymentmethod"] = (string) $paymentmethod_element->item(0)->nodeValue;
}
} else {
eZLog::write("\$order is not an instance of eZOrder in extension/xrowpayone/autoloads/xrowpayoneoperator.php", $logName = 'xrowpayone.log', $dir = 'var/log');
}
if (count($payone_info) == 0) {
$operatorValue = false;
} else {
$operatorValue = $payone_info;
}
break;
}
}
示例6: __construct
/**
* @param SQLIImportHandlerOptions $options
*/
public function __construct( SQLIImportHandlerOptions $options = null )
{
parent::__construct( $options );
$ftpFolder = 'oscar1';
$modeUAT = false;
$this->startDate = microtime( true );
if ( $this->importINI->hasVariable( 'XMLImportSettings', 'ModeUAT' )
&& $this->importINI->variable( 'XMLImportSettings', 'ModeUAT' ) == 'enabled' )
{
$modeUAT = true;
}
if ( is_object($this->options) )
{
if ( $this->options->hasAttribute( 'reportLevel' ) && is_numeric($reportLevel = $this->options->attribute( 'reportLevel' )) )
XMLImportMonitor::setReportLevel( $reportLevel );
if ( $this->options->hasAttribute( 'ftpFolder' ) && in_array($this->options->attribute( 'ftpFolder' ),array('oscar1','oscar2') ) )
$ftpFolder = $this->options->attribute( 'ftpFolder' );
}
$this->rootImportFolder = $ftpFolder;
// Initialize sqliImportItem Statistics and logs
XMLImportDB::init( $this->importINI );
XMLImportMapping::init( $this->importINI );
eZLog::setMaxLogSize( 2000000 );
eZLog::setLogrotateFiles( 20 );
XMLImportMonitor::setOrigin($ftpFolder);
XMLImportMonitor::setSQLiImportItem( $this->getCurrentSQLiImportItem() );
XMLImportMonitor::pushStatistic( 'start_date', time() );
$this->fileHandler = XMLImportFileHandler::instance($this->importINI, $ftpFolder, $modeUAT);
XMLImportDataHandler::setIni ( $this->importINI );
XMLImportDataHandler::setFileHandler ( $this->fileHandler );
}
示例7: generateCustomErrorString
public function generateCustomErrorString($order, $response)
{
$payoneINI = eZINI::instance('xrowpayone.ini');
$custom_error_node_id = $payoneINI->variable('GeneralSettings', 'CustomErrorNode');
$error_fallback = $payoneINI->variable('GeneralSettings', 'CustomErrorFallback');
$error_fallback = ezpI18n::tr('extension/xrowpayone', $error_fallback);
if ($custom_error_node_id !== "disabled") {
if (is_numeric($custom_error_node_id)) {
$custom_error_node = eZContentObjectTreeNode::fetch($custom_error_node_id);
if (isset($custom_error_node) and $custom_error_node instanceof eZContentObjectTreeNode) {
$error_code = $response["errorcode"];
$data_map = $custom_error_node->dataMap();
$matrix_identifier = $payoneINI->variable('GeneralSettings', 'CustomErrorNodeMatrixIdentifier');
if (isset($data_map[$matrix_identifier])) {
$matrix_attribute_content = $data_map[$matrix_identifier]->content();
$matrix_data = $matrix_attribute_content->Matrix;
$matrix_rows = $matrix_data["rows"];
$matrix_rows = $matrix_rows["sequential"];
foreach ($matrix_rows as $row) {
//now map the error code to the matrix code
if ($row["columns"]["0"] == $error_code) {
$custom_errormessage = $row["columns"]["1"];
//return the translated code from object
return $custom_errormessage;
}
}
} else {
eZLog::write("No attribute identifier named " . $matrix_identifier . " found. Please check your configuration 'xrowpayone.ini', GeneralSettings', 'CustomErrorNode'", $logName = 'xrowpayone.log', $dir = 'var/log');
}
} else {
eZLog::write("Could not fetch node from settings 'xrowpayone.ini', GeneralSettings', 'CustomErrorNode' please check your configuration", $logName = 'xrowpayone.log', $dir = 'var/log');
}
}
}
//the worst fallback
return $error_fallback;
}
示例8: loadCache
function loadCache($reset = true, $placement = false)
{
eZDebug::accumulatorStart('ini', 'ini_load', 'Load cache');
if ($reset) {
$this->reset();
}
$cachedDir = self::CONFIG_CACHE_DIR;
$inputFileTime = 0;
$fileName = $this->cacheFileName($placement);
$cachedFile = $cachedDir . $fileName;
if ($placement) {
$this->PlacementCacheFile = $cachedFile;
} else {
$this->CacheFile = $cachedFile;
}
$loadCache = false;
if (file_exists($cachedFile)) {
$loadCache = true;
}
$useCache = false;
if ($loadCache) {
$useCache = true;
if (eZINI::isDebugEnabled()) {
eZDebug::writeNotice("Loading cache '{$cachedFile}' for file '" . $this->FileName . "'", __METHOD__);
}
include $cachedFile;
if (!isset($data) || !isset($data['rev']) || $data['rev'] != eZINI::CONFIG_CACHE_REV) {
if (eZINI::isDebugEnabled()) {
eZDebug::writeNotice("Old structure in cache file used, recreating '{$cachedFile}' to new structure", __METHOD__);
}
unset($data);
$this->reset();
$useCache = false;
} else {
if (self::$checkFileMtime === true || self::$checkFileMtime === $this->FileName) {
eZDebug::accumulatorStart('ini_check_mtime', 'ini_load', 'Check MTime');
$currentTime = time();
$cacheCreatedTime = strtotime($data['created']);
$iniFile = $data['file'];
$inputFiles = $data['files'];
foreach ($inputFiles as $inputFile) {
$fileTime = filemtime($inputFile);
if ($currentTime < $fileTime) {
eZDebug::writeError('Input file "' . $inputFile . '" has a timestamp higher then current time, ignoring to avoid infinite recursion!', __METHOD__);
} else {
if ($fileTime === false || $fileTime > $cacheCreatedTime) {
unset($data);
$this->reset();
$useCache = false;
break;
}
}
}
eZDebug::accumulatorStop('ini_check_mtime');
}
}
}
if ($useCache && isset($data)) {
$this->Charset = $data['charset'];
$this->ModifiedBlockValues = array();
if ($placement) {
$this->BlockValuesPlacement = $data['val'];
} else {
$this->BlockValues = $data['val'];
}
unset($data);
} else {
if (!isset($inputFiles)) {
eZDebug::accumulatorStart('ini_find_files', 'ini_load', 'Find INI Files');
$this->findInputFiles($inputFiles, $iniFile);
eZDebug::accumulatorStop('ini_find_files');
if (count($inputFiles) === 0) {
eZDebug::accumulatorStop('ini');
return false;
}
}
eZDebug::accumulatorStart('ini_files_parse', 'ini_load', 'Parse');
$this->parse($inputFiles, $iniFile, false, $placement);
eZDebug::accumulatorStop('ini_files_parse');
eZDebug::accumulatorStart('ini_files_save', 'ini_load', 'Save Cache');
$cacheSaved = $this->saveCache($cachedDir, $cachedFile, $placement ? $this->BlockValuesPlacement : $this->BlockValues, $inputFiles, $iniFile);
eZDebug::accumulatorStop('ini_files_save');
if ($cacheSaved) {
// Write log message to storage.log
eZLog::writeStorageLog($fileName, $cachedDir);
}
}
eZDebug::accumulatorStop('ini');
}
示例9: defaultExceptionHandler
/**
* Installs the default Exception handler
*
* @params Exception the exception
* @return void
*/
static public function defaultExceptionHandler( Exception $e )
{
if( PHP_SAPI != 'cli' )
{
header( 'HTTP/1.x 500 Internal Server Error' );
header( 'Content-Type: text/html' );
echo "An unexpected error has occurred. Please contact the webmaster.<br />";
if( eZDebug::isDebugEnabled() )
{
echo $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine();
}
}
else
{
$cli = eZCLI::instance();
$cli->error( "An unexpected error has occurred. Please contact the webmaster.");
if( eZDebug::isDebugEnabled() )
{
$cli->error( $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() );
}
}
eZLog::write( 'Unexpected error, the message was : ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine(), 'error.log' );
eZExecution::cleanup();
eZExecution::setCleanExit();
exit( 1 );
}
示例10: array
<?php
$Module =& $Params['Module'];
$order_id = $Params["orderID"];
if (isset($order_id)) {
eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card password ACCEPTED :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
//create the payment gateway - not the best position but at least it works here :)
$payment = xrowPaymentObject::createNew((int) $order_id, xrowPayoneCreditCardGateway::GATEWAY_STRING);
$payment->store();
//store paymentobject and approve it (required to finish the order)
$paymentObj = xrowPaymentObject::fetchByOrderID($order_id);
$paymentObj->approve();
eZLog::write("PENDING in step 2 ('preauthorisation') ::3D Secure Card password REDIRECTING to orderview :: for order ID " . $order_id, $logName = 'xrowpayone.log', $dir = 'var/log');
//redirect into the shopping process => finishing the order!
$Module->redirectTo('/shop/checkout/');
} else {
return $Module->handleError(1, 'kernel');
}
$Result = array();
示例11: setToken
/**
* @return string
*/
private function setToken()
{
$token = array();
$staticDir = StaticData::directory();
$outputFile = $staticDir.'/'.$this->tokenFileName;
if( file_exists( $outputFile ) )
{
$token = json_decode( file_get_contents($outputFile), true );
}
if( !file_exists( $outputFile ) || !isset($token['expiresIn']) || !isset($token['accessToken']) || ($token['expiresIn'] < time()) )
{
if( file_exists( $outputFile ) )
{
unlink($outputFile);
}
$requestData = array(
"clientId" => $this->clientId,
"clientSecret" => $this->clientSecret
);
$query = http_build_query( $requestData );
$smsApiUrl = "{$this->tokenRequestUrl}?{$query}";
eZLog::write( "Sending request to: {$smsApiUrl}", 'sms.log' );
$curl = curl_init($this->tokenRequestUrl);
curl_setopt_array($curl, array(
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $requestData,
CURLOPT_RETURNTRANSFER => true,
)
);
$token = curl_exec( $curl );
if( $token && isset($token['accessToken']) )
{
$logMessage = 'Recieved SMS Service responses: ' . var_export($token, true);
eZLog::write( $logMessage, 'sms.log' );
$token = json_decode($token, TRUE);
$token['expiresIn'] += time() + 300;
curl_close( $curl );
file_put_contents($outputFile, json_encode($token));
$this->smsToken = $token['accessToken'];
return true;
}
else
{
$logMessage = 'Error - Problem with recieved SMS Service responses: ' . var_export($token, true);
eZLog::write( $logMessage, 'sms.log' );
return false;
}
}
$this->smsToken = $token['accessToken'];
return true;
}
示例12: write
public function write($message)
{
eZLog::write($message, $this->logFile, $this->logDir);
}
示例13: rotateLog
static function rotateLog($fileName)
{
$maxLogrotateFiles = eZLog::maxLogrotateFiles();
if ($maxLogrotateFiles == 0) {
return;
}
for ($i = $maxLogrotateFiles; $i > 0; --$i) {
$logRotateName = $fileName . '.' . $i;
if (file_exists($logRotateName)) {
if ($i == $maxLogrotateFiles) {
@unlink($logRotateName);
} else {
$newLogRotateName = $fileName . '.' . ($i + 1);
eZFile::rename($logRotateName, $newLogRotateName);
}
}
}
if (file_exists($fileName)) {
$newLogRotateName = $fileName . '.' . 1;
eZFile::rename($fileName, $newLogRotateName);
return true;
}
return false;
}
示例14: store
function store($sub_dir = false, $suffix = false, $mimeData = false)
{
if (!$this->IsTemporary) {
eZDebug::writeError("Cannot store non temporary file: " . $this->Filename, "eZHTTPFile");
return false;
}
$this->IsTemporary = false;
$ini = eZINI::instance();
// $storage_dir = $ini->variable( "FileSettings", "VarDir" ) . '/' . $ini->variable( "FileSettings", "StorageDir" );
$storage_dir = eZSys::storageDirectory();
if ($sub_dir !== false) {
$dir = $storage_dir . "/{$sub_dir}/";
} else {
$dir = $storage_dir . "/";
}
if ($mimeData) {
$dir = $mimeData['dirpath'];
}
if (!$mimeData) {
$dir .= $this->MimeCategory;
}
if (!file_exists($dir)) {
if (!eZDir::mkdir($dir, false, true)) {
return false;
}
}
$suffixString = false;
if ($suffix != false) {
$suffixString = ".{$suffix}";
}
if ($mimeData) {
$dest_name = $mimeData['url'];
} else {
$dest_name = $dir . "/" . md5(basename($this->Filename) . microtime() . mt_rand()) . $suffixString;
}
if (!move_uploaded_file($this->Filename, $dest_name)) {
eZDebug::writeError("Failed moving uploaded file " . $this->Filename . " to destination {$dest_name}");
unlink($dest_name);
$ret = false;
} else {
$ret = true;
$this->Filename = $dest_name;
$perm = $ini->variable("FileSettings", "StorageFilePermissions");
$oldumask = umask(0);
chmod($dest_name, octdec($perm));
umask($oldumask);
// Write log message to storage.log
$storageDir = $dir . "/";
eZLog::writeStorageLog(basename($this->Filename), $storageDir);
}
return $ret;
}
示例15: startCacheGeneration
/**
* Starts cache generation for the current file.
*
* This is done by creating a file named by the original file name, prefixed
* with '.generating'.
*
* @return bool false if the file is being generated, true if it is not
**/
public function startCacheGeneration()
{
$generatingFilePath = $this->filePath . '.generating';
$ret = $this->backend->_startCacheGeneration($this->filePath, $generatingFilePath);
// generation granted
if ($ret['result'] == 'ok') {
$this->realFilePath = $this->filePath;
$this->filePath = $generatingFilePath;
$this->generationStartTimestamp = $ret['mtime'];
return true;
} elseif ($ret['result'] == 'ko') {
return $ret['remaining'];
} else {
eZLog::write("An error occured starting cache generation on '{$generatingFilePath}'", 'cluster.log');
return false;
}
}