本文整理汇总了PHP中watchdog函数的典型用法代码示例。如果您正苦于以下问题:PHP watchdog函数的具体用法?PHP watchdog怎么用?PHP watchdog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了watchdog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: error_httpd
function error_httpd()
{
global $REDIRECT_STATUS, $REDIRECT_URL, $HTTP_REFERER, $HTTP_USER_AGENT;
switch ($REDIRECT_STATUS) {
case 500:
$message = "500 error - internal server error";
break;
case 404:
$message = "404 error - `{$REDIRECT_URL}' not found";
break;
case 403:
$message = "403 error - access denied - forbidden";
break;
case 401:
$message = "401 error - authorization required";
break;
case 401:
$message = "400 error - bad request";
break;
default:
$message = "unknown error";
}
watchdog("error", "message: `{$message}' - requested url: {$REDIRECT_URL} - referring url: {$HTTP_REFERER} - user agent: {$HTTP_USER_AGENT}");
print "<PRE>\n";
print "<H1>Oops, an error occured!</H1>\n";
print "<B>Processed output:</B><BR>\n";
print " * {$message}<BR>\n";
print " * Return to the <A HREF=\"index.php\">main page</A>.\n";
print "</PRE>\n";
}
示例2: createImageObject
function createImageObject($obj_specimen_pid, $obj_jp2URL, $obj_rft_id, $obj_sourceURL, $obj_width, $obj_height, $obj_jpeg_datastream_url, $obj_label)
{
$this->pid = $this->getNextImagePid();
$this->specimen_pid = $obj_specimen_pid;
$this->jp2URL = $obj_jp2URL;
$this->rft_id = $obj_rft_id;
$this->sourceURL = $obj_sourceURL;
$this->width = $obj_width;
$this->height = $obj_height;
$this->jpeg_datastream_url = $obj_jpeg_datastream_url;
if ($obj_label != null && $obj_label != '') {
$this->label = $obj_label;
} else {
$this->label = $this->pid;
//We may use something other than the pid for the label eventually
}
//create relationships
$pid_base = 'image';
if ($this->startFOXML()) {
if (!$this->addImage_RELS_EXT_datastream()) {
echo 'Unable to addImage_RELS_EXT_datastream.<br>';
}
if (!$this->addDC_datastream()) {
echo 'Unable to addDC_datastream.<br>';
}
list($this->width, $this->height) = getimagesize($this->jp2URL);
if (!$this->addImageMetadata_datastream()) {
echo 'Unable to addImageMetadata_datastream.<br>';
}
if (!$this->addJPEG_datastream()) {
echo 'Unable to addJPEG_datastream.<br>';
}
try {
$foxml_file = str_replace(':', '_', $this->pid);
$foxml_file = '/var/www/drupal/sites/default/files/apiary_datastreams/' . $foxml_file . '.xml';
if (file_exists($foxml_file)) {
unlink($foxml_file);
}
$this->dom->save($foxml_file);
if ($object = ingest_object_from_FOXML($this->dom)) {
$this->msg = "{$this->pid} successfully created.";
include_once drupal_get_path('module', 'apiary_project') . '/workflow/include/search.php';
$search_instance = new search();
$search_instance->index($this->pid);
return true;
} else {
$this->msg = "Unable to ingest image FOXML dom document.";
return false;
}
} catch (exception $e) {
drupal_set_message(t('Error Ingesting Image Object! ') . $e->getMessage(), 'error');
watchdog(t("Fedora_Repository"), "Error Ingesting Image Object!" . $e->getMessage(), WATCHDOG_ERROR);
return false;
}
} else {
$this->msg = "Unable to start image FOXML file for create image object.";
return false;
}
return true;
}
示例3: blackberry_2016_preprocess_html
function blackberry_2016_preprocess_html(&$vars)
{
if (isset($_POST['token'])) {
watchdog('slack access', 'token POST: ' . $_POST['token']);
$vars['theme_hook_suggestions'][] = 'html__headless';
}
}
示例4: submit
/**
* {@inheritdoc}
*/
public function submit(array $form, array &$form_state)
{
$this->entity->delete();
watchdog('user', 'Role %name has been deleted.', array('%name' => $this->entity->label()));
drupal_set_message($this->t('Role %name has been deleted.', array('%name' => $this->entity->label())));
$form_state['redirect_route'] = $this->getCancelUrl();
}
示例5: sendRequest
protected function sendRequest($identifiers)
{
$ids = array();
foreach ($identifiers as $i) {
$ids = array_merge($ids, array_values($i));
}
$authInfo = array('authenticationUser' => $this->username, 'authenticationGroup' => $this->group, 'authenticationPassword' => $this->password);
if (preg_match('/moreinfo.addi.dk/', $this->wsdlUrl)) {
// New moreinfo service.
$client = new SoapClient($this->wsdlUrl . '/moreinfo.wsdl');
$method = 'moreInfo';
} else {
// Legacy additionalInformation service.
$client = new SoapClient($this->wsdlUrl);
$method = 'additionalInformation';
}
$startTime = explode(' ', microtime());
$response = $client->{$method}(array('authentication' => $authInfo, 'identifier' => $identifiers));
$stopTime = explode(' ', microtime());
$time = floatval($stopTime[1] + $stopTime[0] - ($startTime[1] + $startTime[0]));
//Drupal specific code - consider moving this elsewhere
if (variable_get('addi_enable_logging', false)) {
watchdog('addi', 'Completed request (' . round($time, 3) . 's): Ids: %ids', array('%ids' => implode(', ', $ids)), WATCHDOG_DEBUG, 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
}
if ($response->requestStatus->statusEnum != 'ok') {
throw new AdditionalInformationServiceException($response->requestStatus->statusEnum . ': ' . $response->requestStatus->errorText);
}
if (!is_array($response->identifierInformation)) {
$response->identifierInformation = array($response->identifierInformation);
}
return $response;
}
示例6: solrmlt_suggestions
function solrmlt_suggestions($block_id, $nid)
{
try {
$solr = apachesolr_get_solr();
$fields = array('mlt.mintf', 'mlt.mindf', 'mlt.minwl', 'mlt.maxwl', 'mlt.maxqt', 'mlt.boost', 'mlt.qf');
$block = apachesolr_mlt_load_block($block_id);
$params = array('qt' => 'mlt', 'fl' => 'nid,title,url', 'mlt.fl' => implode(',', $block['mlt_fl']));
foreach ($fields as $field) {
$drupal_fieldname = str_replace('.', '_', $field);
if (!empty($block[$drupal_fieldname])) {
$params[$field] = check_plain($block[$drupal_fieldname]);
}
}
$query = apachesolr_drupal_query('id:' . apachesolr_document_id($nid));
// This hook allows modules to modify the query and params objects.
apachesolr_modify_query($query, $params, 'apachesolr_mlt');
if (empty($query)) {
return;
}
$response = $solr->search($query->get_query_basic(), 0, $block['num_results'], $params);
if ($response->response) {
$docs = (array) end($response->response);
}
return $docs;
} catch (Exception $e) {
watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR);
}
}
示例7: submit
/**
* {@inheritdoc}
*/
public function submit(array $form, array &$form_state)
{
$this->entity->delete();
watchdog('user', 'Deleted action %aid (%action)', array('%aid' => $this->entity->id(), '%action' => $this->entity->label()));
drupal_set_message($this->t('Action %action was deleted', array('%action' => $this->entity->label())));
$form_state['redirect_route'] = $this->getCancelUrl();
}
示例8: brukar_client_oauth_callback
function brukar_client_oauth_callback()
{
require_once drupal_get_path('module', 'brukar_common') . '/OAuth.php';
$method = new OAuthSignatureMethod_HMAC_SHA1();
$consumer = new OAuthConsumer(variable_get('brukar_consumer_key'), variable_get('brukar_consumer_secret'));
if (isset($_SESSION['auth_oauth']) && $_SESSION['auth_oauth']['oauth_token'] == $_GET['oauth_token']) {
unset($_GET['oauth_token']);
$tmp = new OAuthToken($_SESSION['auth_oauth']['oauth_token'], $_SESSION['auth_oauth']['oauth_token_secret']);
$req = OAuthRequest::from_consumer_and_token($consumer, $tmp, 'GET', variable_get('brukar_url') . 'server/oauth/access_token', array());
$req->sign_request($method, $consumer, $tmp);
parse_str(trim(file_get_contents($req->to_url())), $token);
unset($_SESSION['auth_oauth']);
if (count($token) > 0) {
$_SESSION['_brukar_access_token'] = array('token' => $token['oauth_token'], 'token_secret' => $token['oauth_token_secret']);
$token = new OAuthToken($token['oauth_token'], $token['oauth_token_secret']);
$req = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', variable_get('brukar_url') . 'server/oauth/user', array());
$req->sign_request($method, $consumer, $token);
brukar_client_login((array) json_decode(trim(file_get_contents($req->to_url()))));
}
}
$debug_data = array('cookie' => $_COOKIE, 'request_uri' => request_uri(), 'auth_oauth' => isset($_SESSION['auth_oauth']) ? $_SESSION['auth_oauth'] : 'no auth_oauth');
watchdog('brukar_client', 'User login failed.<br/>Debug data:<br/><pre>!debug_data</pre><br/>', array('!debug_data' => print_r($debug_data, TRUE)), WATCHDOG_ERROR);
drupal_set_message(t('Noe gikk feil under innlogging.'), 'warning');
drupal_goto('<front>');
}
示例9: doRequestDirect
/**
* Do CURL request directly into sendinblue.
*
* @param array $data
* A data of curl request.
* @return array
* An associate array with respond data.
*/
private function doRequestDirect($data)
{
if (!function_exists('curl_init')) {
$msg = 'SendinBlue requires CURL module';
watchdog('sendinblue', $msg, NULL, WATCHDOG_ERROR);
return NULL;
}
$url = 'http://ws.mailin.fr/';
$ch = curl_init();
$paramData = '';
$data['source'] = 'Drupal';
if (is_array($data)) {
foreach ($data as $key => $value) {
$paramData .= $key . '=' . urlencode($value) . '&';
}
} else {
$paramData = $data;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $paramData);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
示例10: submit
/**
* {@inheritdoc}
*/
public function submit(array $form, array &$form_state)
{
$this->entity->delete();
drupal_set_message($this->t('Deleted vocabulary %name.', array('%name' => $this->entity->label())));
watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE);
$form_state['redirect_route'] = $this->getCancelRoute();
}
示例11: unresolveDependencies
public function unresolveDependencies($subset = false, $subtype = false)
{
// Create a clone of the definition so we don't muck up the entity cache.
$this->unresolved_definition = $subset === false ? $this->entity->definition : $subset;
if (!is_object($this->unresolved_definition)) {
$this->unresolved_definition = (object) $this->unresolved_definition;
}
// Generate the list of handlers for each of the fields.
$handlers = DefinitionHandlerRegistry::getFieldHandlers($this->entity, $this->unresolved_definition, $subtype);
foreach ($handlers as $field_name => $handler) {
if (!isset($this->unresolved_definition->{$field_name})) {
continue;
}
foreach ($handler['handlers'] as $single_handler) {
if (!$single_handler instanceof DefinitionHandlerBase) {
continue;
}
try {
$single_handler->entity =& $this->entity;
$single_handler->unresolved_definition =& $this->unresolved_definition;
$single_handler->unhandleField($this->entity->type(), $handler['type'], $field_name, $this->unresolved_definition->{$field_name});
} catch (\Exception $ex) {
$message = t('Error processing field "@fieldName" - "@message"', array('@fieldName' => $field_name, '@message' => $ex->getMessage()));
\watchdog('publisher', $message, array(), WATCHDOG_WARNING);
$this->errors[] = $ex;
}
}
}
}
示例12: getForm
/**
* Gets a form submitted via #ajax during an Ajax callback.
*
* This will load a form from the form cache used during Ajax operations. It
* pulls the form info from the request body.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request object.
*
* @return array
* An array containing the $form and $form_state. Use the list() function
* to break these apart:
* @code
* list($form, $form_state, $form_id, $form_build_id) = $this->getForm();
* @endcode
*
* @throws Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
*/
protected function getForm(Request $request)
{
$form_state = \Drupal::formBuilder()->getFormStateDefaults();
$form_build_id = $request->request->get('form_build_id');
// Get the form from the cache.
$form = form_get_cache($form_build_id, $form_state);
if (!$form) {
// If $form cannot be loaded from the cache, the form_build_id must be
// invalid, which means that someone performed a POST request onto
// system/ajax without actually viewing the concerned form in the browser.
// This is likely a hacking attempt as it never happens under normal
// circumstances.
watchdog('ajax', 'Invalid form POST data.', array(), WATCHDOG_WARNING);
throw new BadRequestHttpException();
}
// Since some of the submit handlers are run, redirects need to be disabled.
$form_state['no_redirect'] = TRUE;
// When a form is rebuilt after Ajax processing, its #build_id and #action
// should not change.
// @see \Drupal\Core\Form\FormBuilderInterface::rebuildForm()
$form_state['rebuild_info']['copy']['#build_id'] = TRUE;
$form_state['rebuild_info']['copy']['#action'] = TRUE;
// The form needs to be processed; prepare for that by setting a few internal
// variables.
$form_state['input'] = $request->request->all();
$form_id = $form['#form_id'];
return array($form, $form_state, $form_id, $form_build_id);
}
示例13: _soc_boxauth_get_code_from_box_handler
/**
* This function is handles the callback from Box API.
* @return string
*/
function _soc_boxauth_get_code_from_box_handler()
{
// get query string parameters
$qs = drupal_get_query_parameters();
watchdog(SOC_BOXAUTH_MODULENAME, "Got code back from Box", $qs, WATCHDOG_INFO);
// Stage post data and create http query
$post_data = ['grant_type' => 'authorization_code', 'code' => $qs['code'], 'client_id' => variable_get(SOC_BOXAUTH_CLIENTID_VARIABLE), 'client_secret' => variable_get(SOC_BOXAUTH_CLIENTSECRET_VARIABLE)];
$result = BoxFolderOperations::doPost('https://api.box.com/oauth2/token', $post_data, 'Content-type: application/x-www-form-urlencoded', 'QUERY');
// save to session. Decoded json object into php array
$_SESSION['box'] = drupal_json_decode($result);
$_SESSION['box']['expires_time'] = time() + SOC_BOXAUTH_EXPIREOFFSET;
// If successful, the ['box']['access_token'] will exists. Log and report
// to user.
if (isset($_SESSION['box']['access_token'])) {
drupal_set_message(t(variable_get(SOC_BOXAUTH_SUCCESSMESSAGE_VARIABLE)));
watchdog(SOC_BOXAUTH_MODULENAME, 'Successful box access_token');
$next_steps = variable_get(SOC_BOXAUTH_NEXTSTEPS_VARIABLE, ['value' => t('Next steps...')]);
return $next_steps['value'];
} else {
$message = t(variable_get(SOC_BOXAUTH_FAILUREMESSAGE_VARIABLE));
drupal_set_message($message, 'error');
watchdog(SOC_BOXAUTH_MODULENAME, 'Failed box access_token');
return $message;
}
}
示例14: submit
/**
* {@inheritdoc}
*/
public function submit(array $form, array &$form_state)
{
$this->entity->delete();
watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label()));
drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label())));
$form_state['redirect_route'] = new Url('aggregator.sources');
}
示例15: log
public static function log($msg, $data = NULL, $depth = 0, $severity = WATCHDOG_NOTICE, $tag = '')
{
if ($severity == WATCHDOG_WARNING && variable_get('lingotek_warning_log', self::getDefault())) {
return;
} else {
if (strcasecmp($tag, 'api') == 0 && !variable_get('lingotek_api_debug', self::getDefault())) {
return;
}
}
$backtrace = debug_backtrace();
$location = $backtrace[$depth]['file'] . ':' . $backtrace[$depth]['line'];
$function = $backtrace[$depth + 1]['function'];
$args = @json_encode($backtrace[$depth + 1]['args']);
$data_output = "";
if (isset($data)) {
$data_output = json_encode($data);
}
$suffix = is_string($tag) && strlen($tag) ? ' - ' . $tag : '';
$data_array = array();
if (is_array($data)) {
foreach ($data as $k => $v) {
$data_array[$k] = LingotekLog::format($v);
}
}
watchdog('lingotek' . $suffix, t($msg, $data_array) . ' <div style="word-break: break-all; padding-top: 10px; color: #666;"><b>FUNCTION:</b> %function<br /><b>ARGS:</b> %args<br /><b>FILE:</b> %location<br /><b>MESSAGE:</b> %msg <br /><b>DATA:</b> %data <br /></div>', array('%msg' => $msg, '%data' => $data_output, '%location' => $location, '%function' => $function, '%args' => $args), $severity);
if (variable_get('lingotek_error_log', FALSE)) {
error_log("FUNCTION: {$function} ARGS: {$args} FILE: {$location} MESSAGE: {$msg} DATA: {$data_output} ");
}
}