本文整理匯總了PHP中printLog函數的典型用法代碼示例。如果您正苦於以下問題:PHP printLog函數的具體用法?PHP printLog怎麽用?PHP printLog使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了printLog函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: errorLog
function errorLog($str)
{
global $logFileHandle, $adminEmail;
printLog($str);
closeLogFile();
exit;
}
示例2: run
public function run(array $params)
{
global $f3;
// 1. reset 整個數據庫
printLog('Begin Reset Database', 'ResetData');
$dbEngine = DataMapper::getDbEngine();
// 解析 sql 文件,導入數據
$sqlFileContent = file_get_contents(CONSOLE_PATH . '/../install/Asset/data/bzfshop.sql');
$sqlFileContent = SqlHelper::removeComment($sqlFileContent);
$sqlArray = SqlHelper::splitToSqlArray($sqlFileContent, ';');
unset($sqlFileContent);
foreach ($sqlArray as $sqlQuery) {
$queryObject = $dbEngine->prepare($sqlQuery);
$queryObject->execute();
unset($sqlQuery);
unset($queryObject);
}
unset($sqlArray);
printLog('End Reset Database', 'ResetData');
// 2. 刪除 /data 目錄下的所有目錄
printLog('remove everything under /data', 'ResetData');
$this->removeAllDirInsideDir($f3->get('sysConfig[data_path_root]'));
// 3. 刪除 RunTime 目錄下所有目錄
printLog('remove everything in Runtime', 'ResetData');
$this->removeAllDirInsideDir($f3->get('sysConfig[runtime_path]') . DIRECTORY_SEPARATOR . 'Log/');
$this->removeAllDirInsideDir($f3->get('sysConfig[runtime_path]') . DIRECTORY_SEPARATOR . 'Smarty/');
$this->removeAllDirInsideDir($f3->get('sysConfig[runtime_path]') . DIRECTORY_SEPARATOR . 'Temp/');
// 4. 清除 F3 的緩存
$f3->clear('CACHE');
printLog('ResetData Done', 'ResetData');
}
示例3: updateFieldForTable
/**
* Replace {{skin url=""}} with {{view url=""}} for given table field
*
* @param \Magento\Framework\ObjectManagerInterface $objectManager
* @param string $table
* @param string $col
* @return void
*/
function updateFieldForTable($objectManager, $table, $col)
{
/** @var $installer \Magento\Framework\Setup\ModuleDataSetupInterface */
$installer = $objectManager->create('\\Magento\\Framework\\Setup\\ModuleDataSetupInterface');
$installer->startSetup();
$table = $installer->getTable($table);
echo '-----' . "\n";
if ($installer->getConnection()->isTableExists($table)) {
echo 'Table `' . $table . "` processed\n";
$indexList = $installer->getConnection()->getIndexList($table);
$pkField = array_shift($indexList[$installer->getConnection()->getPrimaryKeyName($table)]['fields']);
/** @var $select \Magento\Framework\DB\Select */
$select = $installer->getConnection()->select()->from($table, ['id' => $pkField, 'content' => $col]);
$result = $installer->getConnection()->fetchPairs($select);
echo 'Records count: ' . count($result) . ' in table: `' . $table . "`\n";
$logMessages = [];
foreach ($result as $recordId => $string) {
$content = str_replace('{{skin', '{{view', $string, $count);
if ($count) {
$installer->getConnection()->update($table, [$col => $content], $installer->getConnection()->quoteInto($pkField . '=?', $recordId));
$logMessages['replaced'][] = 'Replaced -- Id: ' . $recordId . ' in table `' . $table . '`';
} else {
$logMessages['skipped'][] = 'Skipped -- Id: ' . $recordId . ' in table `' . $table . '`';
}
}
if (count($result)) {
printLog($logMessages);
}
} else {
echo 'Table `' . $table . "` was not found\n";
}
$installer->endSetup();
echo '-----' . "\n";
}
示例4: run
public function run(array $params)
{
$pageSize = 500;
$goodsBasicService = new Goods();
$totalGoodsCount = SearchHelper::count(SearchHelper::Module_Goods, array());
for ($pageNo = 0; $pageNo * $pageSize < $totalGoodsCount; $pageNo++) {
// 查詢商品
$goodsArray = SearchHelper::search(SearchHelper::Module_Goods, 'g.goods_id', array(), array(array('g.goods_id', 'asc')), $pageNo * $pageSize, $pageSize);
foreach ($goodsArray as $goodsItem) {
$goods_id = $goodsItem['goods_id'];
printLog('begin process goods [' . $goods_id . ']');
$goodsObj = $goodsBasicService->loadGoodsById($goods_id);
if ($goodsObj->isEmpty()) {
printLog('goods [' . $goods_id . '] is empty');
} else {
$goodsObj->goods_desc = str_replace('tuan.bangzhufu.com', 'www.bangzhufu.com', $goodsObj->goods_desc);
$goodsObj->goods_desc = str_replace('cdn.bzfshop.net', 'img.bangzhufu.com', $goodsObj->goods_desc);
$goodsObj->goods_desc = preg_replace('!/Goods/View/goods_id~([0-9]+).html!', '/Goods/View/goods_id-\\1.html', $goodsObj->goods_desc);
$goodsObj->update_time = \Core\Helper\Utility\Time::gmTime();
$goodsObj->save();
}
unset($goodsObj);
printLog('end process goods [' . $goods_id . ']');
}
}
}
示例5: verifyNotify
/**
* 針對notify_url驗證消息是否是支付寶發出的合法消息
*
* @return 驗證結果
*/
function verifyNotify()
{
if (empty($_POST)) {
//判斷POST來的數組是否為空
return false;
} else {
//生成簽名結果
$isSign = $this->getSignVeryfy($_POST, $_POST["sign"]);
//獲取支付寶遠程服務器ATN結果(驗證是否是支付寶發來的消息)
$responseTxt = 'true';
if (!empty($_POST["notify_id"])) {
$responseTxt = $this->getResponse($_POST["notify_id"]);
}
//驗證
//$responsetTxt的結果不是true,與服務器設置問題、合作身份者ID、notify_id一分鍾失效有關
//isSign的結果不是true,與安全校驗碼、請求時的參數格式(如:帶自定義參數等)、編碼格式有關
if (preg_match("/true\$/i", $responseTxt) && $isSign) {
return true;
}
//失敗,寫日誌記錄
if ($isSign) {
$isSignStr = 'true';
} else {
$isSignStr = 'false';
}
$log_text = "Alipay responseTxt=" . $responseTxt . " notify_url_log:isSign=" . $isSignStr . ",";
$log_text = $log_text . createLinkString($_POST);
printLog($log_text, 'PAYMENT', Base::ERROR);
return false;
}
}
示例6: printLogL
function printLogL($str, $level)
{
for ($i = 1; $i <= $level; ++$i) {
$str = "\t" . $str;
}
printLog($str);
}
示例7: getSearchInstance
/**
* 生成搜索的具體 instance
*
* @return ISearch
* @throws \InvalidArgumentException
*/
protected static function getSearchInstance()
{
if (!static::$searchInstance) {
static::$searchInstance = new static::$searchImplementClass();
if (!static::$searchInstance instanceof ISearch) {
throw new \InvalidArgumentException(static::$searchImplementClass . ' is invalid search implement');
}
if (!static::$searchInstance->init(static::$searchImplementInitParamArray)) {
printLog(static::$searchImplementClass . ' init failed with param ' . print_r(static::$searchImplementInitParamArray, true), __CLASS__, \Core\Log\Base::ERROR);
throw new \InvalidArgumentException('can not init ' . static::$searchImplementClass);
}
}
return static::$searchInstance;
}
示例8: loadTaskClass
/**
* 根據 task_class 參數加載並實例化 Cron 任務對象
*
* @param string $task_class
*
* @return ICronTask 對象
*/
public static function loadTaskClass($task_class)
{
if (!class_exists($task_class)) {
printLog('class [' . $task_class . '] does not exist', __CLASS__, BaseLog::ERROR);
return null;
}
$taskInstance = new $task_class();
if (!is_a($taskInstance, '\\Core\\Cron\\ICronTask')) {
printLog('class [' . $task_class . '] does not implement ICronTask', __CLASS__, BaseLog::ERROR);
unset($taskInstance);
return null;
}
return $taskInstance;
}
示例9: addAutoloadPath
/**
* 添加一個用於 class autoload 的路徑
*
* 注意:我們允許 plugin 覆蓋係統本身的功能,所以如果你的 path 裏麵包含和係統名字一樣的 Controller,
* 你就可能會覆蓋係統已有的操作
*
* @param string $path
* @param bool $addToHead 是否加入搜索路徑的開頭,如果你的類不常用,請加入到搜索末尾有利於提高搜索效率
*
*/
public static function addAutoloadPath($path, $addToHead = false)
{
if (!file_exists($path)) {
printLog('[' . $path . '] does not exist', 'SystemHelper', \Core\Log\Base::WARN);
return;
}
$path = realpath($path);
global $f3;
if ($addToHead) {
// 加到搜索路徑開頭
$f3->set('AUTOLOAD', $path . '/;' . $f3->get('AUTOLOAD'));
} else {
// 加到搜索路徑末尾
$f3->set('AUTOLOAD', $f3->get('AUTOLOAD') . $path . '/;');
}
}
示例10: __callstatic
/**
* 調用對應的對象方法
*
* @param $func
* @param array $args
*
* @return mixed
* @throws \InvalidArgumentException
*/
static function __callstatic($func, array $args)
{
foreach (static::$registerClassArray as $className => $initParam) {
$instance = static::loadClassInstance($className, $initParam);
// 檢查方法是否存在
if (!method_exists($instance, $func)) {
throw new \InvalidArgumentException('class [' . $className . '] has no method [' . $func . ']');
}
global $f3;
if ($f3->get('DEBUG') > 2) {
printLog('call [' . $className . '] method [' . $func . ']', __CLASS__, \Core\Log\Base::DEBUG);
}
// 調用對象方法
call_user_func_array(array($instance, $func), $args);
// 釋放內存
unset($instance);
}
}
示例11: loadModule
private function loadModule($searchType)
{
// 檢查對應的搜索模塊是否存在
$filePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . $searchType . '.php';
if (!file_exists($filePath)) {
// 沒有對應的搜索模塊,失敗
printLog($searchType . ' does not exist', __CLASS__, \Core\Log\Base::ERROR);
return false;
}
require_once $filePath;
// 生成搜索模塊
$searchType = __NAMESPACE__ . '\\' . $searchType;
$searchModule = new $searchType();
if (!$searchModule || !$searchModule instanceof ISearch) {
throw new \InvalidArgumentException($searchType . ' is an invalid ISearch');
}
return $searchModule;
}
示例12: run
public function run(array $params)
{
global $f3;
// 每次處理多少條記錄
$batchProcessCount = 100;
// 圖片所在的根目錄
$dataPathRoot = $f3->get('sysConfig[data_path_root]');
$image_thumb_width = $f3->get('sysConfig[image_thumb_width]');
$image_thumb_height = $f3->get('sysConfig[image_thumb_height]');
$goodsGalleryService = new GoodsGalleryService();
$baseService = new BaseService();
$totalGoodsGalleryCount = $baseService->_countArray('goods_gallery', null);
// 記錄處理開始
for ($offset = 0; $offset < $totalGoodsGalleryCount; $offset += $batchProcessCount) {
$goodsGalleryArray = $baseService->_fetchArray('goods_gallery', '*', null, array('order' => 'img_id asc'), $offset, $batchProcessCount);
foreach ($goodsGalleryArray as $goodsGalleryItem) {
if (!is_file($dataPathRoot . '/' . $goodsGalleryItem['img_original'])) {
continue;
// 文件不存在,不處理
}
$pathInfoArray = pathinfo($goodsGalleryItem['img_original']);
//生成縮略圖
$imageThumbFileRelativeName = $pathInfoArray['dirname'] . '/' . $pathInfoArray['filename'] . '_' . $image_thumb_width . 'x' . $image_thumb_height . '.jpg';
//重新生存縮略圖
printLog('Re-generate File :' . $imageThumbFileRelativeName);
StorageImageHelper::resizeImage($dataPathRoot, $goodsGalleryItem['img_original'], $imageThumbFileRelativeName, $image_thumb_width, $image_thumb_height);
// 更新 goods_gallery 設置
printLog('update goods_gallery img_id [' . $goodsGalleryItem['img_id'] . ']');
$goodsGallery = $goodsGalleryService->loadGoodsGalleryById($goodsGalleryItem['img_id']);
if (!$goodsGallery->isEmpty()) {
$goodsGallery->thumb_url = $imageThumbFileRelativeName;
$goodsGallery->save();
}
// 主動釋放資源
unset($goodsGallery);
unset($pathInfoArray);
unset($imageThumbFileRelativeName);
}
unset($goodsGalleryArray);
printLog('re-generate thumb image offset : ' . $offset);
}
printLog('re-generate thumb image finished , offset : ' . $offset);
}
示例13: SelectValue
public static function SelectValue($retrieveValue, $tablename, $conditions)
{
$mydb = self::getFactory()->getConnection();
$values = array();
$condclauses = array();
foreach ($conditions as $key => $value) {
$condclauses[] = $key . "=?";
$values[] = $value;
}
$stmtString = "SELECT " . $retrieveValue . " FROM " . $tablename . " WHERE ";
$stmtString .= getArrayInString($condclauses, 'and');
$stmt = $mydb->prepare($stmtString);
$start = microtime(true);
$stmt->execute($values);
$time = microtime(true) - $start;
self::$log[] = array('query' => $stmt->queryString, 'time' => round($time * 1000, 3));
return $stmt->fetchColumn();
printLog();
}
示例14: run
public function run(array $params)
{
printLog('Begin CreateDictionary', 'CreateDictionary');
$metaDictionaryService = new MetaDictionaryService();
// 用於 order_refer 中顯示訂單來源渠道 utm_source
$metaDictionaryService->saveWord('SELF', '網站自身', '網站自身', '');
$metaDictionaryService->saveWord('TUAN360CPS', '360團購導航', '360團購導航', '');
$metaDictionaryService->saveWord('YIQIFACPS', '億起發', '億起發', '');
$metaDictionaryService->saveWord('DUOMAICPS', '多麥', '多麥', '');
// 用於 order_refer 中顯示訂單來源渠道 utm_medium
$metaDictionaryService->saveWord('QQCAIBEI', 'QQ彩貝', 'QQ彩貝', '');
$metaDictionaryService->saveWord('TUAN360TEQUAN', '360特權', '360特權', '');
$metaDictionaryService->saveWord('TUAN360WAP', '360手機WAP', '360手機WAP', '');
// 用於 order_refer 中顯示訂單登陸方式 login_type
$metaDictionaryService->saveWord('normal', '普通登陸', '普通登陸', '');
$metaDictionaryService->saveWord('qqcaibei', 'QQ彩貝登陸', 'QQ彩貝登陸', '');
$metaDictionaryService->saveWord('qqlogin', 'QQ登陸', 'QQ登陸', '');
$metaDictionaryService->saveWord('tuan360auth', '360聯合登陸', '360聯合登陸', '');
printLog('Finish CreateDictionary', 'CreateDictionary');
}
示例15: run
public function run(array $params)
{
global $f3;
// 每次處理多少條記錄
$batchProcessCount = 100;
$baseService = new BaseService();
$totalGoodsCount = $baseService->_countArray('goods', null);
// 記錄處理開始
for ($offset = 0; $offset < $totalGoodsCount; $offset += $batchProcessCount) {
$goodsArray = $baseService->_fetchArray('goods', 'goods_id', null, array('order' => 'goods_id asc'), $offset, $batchProcessCount);
foreach ($goodsArray as $goodsItem) {
$sql = "update " . DataMapper::tableName('goods') . ' set ' . ' user_buy_number = (select sum(goods_number) from ' . DataMapper::tableName('order_goods') . ' where goods_id = ? )' . ' ,user_pay_number = (select sum(goods_number) from ' . DataMapper::tableName('order_goods') . ' where goods_id = ? and order_goods_status > 0)' . ' where goods_id = ? order by goods_id asc limit 1 ';
$dbEngine = DataMapper::getDbEngine();
$dbEngine->exec($sql, array(1 => $goodsItem['goods_id'], $goodsItem['goods_id'], $goodsItem['goods_id']));
}
unset($goodsArray);
printLog('calculate goods buy number offset : ' . $offset);
}
printLog('calculate goods buy number finished , offset : ' . $offset);
}