function monolog_handler_form in Monolog 7
Same name and namespace in other branches
- 6 monolog.admin.inc \monolog_handler_form()
Handler settings callback.
Parameters
stdClass $profile: The logging profile configuration.
array|null $handler: The configuration options specific to the handler being edited.
1 string reference to 'monolog_handler_form'
- monolog_menu in ./
monolog.module - Implements hook_menu().
File
- ./
monolog.admin.inc, line 686 - Administrative settings for the Monolog module.
Code
function monolog_handler_form($form, &$form_state, stdClass $profile, array $handler = null) {
$form['#is_new'] = null === $handler;
$handler_name = $form['#is_new'] ? arg(8) : $handler['handler'];
if (!($handler_info = monolog_handler_info_load($handler_name))) {
drupal_not_found();
}
// Pop "Add Hander" link off, add profile link.
$breadcrumb = drupal_get_breadcrumb();
$add_handler_link = array_pop($breadcrumb);
$breadcrumb[] = l($profile->options['label'], 'admin/config/development/monolog/profile/' . $profile->name);
if ($form['#is_new']) {
$handler = array(
'handler' => $handler_name,
'label' => $handler_info['label'],
'level' => Logger::INFO,
'bubble' => 1,
'weight' => 1,
);
// Re-add the "Add Handler link".
$breadcrumb[] = $add_handler_link;
}
drupal_set_breadcrumb($breadcrumb);
$form['#monolog'] = array(
'profile' => $profile,
'handler_name' => $handler_name,
);
$form['weight'] = array(
'#type' => 'value',
'#value' => $handler['weight'],
);
$form['label'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $handler['label'],
'#description' => t('The human-readable name of the handler.'),
'#required' => TRUE,
'#maxlength' => 255,
'#size' => 30,
);
$form['name'] = array(
'#type' => 'machine_name',
'#default_value' => $form['#is_new'] ? '' : arg(7),
'#maxlength' => 32,
'#machine_name' => array(
'exists' => 'monolog_profile_load',
'source' => array(
'label',
),
),
'#disabled' => !$form['#is_new'],
'#description' => t('The machine readable name of the handler. This value can only contain letters, numbers, and underscores.'),
);
$form['level'] = array(
'#title' => t('Logging level'),
'#type' => 'select',
'#default_value' => $handler['level'],
'#options' => monolog_level_options(),
'#description' => t('The minimum severity level of logged messages.'),
);
$form['bubble'] = array(
'#title' => 'Allow messages to bubble up to the next handler in the stack.',
'#type' => 'checkbox',
'#default_value' => $handler['bubble'],
'#description' => t('If unckecked, messages processed by this handler will be blocked from being processed by the subsequent handlers in the stack.'),
);
monolog_load_handler_include($handler_info);
if ($handler_info['settings callback']) {
if (isset($handler_info['default settings'])) {
$handler += $handler_info['default settings'];
}
$handler_info['settings callback']($form, $form_state, $profile, $handler);
}
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save handler'),
);
$form['actions']['cancel'] = array(
'#markup' => l(t('Cancel'), 'admin/config/development/monolog/profile/' . $profile->name),
);
$form['#submit'] = array(
'monolog_handler_form_submit',
);
return $form;
}