MCPcopy Create free account
hub / github.com/apache/httpd / set_loglevel

Function set_loglevel

server/core.c:3460–3522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3458}
3459
3460static const char *set_loglevel(cmd_parms *cmd, void *config_, const char *arg_)
3461{
3462 char *level_str;
3463 int level;
3464 module *module;
3465 char *arg = apr_pstrdup(cmd->temp_pool, arg_);
3466 struct ap_logconf *log;
3467 const char *err;
3468
3469 if (cmd->path) {
3470 core_dir_config *dconf = config_;
3471 if (!dconf->log) {
3472 dconf->log = ap_new_log_config(cmd->pool, NULL);
3473 }
3474 log = dconf->log;
3475 }
3476 else {
3477 log = &cmd->server->log;
3478 }
3479
3480 if (arg == NULL)
3481 return "LogLevel requires level keyword or module loglevel specifier";
3482
3483 level_str = ap_strrchr(arg, ':');
3484
3485 if (level_str == NULL) {
3486 err = ap_parse_log_level(arg, &log->level);
3487 if (err != NULL)
3488 return err;
3489 ap_reset_module_loglevels(log, APLOG_NO_MODULE);
3490 ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,
3491 "Setting LogLevel for all modules to %s", arg);
3492 return NULL;
3493 }
3494
3495 *level_str++ = '\0';
3496 if (!*level_str) {
3497 return apr_psprintf(cmd->temp_pool, "Module specifier '%s' must be "
3498 "followed by a log level keyword", arg);
3499 }
3500
3501 err = ap_parse_log_level(level_str, &level);
3502 if (err != NULL)
3503 return apr_psprintf(cmd->temp_pool, "%s:%s: %s", arg, level_str, err);
3504
3505 if ((module = find_module(cmd->server, arg)) == NULL) {
3506 char *name = apr_psprintf(cmd->temp_pool, "%s_module", arg);
3507 ap_log_error(APLOG_MARK, APLOG_TRACE6, 0, cmd->server,
3508 "Cannot find module '%s', trying '%s'", arg, name);
3509 module = find_module(cmd->server, name);
3510 }
3511
3512 if (module == NULL) {
3513 return apr_psprintf(cmd->temp_pool, "Cannot find module %s", arg);
3514 }
3515
3516 ap_set_module_loglevel(cmd->pool, log, module->module_index, level);
3517 ap_log_error(APLOG_MARK, APLOG_TRACE3, 0, cmd->server,

Callers

nothing calls this directly

Calls 7

ap_new_log_configFunction · 0.85
ap_strrchrFunction · 0.85
ap_parse_log_levelFunction · 0.85
find_moduleFunction · 0.85
ap_set_module_loglevelFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected