本文整理汇总了PHP中Piwik\Log::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::error方法的具体用法?PHP Log::error怎么用?PHP Log::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Log
的用法示例。
在下文中一共展示了Log::error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateTracker
public function updateTracker()
{
try {
$trackerUpdater = new TrackerUpdater();
$trackerUpdater->update();
} catch (\Exception $e) {
Log::error('There was an error while updating the javascript tracker: ' . $e->getMessage());
}
}
示例2: testTokenAuthIsRemoved
/**
* @dataProvider getBackendsToTest
*/
public function testTokenAuthIsRemoved($backend)
{
$this->recreateLogSingleton($backend);
Log::error('token_auth=9b1cefc915ff6180071fb7dcd13ec5a4');
$this->checkBackend($backend, 'token_auth=removed', $formatMessage = true, $tag = 'Monolog');
}
示例3: buildView
protected function buildView()
{
$this->overrideSomeConfigPropertiesIfNeeded();
try {
$this->beforeLoadDataTable();
$this->loadDataTableFromAPI();
$this->postDataTableLoadedFromAPI();
$requestPropertiesAfterLoadDataTable = $this->requestConfig->getProperties();
$this->applyFilters();
$this->addVisualizationInfoFromMetricMetadata();
$this->afterAllFiltersAreApplied();
$this->beforeRender();
$this->logMessageIfRequestPropertiesHaveChanged($requestPropertiesAfterLoadDataTable);
} catch (NoAccessException $e) {
throw $e;
} catch (\Exception $e) {
Log::error("Failed to get data from API: " . $e->getMessage() . "\n" . $e->getTraceAsString());
$message = $e->getMessage();
if (\Piwik_ShouldPrintBackTraceWithMessage()) {
$message .= "\n" . $e->getTraceAsString();
}
$loadingError = array('message' => $message);
}
$view = new View("@CoreHome/_dataTable");
if (!empty($loadingError)) {
$view->error = $loadingError;
}
$view->assign($this->templateVars);
$view->visualization = $this;
$view->visualizationTemplate = static::TEMPLATE_FILE;
$view->visualizationCssClass = $this->getDefaultDataTableCssClass();
$view->reportMetdadata = $this->getReportMetadata();
if (null === $this->dataTable) {
$view->dataTable = null;
} else {
$view->dataTableHasNoData = !$this->isThereDataToDisplay();
$view->dataTable = $this->dataTable;
// if it's likely that the report data for this data table has been purged,
// set whether we should display a message to that effect.
$view->showReportDataWasPurgedMessage = $this->hasReportBeenPurged();
$view->deleteReportsOlderThan = Option::get('delete_reports_older_than');
}
$view->idSubtable = $this->requestConfig->idSubtable;
$view->clientSideParameters = $this->getClientSideParametersToSet();
$view->clientSideProperties = $this->getClientSidePropertiesToSet();
$view->properties = array_merge($this->requestConfig->getProperties(), $this->config->getProperties());
$view->reportLastUpdatedMessage = $this->reportLastUpdatedMessage;
$view->footerIcons = $this->config->footer_icons;
$view->isWidget = Common::getRequestVar('widget', 0, 'int');
return $view;
}
示例4: install
public static function install()
{
foreach (self::getScopes() as $scope) {
$model = new Model($scope);
try {
$maxCustomVars = self::DEFAULT_CUSTOM_VAR_COUNT;
$customVarsToAdd = $maxCustomVars - $model->getCurrentNumCustomVars();
for ($index = 0; $index < $customVarsToAdd; $index++) {
$model->addCustomVariable();
}
} catch (\Exception $e) {
Log::error('Failed to add custom variable: ' . $e->getMessage());
}
}
}
示例5: update
/**
* Attempts to download new location, ISP & organization GeoIP databases and
* replace the existing ones w/ them.
*/
public function update()
{
try {
Option::set(self::LAST_RUN_TIME_OPTION_NAME, Date::factory('today')->getTimestamp());
$locUrl = Option::get(self::LOC_URL_OPTION_NAME);
if (!empty($locUrl)) {
$this->downloadFile('loc', $locUrl);
}
$ispUrl = Option::get(self::ISP_URL_OPTION_NAME);
if (!empty($ispUrl)) {
$this->downloadFile('isp', $ispUrl);
}
$orgUrl = Option::get(self::ORG_URL_OPTION_NAME);
if (!empty($orgUrl)) {
$this->downloadFile('org', $orgUrl);
}
} catch (Exception $ex) {
// message will already be prefixed w/ 'GeoIPAutoUpdater: '
Log::error($ex);
$this->performRedundantDbChecks();
throw $ex;
}
$this->performRedundantDbChecks();
}
示例6: geoipUpdateError
function geoipUpdateError($message)
{
Log::error($message);
Common::sendHeader('HTTP/1.1 500 Internal Server Error', $replace = true, $responseCode = 500);
exit;
}
示例7: logException
public static function logException(\Exception $exception)
{
Log::error($exception);
}
示例8: start
/**
* Start the session
*
* @param array|bool $options An array of configuration options; the auto-start (bool) setting is ignored
* @return void
* @throws Exception if starting a session fails
*/
public static function start($options = false)
{
if (headers_sent() || self::$sessionStarted || defined('PIWIK_ENABLE_SESSION_START') && !PIWIK_ENABLE_SESSION_START) {
return;
}
self::$sessionStarted = true;
// use cookies to store session id on the client side
@ini_set('session.use_cookies', '1');
// prevent attacks involving session ids passed in URLs
@ini_set('session.use_only_cookies', '1');
// advise browser that session cookie should only be sent over secure connection
if (ProxyHttp::isHttps()) {
@ini_set('session.cookie_secure', '1');
}
// advise browser that session cookie should only be accessible through the HTTP protocol (i.e., not JavaScript)
@ini_set('session.cookie_httponly', '1');
// don't use the default: PHPSESSID
@ini_set('session.name', self::SESSION_NAME);
// proxies may cause the referer check to fail and
// incorrectly invalidate the session
@ini_set('session.referer_check', '');
$currentSaveHandler = ini_get('session.save_handler');
$config = Config::getInstance();
if (self::isFileBasedSessions()) {
// Note: this handler doesn't work well in load-balanced environments and may have a concurrency issue with locked session files
// for "files", use our own folder to prevent local session file hijacking
$sessionPath = self::getSessionsDirectory();
// We always call mkdir since it also chmods the directory which might help when permissions were reverted for some reasons
Filesystem::mkdir($sessionPath);
@ini_set('session.save_handler', 'files');
@ini_set('session.save_path', $sessionPath);
} elseif ($config->General['session_save_handler'] === 'dbtable' || in_array($currentSaveHandler, array('user', 'mm'))) {
// We consider these to be misconfigurations, in that:
// - user - we can't verify that user-defined session handler functions have already been set via session_set_save_handler()
// - mm - this handler is not recommended, unsupported, not available for Windows, and has a potential concurrency issue
$config = array('name' => Common::prefixTable('session'), 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime');
$saveHandler = new DbTable($config);
if ($saveHandler) {
self::setSaveHandler($saveHandler);
}
}
// garbage collection may disabled by default (e.g., Debian)
if (ini_get('session.gc_probability') == 0) {
@ini_set('session.gc_probability', 1);
}
try {
parent::start();
register_shutdown_function(array('Zend_Session', 'writeClose'), true);
} catch (Exception $e) {
Log::error('Unable to start session: ' . $e->getMessage());
$enableDbSessions = '';
if (DbHelper::isInstalled()) {
$enableDbSessions = "<br/>If you still experience issues after trying these changes,\n\t\t\t \t\t\twe recommend that you <a href='http://piwik.org/faq/how-to-install/#faq_133' rel='noreferrer' target='_blank'>enable database session storage</a>.";
}
$pathToSessions = Filechecks::getErrorMessageMissingPermissions(self::getSessionsDirectory());
$message = sprintf("Error: %s %s %s\n<pre>Debug: the original error was \n%s</pre>", Piwik::translate('General_ExceptionUnableToStartSession'), $pathToSessions, $enableDbSessions, $e->getMessage());
$ex = new MissingFilePermissionException($message, $e->getCode(), $e);
$ex->setIsHtmlMessage();
throw $ex;
}
}
示例9: logError
public function logError($m)
{
if (!defined('PIWIK_ARCHIVE_NO_TRUNCATE')) {
$m = substr($m, 0, self::TRUNCATE_ERROR_MESSAGE_SUMMARY);
}
$m = str_replace(array("\n", "\t"), " ", $m);
$this->errors[] = $m;
Log::error($m);
}
示例10: geoipUpdateError
function geoipUpdateError($message)
{
Log::error($message);
if (!Common::isPhpCliMode()) {
@header('HTTP/1.1 500 Internal Server Error', $replace = true, $responseCode = 500);
}
exit;
}
示例11: testTokenAuthIsRemoved
/**
* @dataProvider getBackendsToTest
*/
public function testTokenAuthIsRemoved($backend)
{
Config::getInstance()->log['log_writers'] = array($backend);
Log::error('token_auth=9b1cefc915ff6180071fb7dcd13ec5a4');
$this->checkBackend($backend, 'token_auth=removed', $formatMessage = true, $tag = 'Monolog');
}
示例12: testLoggingWorksWhenMessageIsException
/**
* @group Core
*
* @dataProvider getBackendsToTest
*/
public function testLoggingWorksWhenMessageIsException($backend)
{
Config::getInstance()->log['log_writers'] = array($backend);
ob_start();
$exception = new Exception("dummy error message");
Log::error($exception);
$this->screenOutput = ob_get_contents();
ob_end_clean();
$this->checkBackend($backend, self::$expectedExceptionOutput[$backend], $formatMessage = false, $tag = 'Core_LogTest');
$this->checkBackend('screen', self::$expectedExceptionOutput['screen']);
// errors should always written to the screen
}
示例13: logIntranetSubNetworkInfo
/**
* Called by event `Tracker.newVisitorInformation`
*
* @see getListHooksRegistered()
*/
public function logIntranetSubNetworkInfo(&$visitorInfo)
{
if (!file_exists($this->getDataFilePath())) {
Log::error('Plugin IntranetGeoIP does not work. File is missing: ' . $this->getDataFilePath());
return;
}
$data = (include $this->getDataFilePath());
if ($data === false) {
// no data file found
// @todo ...inform the user/ log something
Log::error('Plugin IntranetGeoIP does not work. File is missing: ' . $this->getDataFilePath());
return;
}
foreach ($data as $value) {
$ip = Network\IP::fromBinaryIP($visitorInfo['location_ip']);
if (isset($value['networks']) && $ip->isInRanges($value['networks']) === true) {
// values with the same key are not overwritten by right!
// http://www.php.net/manual/en/language.operators.array.php
if (isset($value['visitorInfo'])) {
$visitorInfo = $value['visitorInfo'] + $visitorInfo;
}
return;
}
}
// if nothing was matched, you can define default values if you want to
if (isset($data['noMatch']) && isset($data['noMatch']['visitorInfo'])) {
$visitorInfo = $data['noMatch']['visitorInfo'] + $visitorInfo;
return;
}
}
示例14: performRedundantDbChecks
/**
* Utility function that checks if geolocation works with each installed database,
* and if one or more doesn't, they are renamed to make sure tracking will work.
* This is a safety measure used to make sure tracking isn't affected if strange
* update errors occur.
*
* Databases are renamed to ${original}.broken .
*
* Note: method is protected for testability.
*
* @param $logErrors - only used to hide error logs during tests
*/
protected function performRedundantDbChecks($logErrors = true)
{
$databaseTypes = array_keys(GeoIp::$dbNames);
foreach ($databaseTypes as $type) {
$customNames = array('loc' => array(), 'isp' => array(), 'org' => array());
$customNames[$type] = GeoIp::$dbNames[$type];
// create provider that only uses the DB type we're testing
$provider = new Php($customNames);
// test the provider. on error, we rename the broken DB.
self::getTestLocationCatchPhpErrors($provider);
if (self::$unzipPhpError !== null) {
list($errno, $errstr, $errfile, $errline) = self::$unzipPhpError;
if ($logErrors) {
Log::error("GeoIPAutoUpdater: Encountered PHP error when performing redundant tests on GeoIP " . "%s database: %s: %s on line %s of %s.", $type, $errno, $errstr, $errline, $errfile);
}
// get the current filename for the DB and an available new one to rename it to
list($oldPath, $newPath) = $this->getOldAndNewPathsForBrokenDb($customNames[$type]);
// rename the DB so tracking will not fail
if ($oldPath !== false && $newPath !== false) {
if (file_exists($newPath)) {
unlink($newPath);
}
rename($oldPath, $newPath);
}
}
}
}
示例15: error
/**
* Triggers an error if the development mode is enabled. Depending on the current environment / mode it will either
* log the given message or throw an exception to make sure it will be displayed in the Piwik UI.
*
* @param string $message
* @throws Exception
*/
public static function error($message)
{
if (!self::isEnabled()) {
return;
}
$message .= ' (This error is only shown in development mode)';
if (SettingsServer::isTrackerApiRequest() || Common::isPhpCliMode()) {
Log::error($message);
} else {
throw new Exception($message);
}
}