Tripal
Functions
Notify

Functions

 tripal_report_error ($type, $severity, $message, $variables=[], $options=[])
 
 tripal_log ($message, $type='error', $options=[])
 
 tripal_set_message ($message, $importance=TRIPAL_INFO, $options=[])
 

Detailed Description

Provides an application programming interface (API) for improved user notifications. These API functions can be used to set messages for end-users, administrators, or simple logging.

Function Documentation

◆ tripal_log()

tripal_log (   $message,
  $type = 'error',
  $options = [] 
)

DEPRECATED

File-based error logging for Tripal.

This function is deprecated in Tripal v4. It will be removed in a future release of Tripal. Please use the \Drupal\tripal\Services\TripalLogger class instead.

Consider using the tripal_report_error function rather than calling this function directly, as that function calls this one for non INFO messages and has greater functionality.

Parameters
$messageThe message to be logged. Need not contain date/time information.
$log_typeThe type of log. Should be one of 'error' or 'job' although other types are supported.
$optionsAn array of options where the following keys are supported:
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.
Returns
The number of bytes that were written to the file, or FALSE on failure.

◆ tripal_report_error()

tripal_report_error (   $type,
  $severity,
  $message,
  $variables = [],
  $options = [] 
)

DEPRECATED

Provide better error notice for Tripal.

This function is deprecated in Tripal v4. It will be removed in a future release of Tripal. Please use the \Drupal\tripal\Services\TripalLogger class instead.

Please be sure to set the $options array as desired. For example, by default this function sends all messages to the Drupal logger. If a long running job uses this function and prints status messages you may not want to have those go to the logger as it can dramatically affect performance.

If the environment variable 'TRIPAL_DEBUG' is set to 1 then this function will add backtrace information to the message.

Parameters
$typeThe catagory to which this message belongs. Can be any string, but the general practice is to use the name of the module.
$severityThe severity of the message; one of the following values:
  • TRIPAL_CRITICAL: Critical conditions.
  • TRIPAL_ERROR: Error conditions.
  • TRIPAL_WARNING: Warning conditions.
  • TRIPAL_NOTICE: (default) Normal but significant conditions.
  • TRIPAL_INFO: Informational messages.
  • TRIPAL_DEBUG: Debug-level messages.
$messageThe message to store in the log. Keep $message translatable by not concatenating dynamic values into it! Variables in the message should be added by using placeholder strings alongside the variables argument to declare the value of the placeholders. See t() for documentation on how $message and $variables interact.
$variablesArray of variables to replace in the message on display or NULL if message is already translated or not possible to translate.
$optionsAn array of options. Some available options include:
  • print: prints the error message to the terminal screen. Useful when display is the command-line
  • drupal_set_message: set to TRUE then send the message to the drupal_set_message function.
  • logger: set to FALSE to disable logging to Drupal's logger.
  • job: The jobs management object for the job if this function is run as a job. Adding the job object here ensures that any status or error messages are also logged with the job.

◆ tripal_set_message()

tripal_set_message (   $message,
  $importance = TRIPAL_INFO,
  $options = [] 
)

Display messages to tripal administrators.

This can be used instead of drupal_set_message when you want to target tripal administrators.

Parameters
$messageThe message to be displayed to the tripal administrators.
$importanceThe level of importance for this message. In the future this will be used to allow administrators to filter some of these messages. It can be one of the following:
  • TRIPAL_CRITICAL: Critical conditions.
  • TRIPAL_ERROR: Error conditions.
  • TRIPAL_WARNING: Warning conditions.
  • TRIPAL_NOTICE: Normal but significant conditions.
  • TRIPAL_INFO: (default) Informational messages.
  • TRIPAL_DEBUG: Debug-level messages.
$optionsAny options to apply to the current message. Supported options include:
  • return_html: return HTML instead of setting a drupal message. This can be used to place a tripal message in a particular place in the page. The default is FALSE.