1 common.inc watchdog_severity_levels($return = 'label')

Returns a list of severity levels, as defined in RFC 3164.

Parameters

string $return: The type of data to return. Can be one of:

  • all: The full array.
  • name: The untranslated machine names.
  • label: The translated human-readable names/labels.
  • description: The level descriptions.

For backwards-compatibility, this defaults to 'label'.

Return value

array: An array of the possible severity levels for log messages. The array keys are the named constants, while the values depend on the value of $return.

See also

https://en.wikipedia.org/wiki/Syslog#Severity_level

http://www.ietf.org/rfc/rfc3164.txt

watchdog()

Related topics

File

core/includes/common.inc, line 8569
Common functions that many Backdrop modules will need to reference.

Code

function watchdog_severity_levels($return = 'label') {
  $levels = array(
    WATCHDOG_EMERGENCY => array(
      'name' => 'emergency',
      'label' => t('Emergency'),
      'description' => t('System is unusable'),
    ),
    WATCHDOG_ALERT => array(
      'name' => 'alert',
      'label' => t('Alert'),
      'description' => t('Action must be taken immediately'),
    ),
    WATCHDOG_CRITICAL => array(
      'name' => 'critical',
      'label' => t('Critical'),
      'description' => t('Critical conditions'),
    ),
    WATCHDOG_ERROR => array(
      'name' => 'error',
      'label' => t('Error'),
      'description' => t('Error conditions'),
    ),
    WATCHDOG_WARNING => array(
      'name' => 'warning',
      'label' => t('Warning'),
      'description' => t('Warning conditions'),
    ),
    WATCHDOG_NOTICE => array(
      'name' => 'notice',
      'label' => t('Notice'),
      'description' => t('Normal but significant conditions'),
    ),
    WATCHDOG_INFO => array(
      'name' => 'info',
      'label' => t('Info'),
      'description' => t('Informational messages'),
    ),
    WATCHDOG_DEBUG => array(
      'name' => 'debug',
      'label' => t('Debug'),
      'description' => t('Debug-level messages'),
    ),
    WATCHDOG_DEPRECATED => array(
      'name' => 'deprecated',
      'label' => t('Deprecated'),
      'description' => t('Deprecated function/feature notices'),
    ),
  );

  switch ($return) {
    case 'name':
    case 'label':
    case 'description':
      return array_combine(array_keys($levels), array_column($levels, $return));
    case 'all':
    default:
      return $levels;
  }
}