当前位置: 首页>>代码示例>>PHP>>正文


PHP Error::log方法代码示例

本文整理汇总了PHP中Error::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::log方法的具体用法?PHP Error::log怎么用?PHP Error::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Error的用法示例。


在下文中一共展示了Error::log方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build

 public static function build($data, $allowCallbacks = true)
 {
     //  Check it's being called with AJAX
     //  But only if we tell it to
     if (!self::validOrigin()) {
         Error::log('Invalid origin');
         exit;
     }
     //  I do love a bit of json
     Response::set(200);
     //  Store our encoded data as a variable
     $json = json_encode($data);
     //  Just make sure
     if (!$json) {
         return;
     }
     //  Do we allow ?callback=test parameters?
     if ($allowCallbacks === true) {
         $callback = preg_replace('/[^0-9a-z\\-_\\d]/i', '', Input::get('callback'));
         if ($callback) {
             $json = $callback . '(' . $json . ');';
         }
     }
     //  Give 'em what they wanted
     return $json;
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:26,代码来源:ajax.php

示例2: getXMLFromCache

 /**
  * @return \SimpleXMLElement
  *
  * Handle the retrieval of the XML data
  */
 public function getXMLFromCache()
 {
     try {
         //Check cache file exists
         if (is_dir(ROOT . '/cache')) {
             $this->localXMLpath = ROOT . '/cache/' . $this->stateAbbrev . '.xml';
             //Check if the local file exists and when last modified
             if (is_file($this->localXMLpath)) {
                 $stats = stat($this->localXMLpath);
                 $timeLastAccessed = $stats[8] + TIMER;
                 //60 sec * 30 = 30 Mins = 1800 sec
                 if (time() > $timeLastAccessed) {
                     //Compare the modified file times and download if needed
                     $this->compareTimestamps();
                 }
             } else {
                 //File does not exist, download file
                 $this->downloadFile();
             }
             //Return true the file is up to date
             return @simplexml_load_file($this->localXMLpath);
         } else {
             Error::log('Cache folder does not exist at /src/cache.');
             throw new \Exception('Cache folder does not exist at /src/cache.');
         }
     } catch (\Exception $e) {
         echo 'Exception thrown! ', $e->getMessage(), "\n";
     }
 }
开发者ID:moto485,项目名称:bom-weather,代码行数:34,代码来源:LoadStateWeather.php

示例3: log

function log($s)
{
    static $error;
    if (is_null($error)) {
        $error = new Error();
    }
    $error->log($s);
}
开发者ID:raynaldmo,项目名称:php-education,代码行数:8,代码来源:Error.php

示例4: __construct

 public function __construct()
 {
     $object = Storage::get('db', false);
     //  Sanity check
     if ($object === false) {
         return Error::log('Could not get Database class');
     }
     $this->db = $this->database = $object;
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:9,代码来源:model.php

示例5: stampResource

 /**
  * Stamps the current datestamp and ip_address.
  */
 public static function stampResource(\Resource $resource, $action)
 {
     $activity = new Activity();
     $activity->class_name = $resource->getNamespace();
     $activity->resource_id = $resource->getId();
     $activity->action = $action;
     if (\User\Current::isLoggedIn()) {
         $activity->user_id = \User\Current::getUserId();
     }
     try {
         $activity->ip_address = \Server::getUserIp();
     } catch (Exception $e) {
         $activity->ip_address = '0.0.0.0';
         \Error::log($e);
     }
     \ResourceFactory::saveResource($activity);
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:20,代码来源:Activity.php

示例6: Run

 public function Run()
 {
     //        set_exception_handler(array($this, "_exceptionHendler"));
     $this->_startTime = microtime(true);
     Log::setDebug();
     // init Session
     if (Settings::$sessionAutostart) {
         self::$_oSession = new Settings::$sessionType();
     }
     // init DB
     if (Settings::$dbEnable) {
         self::$_oDb = new Settings::$dbDriver();
     }
     // init cache
     if (Settings::$cacheEnable) {
         self::$_oCache = new Settings::$cacheDriver();
     }
     $this->startSystemLog();
     Error::log();
     $this->oView = new View();
     $this->oRouter = new Router();
     $this->run = true;
 }
开发者ID:jjechev,项目名称:phpTdConvert,代码行数:23,代码来源:Core.php

示例7: catch

/**
 * Helpers
 */
require APP . 'helpers' . EXT;
/**
 * Anchor setup
 */
try {
    Anchor::setup();
} catch (Exception $e) {
    if (ini_get('display_errors') != "1") {
        echo "<h1>Something went wrong, please notify the owner of the site</h1>";
    } else {
        Error::exception($e);
    }
    Error::log($e);
    die;
}
/**
 * Import defined routes
 */
if (is_admin()) {
    // Set posts per page for admin
    Config::set('admin.posts_per_page', 6);
    require APP . 'routes/admin' . EXT;
    require APP . 'routes/categories' . EXT;
    require APP . 'routes/comments' . EXT;
    require APP . 'routes/fields' . EXT;
    require APP . 'routes/menu' . EXT;
    require APP . 'routes/metadata' . EXT;
    require APP . 'routes/pages' . EXT;
开发者ID:anchorcms,项目名称:anchor-cms,代码行数:31,代码来源:run.php

示例8: install

 /**
  * Updated: 19 Feb 2010
  * Boost used to allow pausing for entering information. This was removed.
  * @param $inBoost
  * @param $inBranch
  * @param $home_dir
  * @return unknown_type
  */
 public function install($inBoost = true, $inBranch = false, $home_dir = NULL)
 {
     $content = array();
     $dir_content = array();
     if ($inBranch && !empty($home_dir)) {
         $GLOBALS['boost_branch_dir'] = $home_dir;
     }
     if (!$this->checkDirectories($dir_content, null, false)) {
         return implode('<br />', $dir_content);
     }
     if (!$this->isModules()) {
         return PHPWS_Error::get(BOOST_NO_MODULES_SET, 'boost', 'install');
     }
     $last_mod = end($this->modules);
     foreach ($this->modules as $title => $mod) {
         $title = trim($title);
         if ($this->getStatus($title) == BOOST_DONE) {
             continue;
         }
         if ($this->getCurrent() != $title && $this->getStatus($title) == BOOST_NEW) {
             $this->setCurrent($title);
             $this->setStatus($title, BOOST_START);
         }
         $content[] = dgettext('boost', 'Installing') . ' - ' . $mod->getProperName();
         if ($this->getStatus($title) == BOOST_START && $mod->isImportSQL()) {
             $content[] = dgettext('boost', 'Importing SQL install file.');
             $db = new PHPWS_DB();
             $result = $db->importFile($mod->getDirectory() . 'boost/install.sql');
             if (PHPWS_Error::isError($result)) {
                 PHPWS_Error::log($result);
                 $this->addLog($title, dgettext('boost', 'Database import failed.'));
                 $content[] = dgettext('boost', 'An import error occurred.');
                 $content[] = dgettext('boost', 'Check your logs for more information.');
                 return implode('<br />', $content) . '<br />' . implode('<br />', $content);
             } else {
                 $content[] = dgettext('boost', 'Import successful.');
             }
         }
         try {
             $result = $this->onInstall($mod, $content);
             if ($result === true) {
                 $this->setStatus($title, BOOST_DONE);
                 $this->createDirectories($mod, $content, $home_dir);
                 $this->registerModule($mod, $content);
                 $continue = true;
             } elseif ($result === -1) {
                 // No installation file (install.php) was found.
                 $this->setStatus($title, BOOST_DONE);
                 $this->createDirectories($mod, $content, $home_dir);
                 $this->registerModule($mod, $content);
                 $continue = true;
             } elseif (PHPWS_Error::isError($result)) {
                 $content[] = dgettext('boost', 'There was a problem in the installation file:');
                 $content[] = '<b>' . $result->getMessage() . '</b>';
                 $content[] = '<br />';
                 PHPWS_Error::log($result);
                 $continue = false;
             }
         } catch (\Exception $e) {
             $content[] = implode('<br />', $content);
             $content[] = dgettext('boost', 'There was a problem in the installation file:');
             $content[] = '<b>' . $e->getMessage() . '</b>';
             $content[] = '<br />';
             \Error::log($e);
             $continue = false;
         }
         // in case install changes translate directory
     }
     if ($last_mod->title == $title) {
         // H0120
         $content[] = dgettext('boost', 'Installation complete!');
         $this->addLog($title, str_replace("\n\n\n", "\n", implode("\n", str_replace('<br />', "\n", $content))));
     }
     return implode('<br />', $content);
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:83,代码来源:Boost.php

示例9: handler

	/**
	 * Replaces Kohana's `Kohana::exception_handler()` method. This does the
	 * same thing, but also adds email functionality and the ability to perform
	 * an action in response to the exception. These actions and emails are
	 * customizable per type in the config file for this module.
	 *
	 * @uses		Kohana::exception_text
	 * @param \Exception $e
	 * @internal param \exception $object object
	 * @return	boolean
	 */
	public static function handler(Exception $e)
	{
		try
		{
			$error = new Error();

			// Get the exception information
			$error->exception = $e;
			$error->type = get_class($e);
			$error->code = $e->getCode();
			$error->message = $e->getMessage();
			$error->file = $e->getFile();
			$error->line = $e->getLine();
			$error->request_initial = Request::initial();

			// Create a text version of the exception
			$error->text = Kohana_Exception::text($e);

			if (Kohana::$is_cli)
			{
				// Display the text of the exception
				echo "\n{$error->text}\n";
			}

			// Get the exception backtrace
			$error->trace = $e->getTrace();

			if ($e instanceof ErrorException)
			{
				if (version_compare(PHP_VERSION, '5.3', '<'))
				{
					// Workaround for a bug in ErrorException::getTrace() that exists in
					// all PHP 5.2 versions. @see http://bugs.php.net/bug.php?id=45895
					for ($i = count($error->trace) - 1;$i > 0;--$i)
					{
						if (isset($error->trace[$i - 1]['args']))
						{
							// Re-position the args
							$error->trace[$i]['args'] = $error->trace[$i - 1]['args'];

							// Remove the args
							unset($error->trace[$i - 1]['args']);
						}
					}
				}
			}

			if (!headers_sent() and (Kohana::$is_cli === false))
			{
				// Make sure the proper content type is sent with a 500 status
				header('Content-Type: text/html; charset=' . Kohana::$charset, true, 500);
			}

			// Get the contents of the output buffer
			$error->display = $error->render();

			// Log the error
			$error->log();

			// Email the error
			$error->email();

			// Respond to the error
			$error->action();

			return true;
		}
		catch (Exception $e)
		{
			// Log an error.
			if (is_object(Kohana::$log))
			{
				// Create a text version of the exception
				$error = Kohana_Exception::text($e);

				// Add this exception to the log
				Kohana::$log->add(Log::ERROR, $error);

				// Make sure the logs are written
				Kohana::$log->write();
			}

			// Clean the output buffer if one exists
			ob_get_level() and ob_clean();

			// Display the exception text
			header('HTTP/1.1 500 Internal Server Error');
			echo "Unknown Error - Exception thrown in Error::handler()";

//.........这里部分代码省略.........
开发者ID:nexeck,项目名称:kohana-errors,代码行数:101,代码来源:error.php

示例10: act_login

 /**
  * 登录操作
  */
 public function act_login()
 {
     $username = isset($_POST['username']) ? hy_check($_POST['username'], 'un', 15) : '';
     $password = isset($_POST['password']) ? hy_check($_POST['password'], '', 20) : '';
     $captcha = isset($_POST['captcha']) ? $_POST['captcha'] : '';
     $check_vali = $this->validator($captcha);
     if (!$check_vali || $captcha == '') {
         $this->showMsg('验证码错误', 'index.php?g=admin&m=index&a=login');
     }
     if ($username == '#@_error' || $password == '#@_error') {
         Error::log('[后台登录错误]' . $_POST['username'] . '--' . hy_getIP(), ADMIN_LOG);
         $this->showMsg(Lang('账号或者密码错误'), '/qq_admin.php');
     }
     if (Model('index')->check_user($username, $password)) {
         header("Location:index.php?g=admin&m=index&a=index");
     } else {
         Error::log('[后台登录错误]' . $_POST['username'] . '--' . hy_getIP(), ADMIN_LOG);
         $this->showMsg(Lang('账号或者密码错误'), 'index.php?g=admin&m=index&a=login');
     }
 }
开发者ID:gzwyufei,项目名称:yfqiaqia,代码行数:23,代码来源:indexController.php

示例11: setPath

 public function setPath($path)
 {
     if (file_exists($path)) {
         return self::$templatepath = $path;
     }
     Error::log('Path ' . $path . ' not found');
 }
开发者ID:CraigChilds94,项目名称:scaffold,代码行数:7,代码来源:template.php

示例12: setDefaultSuburb

 /**
  * Set the $defaultSuburb
  *********************************************************************/
 public function setDefaultSuburb($stateAbbrev)
 {
     $stateAbbrev = strtolower($stateAbbrev);
     switch ($stateAbbrev) {
         case 'vic':
             return 'Melbourne';
         case 'nsw':
             return 'Sydney';
         case 'qld':
             return 'Brisbane';
         case 'sa':
             return 'Adelaide';
         case 'wa':
             return 'Perth';
         case 'tas':
             return 'Tasmania';
         case 'nt':
             return 'Darwin';
         case 'act':
             return 'Canberra';
         default:
             Error::log('No default match for state, please use vic, nsw, etc');
             return false;
     }
 }
开发者ID:moto485,项目名称:bom-weather,代码行数:28,代码来源:LoadSuburbWeather.php

示例13: submitManagerApplication

    private function submitManagerApplication()
    {
        $request = \Server::getCurrentRequest();
        $vars = $request->getVars();
        $username = $request->getVar('managerUsername');
        $password = $request->getVar('managerPassword');
        $first_name = $request->getVar('contactFirstName');
        $last_name = $request->getVar('contactLastName');
        $email = $request->getVar('emailAddress');
        $phone = $request->getVar('phoneNumber');
        $hours = $request->getVar('contactHours');
        $company_name = $request->getVar('companyName');
        $company_url = $request->getVar('companyUrl');
        $company_address = $request->getVar('companyAddress');
        $private = $request->getVar('managerType');
        $contact = new Contact();
        try {
            $contact->setUsername($username);
            $contact->setPassword($password);
            $contact->setFirstName($first_name);
            $contact->setLastName($last_name);
            $contact->setEmailAddress($email);
            $contact->setPhone($phone);
            $contact->setTimesAvailable($hours);
            if ($private == 'false') {
                $contact->setPrivate(false);
                if (empty($company_name)) {
                    throw \Exception('Missing company name');
                } else {
                    $contact->setCompanyName($company_name);
                }
                if (empty($company_address)) {
                    throw \Exception('Missing company address');
                } else {
                    $contact->setCompanyAddress($company_address);
                }
                $contact->setCompanyUrl($company_url);
            } else {
                $contact->setPrivate(true);
                $contact->setCompanyName('Private Renter');
            }
            $contact->setApproved(false);
            $contact->save();
            $this->emailApprovalNeeded();
        } catch (\Exception $ex) {
            $address = \PHPWS_Settings::get('properties', 'email');
            \Error::log($ex);
            $this->title = 'Sorry!';
            $this->content = <<<EOF
<p>Your manager submission could not be processed. Please email <a href="mailto:{$address}">{$address}</a> to inform them of your problem.</p>
EOF;
            $this->content .= $ex->getMessage();
            return;
        }
        // success
        $this->title = 'Thank you';
        $this->content = <<<EOF
<p>We will review your manager application and email your confirmation.</p>
                <p><a href="./">Return to the home page</a></p>
EOF;
    }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:61,代码来源:Contact_User.php


注:本文中的Error::log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。