本文整理汇总了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);
}