function monolog in Monolog 7
Same name and namespace in other branches
- 6 monolog.module \monolog()
Factory function for Monolog loggers.
Parameters
string $channel_name: The machine name the logging channel.
Return value
Throws
\RuntimeException
1 call to monolog()
- monolog_logging_watchdog in modules/
monolog_logging/ monolog_logging.module - Implements hook_watchdog().
11 string references to 'monolog'
- monolog_ctools_plugin_api in ./
monolog.module - Implements hook_ctools_plugin_api().
- monolog_gelf_monolog_handler_info in modules/
monolog_gelf/ monolog_gelf.module - Implements hook_monolog_handler_info().
- monolog_handler_form_submit in ./
monolog.admin.inc - Form submission handler for monolog_handler_form().
- monolog_hook_info in ./
monolog.module - Implements hook_hook_info().
- monolog_logging_bootstrap in modules/
monolog_logging/ monolog_logging.module - Ensure that required subsystems and modules are loaded if watchdog messages are logged prior to a full Drupal bootstrap.
File
- ./
monolog.module, line 174 - A Framework and UI for integrating with the Monolog library.
Code
function monolog($channel_name) {
// We do not use drupal_static() since this is a high frequency function.
static $loggers = array();
if (!isset($loggers[$channel_name])) {
try {
if (function_exists('composer_manager_register_autoloader')) {
composer_manager_register_autoloader();
}
if (!class_exists('Drupal\\Monolog\\Logger')) {
$message = t('The Drupal\\Monolog\\Logger class was not found. Make sure the Monolog package is installed via Composer.');
throw new \RuntimeException($message);
}
$channel_profiles = variable_get('monolog_channel_profiles', array());
if (!isset($channel_profiles[$channel_name])) {
$channel_info = monolog_channel_info_load($channel_name);
$channel_profiles[$channel_name] = $channel_info['default profile'];
}
if (!($profile = monolog_profile_load($channel_profiles[$channel_name]))) {
$message = t('Logging profile not valid: @profile', array(
'@profile' => $profile,
));
throw new \InvalidArgumentException($message);
}
$logger = new Logger($channel_name);
monolog_push_handlers($logger, $profile);
$loggers[$channel_name] = $logger;
} catch (\InvalidArgumentException $e) {
$loggers[$channel_name] = new NullLogger();
// The user module might not be loaded if watchdog() is called too early.
// @see http://drupal.org/node/1997462
if (function_exists('user_access') && user_access('administer site configuration')) {
drupal_set_message($e
->getMessage(), 'error');
}
}
}
return $loggers[$channel_name];
}