本文整理汇总了PHP中logger::emerg方法的典型用法代码示例。如果您正苦于以下问题:PHP logger::emerg方法的具体用法?PHP logger::emerg怎么用?PHP logger::emerg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger
的用法示例。
在下文中一共展示了logger::emerg方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exception
function exception(Exception $e)
{
logger::emerg("Unhandled exception: (%s) %s in %s:%d", get_class($e), $e->getMessage(), str_replace(BASE_PATH, '', $e->getFile()), $e->getLine());
Console::debugEx(0, get_class($e), "Unhandled exception: (%s) %s in %s:%d", get_class($e), $e->getMessage(), str_replace(BASE_PATH, '', $e->getFile()), $e->getLine());
$f = file($e->getFile());
foreach ($f as $i => $line) {
$mark = $i + 1 == $e->getLine() ? '=> ' : ' ';
$f[$i] = sprintf(' %05d. %s', $i + 1, $mark) . $f[$i];
$f[$i] = str_replace("\n", "", $f[$i]);
}
$first = $e->getLine() - 4;
if ($first < 0) {
$first = 0;
}
$last = $e->getLine() + 3;
if ($last >= count($f)) {
$last = count($f) - 1;
}
$source = join("\n", array_slice($f, $first, $last - $first));
Console::debugEx(0, get_class($e), Console::backtrace(0, $e->getTrace(), true));
Console::debugEx(LOG_LOG, "Exception", "Source dump of %s:\n%s", str_replace(BASE_PATH, '', $e->getFile()), $source);
$rv = 1;
logger::emerg("Exiting with return code %d after exception.", $rv);
Console::debugEx(LOG_BASIC, __CLASS__, "Exiting with return code %d after exception.", $rv);
}
示例2: exec
/**
* 多进程执行队列
*
* @param string $queue_name
* @param int $max
* @param string $phpExec
*/
public function exec($queue_name, $max, $phpExec = '')
{
$max = $max ? $max : 1;
$time = time();
while (1) {
//执行死循环
try {
while ($this->threadRunning < $max && !system_queue::instance()->is_end($queue_name)) {
$this->running[] = new system_queue_consumer_proc_thread($queue_name, $phpExec);
usleep(200000);
$this->threadRunning++;
}
} catch (Exception $e) {
switch ($e->getCode()) {
case 30001:
logger::emerg(sprintf('ERROR:%d @ %s', $e->getCode(), $e->getMessage));
exit;
}
}
//检查是否已经结束
if ($this->threadRunning == 0) {
break;
}
//等待代码执行完成
usleep(50000);
$thread_close = array();
//记录线程的关闭状态
//检查已经完成的任务
foreach ($this->running as $idx => $thread) {
if (!$thread->isRunning() || $thread->isOverExecuted($max)) {
$thread_close[] = proc_close($thread->resource);
//记录线程的关闭状态
unset($this->running[$idx]);
$this->threadRunning--;
}
}
}
}
示例3: main
function main()
{
$tagctl = app::get('desktop')->model('tag');
$tag_rel = app::get('desktop')->model('tag_rel');
$tag_name = $_POST['tag']['name'];
$tag_stat = $_POST['tag']['stat'];
$tag_ids = $_POST['tag']['tag_id'];
if ($_POST['filter']) {
$obj = $this->object;
$schema = $obj->get_schema();
$idColumn = $schema['idColumn'];
$filter = unserialize($_POST['filter']);
logger::emerg('---zz' . var_export($filter, true));
$rows = $obj->getList($idColumn, $filter, 0, -1);
foreach ($rows as $value) {
$pkey[] = $value[$idColumn];
}
}
$pkey = (array) $pkey;
//没有选择任何标签情况 time:2010-11-24
if (!$tag_stat || !is_array($tag_stat)) {
header('Content-Type:application/json; charset=utf-8');
echo '{error:"' . app::get('desktop')->_('标签设置失败!') . '"}';
exit;
}
foreach ($tag_stat as $key => $value) {
if ($value == 2) {
continue;
}
if ($value == 1) {
//取消标签
$tag_item = $tagctl->getList('tag_id', array('tag_name' => $tag_name[$key], 'tag_type' => $this->object->table_name()));
foreach ($pkey as $id) {
if (!intval($id) && !intval($tag_item[0]['tag_id'])) {
continue;
}
$tag_rel->delete(array('tag_id' => $tag_item[0]['tag_id'], 'rel_id' => $id));
}
} else {
//设置标签
$tag_item = $tagctl->getList('tag_id', array('tag_name' => $tag_name[$key], 'tag_type' => $this->object->table_name()));
if ($tag_item && !$tag_ids[$key]) {
header('Content-Type:application/json; charset=utf-8');
echo '{error:"' . app::get('desktop')->_('标签重复添加!') . '",_:null}';
exit;
}
$data['tag_type'] = $this->object->table_name();
$data['tag_name'] = $tag_name[$key];
$data['app_id'] = $this->app->app_id;
$tagctl->save($data);
logger::emerg('---' . var_export($data, true));
logger::emerg('---xx' . var_export($pkey, true));
if ($data['tag_id']) {
$data2['tag']['tag_id'] = $data['tag_id'];
unset($data['tag_id']);
foreach ($pkey as $id) {
$data2['tag_type'] = $this->object->table_name();
$data2['app_id'] = $this->app->app_id;
$data2['rel_id'] = $id;
//save修改了data tag_id的位置 edit by jiaolei time:2010-11-17 mantis:0019313
$data2['tag']['tag_id'] or $data2['tag']['tag_id'] = $data2['tag_id'];
logger::emerg("===" . var_export($data2, true));
$tag_rel->save($data2);
}
}
}
}
//header('Content-Type:application/json; charset=utf-8');
$res['success'] = app::get('desktop')->_('标签设置成功');
return response::json($res);
}
示例4: stopFrontendCrawler
/**
* @static
* @param bool $playNice
* @return bool
*/
public static function stopFrontendCrawler($playNice = true, $isFrontendCall = false)
{
logger::debug("SearchPhp_Plugin: forcing frontend crawler stop, play nice: [ {$playNice} ]");
self::setStopLock("frontend", true);
//just to make sure nothing else starts the crawler right now
self::setCrawlerState("frontend", "started", false);
$configArray = self::getSearchConfigArray();
$maxThreads = $configArray['search']['frontend']['crawler']['maxThreads'];
$db = Pimcore_Resource_Mysql::get();
$db->query("DROP TABLE IF EXISTS `plugin_searchphp_frontend_crawler_todo`;");
$db->query("DROP TABLE IF EXISTS `plugin_searchphp_indexer_todo`;");
logger::debug("SearchPhp_Plugin: forcing frontend crawler stop - dropped tables");
sleep(1);
$pidFiles = array("maintainance_crawler-indexer");
for ($i = 1; $i <= $maxThreads; $i++) {
$pidFiles[] = "maintainance_crawler-" . $i;
}
$counter = 1;
while ($pidFiles and count($pidFiles) > 0 and $counter < 10) {
sort($pidFiles);
for ($i = 0; $i < count($pidFiles); $i++) {
$file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $pidFiles[$i];
if (!is_file($file)) {
unset($pidFiles[$i]);
}
}
sleep(1);
$counter++;
}
if (!$playNice) {
if (is_file(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/maintainance_SearchPhp_Plugin.pid" and $isFrontendCall)) {
$pidFiles[] = "maintainance_SearchPhp_Plugin.pid";
}
//delete pid files of all processes
for ($i = 0; $i < count($pidFiles); $i++) {
$file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/" . $pidFiles[$i];
if (is_file($file) and !unlink($file)) {
logger::emerg("SearchPhp_Plugin: : Trying to force stop crawler, but cannot delete [ {$file} ]");
}
if (!is_file($file)) {
unset($pidFiles[$i]);
}
}
}
self::setStopLock("frontend", false);
if (!$pidFiles or count($pidFiles) == 0) {
self::setCrawlerState("frontend", "finished", false);
return true;
}
return false;
}
示例5: generateSitemap
/**
* @return void
*/
public static function generateSitemap()
{
$sitemapDir = PIMCORE_WEBSITE_PATH . "/var/search/sitemap";
if (is_dir($sitemapDir) and !is_writable($sitemapDir)) {
$sitemapDirAvailable = false;
} else {
if (!is_dir($sitemapDir)) {
$sitemapDirAvailable = mkdir($sitemapDir, 0755, true);
chmod($sitemapDir, 0755);
} else {
$sitemapDirAvailable = true;
}
}
if ($sitemapDirAvailable) {
$db = Pimcore_Resource_Mysql::get();
$hosts = $db->fetchAll("SELECT DISTINCT host from plugin_searchphp_contents");
if (is_array($hosts)) {
//create domain sitemaps
foreach ($hosts as $row) {
$host = $row['host'];
$data = $db->fetchAll("SELECT * FROM plugin_searchphp_contents WHERE host = '" . $host . "' AND content != 'canonical' AND content!='noindex' ORDER BY uri", array());
$name = str_replace(".", "-", $host);
$filePath = $sitemapDir . "/sitemap-" . $name . ".xml";
$fh = fopen($filePath, 'w');
fwrite($fh, '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n");
fwrite($fh, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
fwrite($fh, "\r\n");
foreach ($data as $row) {
$uri = str_replace("&pimcore_outputfilters_disabled=1", "", $row['uri']);
$uri = str_replace("?pimcore_outputfilters_disabled=1", "", $uri);
fwrite($fh, '<url>' . "\r\n");
fwrite($fh, ' <loc>' . htmlspecialchars($uri, ENT_QUOTES) . '</loc>' . "\r\n");
fwrite($fh, '</url>' . "\r\n");
}
fwrite($fh, '</urlset>' . "\r\n");
fclose($fh);
}
//create sitemap index file
$filePath = $sitemapDir . "/sitemap.xml";
$fh = fopen($filePath, 'w');
fwrite($fh, '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n");
fwrite($fh, '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
fwrite($fh, "\r\n");
foreach ($hosts as $row) {
$host = $row['host'];
$name = str_replace(".", "-", $host);
//first host must be main domain - see hint in plugin settings
$currenthost = $hosts[0]['host'];
fwrite($fh, '<sitemap>' . "\r\n");
fwrite($fh, ' <loc>http://' . $currenthost . "/plugin/SearchPhp/frontend/sitemap/?sitemap=sitemap-" . $name . ".xml" . '</loc>' . "\r\n");
fwrite($fh, '</sitemap>' . "\r\n");
}
fwrite($fh, '</sitemapindex>' . "\r\n");
fclose($fh);
} else {
logger::warn("SearchPhp_Tool: could not generate sitemaps, did not find any hosts in index.");
}
} else {
logger::emerg("SearchPhp_Tool: Cannot generate sitemap. Sitemap directory [ " . $sitemapDir . " ] not available/not writeable and cannot be created");
}
}