mca/base: standize MCA verbosity levels
Up until this point we have had inconsistent usage for MCA verbosity levels. This commit attempts to correct this by recommending components use these standard levels: none (0), error (1), warn (10), info (20), debug (40), and trace (60). Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
родитель
e57861b0a5
Коммит
8cbf743cfa
@ -11,7 +11,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2013 Los Alamos National Security, LLC. All rights
|
||||
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
@ -69,6 +69,30 @@ OPAL_DECLSPEC extern bool mca_base_component_disable_dlopen;
|
||||
OPAL_DECLSPEC extern char *mca_base_system_default_path;
|
||||
OPAL_DECLSPEC extern char *mca_base_user_default_path;
|
||||
|
||||
/*
|
||||
* Standard verbosity levels
|
||||
*/
|
||||
enum {
|
||||
/** total silence */
|
||||
MCA_BASE_VERBOSE_NONE = -1,
|
||||
/** only errors are printed */
|
||||
MCA_BASE_VERBOSE_ERROR = 0,
|
||||
/** emit messages about component selection, open, and unloading */
|
||||
MCA_BASE_VERBOSE_COMPONENT = 10,
|
||||
/** also emit warnings */
|
||||
MCA_BASE_VERBOSE_WARN = 20,
|
||||
/** also emit general, user-relevant information, such as rationale as to why certain choices
|
||||
* or code paths were taken, information gleaned from probing the local system, etc. */
|
||||
MCA_BASE_VERBOSE_INFO = 40,
|
||||
/** also emit relevant tracing information (e.g., which functions were invoked /
|
||||
* call stack entry/exit info) */
|
||||
MCA_BASE_VERBOSE_TRACE = 60,
|
||||
/** also emit Open MPI-developer-level (i.e,. highly detailed) information */
|
||||
MCA_BASE_VERBOSE_DEBUG = 80,
|
||||
/** also output anything else that might be useful */
|
||||
MCA_BASE_VERBOSE_MAX = 100,
|
||||
};
|
||||
|
||||
/*
|
||||
* Public functions
|
||||
*/
|
||||
|
@ -92,10 +92,16 @@ int mca_base_framework_register (struct mca_base_framework_t *framework,
|
||||
}
|
||||
|
||||
/* register a verbosity variable for this framework */
|
||||
asprintf (&desc, "Verbosity level for the %s framework (0 = no verbosity)",
|
||||
framework->framework_name);
|
||||
ret = asprintf (&desc, "Verbosity level for the %s framework (default: 0)",
|
||||
framework->framework_name);
|
||||
if (0 > ret) {
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
framework->framework_verbose = MCA_BASE_VERBOSE_ERROR;
|
||||
ret = mca_base_framework_var_register (framework, "verbose", desc,
|
||||
MCA_BASE_VAR_TYPE_INT, NULL, 0,
|
||||
MCA_BASE_VAR_TYPE_INT,
|
||||
&mca_base_var_enum_verbose, 0,
|
||||
MCA_BASE_VAR_FLAG_SETTABLE,
|
||||
OPAL_INFO_LVL_8,
|
||||
MCA_BASE_VAR_SCOPE_LOCAL,
|
||||
|
@ -852,7 +852,7 @@ int mca_base_var_deregister(int vari)
|
||||
var->mbv_storage->stringval) {
|
||||
free (var->mbv_storage->stringval);
|
||||
var->mbv_storage->stringval = NULL;
|
||||
} else if (MCA_BASE_VAR_TYPE_BOOL != var->mbv_type && NULL != var->mbv_enumerator) {
|
||||
} else if (var->mbv_enumerator && !var->mbv_enumerator->enum_is_static) {
|
||||
OBJ_RELEASE(var->mbv_enumerator);
|
||||
}
|
||||
|
||||
@ -1486,7 +1486,9 @@ static int register_variable (const char *project_name, const char *framework_na
|
||||
OBJ_RELEASE (var->mbv_enumerator);
|
||||
}
|
||||
|
||||
OBJ_RETAIN(enumerator);
|
||||
if (!enumerator->enum_is_static) {
|
||||
OBJ_RETAIN(enumerator);
|
||||
}
|
||||
}
|
||||
|
||||
var->mbv_enumerator = enumerator;
|
||||
@ -1847,7 +1849,7 @@ static void var_destructor(mca_base_var_t *var)
|
||||
}
|
||||
|
||||
/* don't release the boolean enumerator */
|
||||
if (MCA_BASE_VAR_TYPE_BOOL != var->mbv_type && NULL != var->mbv_enumerator) {
|
||||
if (var->mbv_enumerator && !var->mbv_enumerator->enum_is_static) {
|
||||
OBJ_RELEASE(var->mbv_enumerator);
|
||||
}
|
||||
|
||||
@ -1860,6 +1862,7 @@ static void var_destructor(mca_base_var_t *var)
|
||||
if (NULL != var->mbv_long_name) {
|
||||
free(var->mbv_long_name);
|
||||
}
|
||||
|
||||
if (NULL != var->mbv_description) {
|
||||
free(var->mbv_description);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2012-2014 Los Alamos National Security, LLC. All rights
|
||||
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
@ -23,6 +23,7 @@
|
||||
#include "opal_config.h"
|
||||
|
||||
#include "opal/mca/base/mca_base_var_enum.h"
|
||||
#include "opal/mca/base/base.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -33,6 +34,10 @@ static void mca_base_var_enum_destructor (mca_base_var_enum_t *enumerator);
|
||||
OBJ_CLASS_INSTANCE(mca_base_var_enum_t, opal_object_t, mca_base_var_enum_constructor,
|
||||
mca_base_var_enum_destructor);
|
||||
|
||||
static int enum_dump (mca_base_var_enum_t *self, char **out);
|
||||
static int enum_get_count (mca_base_var_enum_t *self, int *count);
|
||||
static int enum_get_value (mca_base_var_enum_t *self, int index, int *value, const char **string_value);
|
||||
|
||||
static int mca_base_var_enum_bool_get_count (mca_base_var_enum_t *enumerator, int *count)
|
||||
{
|
||||
*count = 2;
|
||||
@ -97,6 +102,7 @@ static int mca_base_var_enum_bool_dump (mca_base_var_enum_t *self, char **out)
|
||||
|
||||
mca_base_var_enum_t mca_base_var_enum_bool = {
|
||||
.super = OPAL_OBJ_STATIC_INIT(opal_object_t),
|
||||
.enum_is_static = true,
|
||||
.enum_name = "boolean",
|
||||
.get_count = mca_base_var_enum_bool_get_count,
|
||||
.get_value = mca_base_var_enum_bool_get_value,
|
||||
@ -105,6 +111,108 @@ mca_base_var_enum_t mca_base_var_enum_bool = {
|
||||
.dump = mca_base_var_enum_bool_dump
|
||||
};
|
||||
|
||||
/* verbosity enumerator */
|
||||
static mca_base_var_enum_value_t verbose_values[] = {
|
||||
{MCA_BASE_VERBOSE_NONE, "none"},
|
||||
{MCA_BASE_VERBOSE_ERROR, "error"},
|
||||
{MCA_BASE_VERBOSE_COMPONENT, "component"},
|
||||
{MCA_BASE_VERBOSE_WARN, "warn"},
|
||||
{MCA_BASE_VERBOSE_INFO, "info"},
|
||||
{MCA_BASE_VERBOSE_TRACE, "trace"},
|
||||
{MCA_BASE_VERBOSE_DEBUG, "debug"},
|
||||
{MCA_BASE_VERBOSE_MAX, "max"},
|
||||
{-1, NULL}
|
||||
};
|
||||
|
||||
static int mca_base_var_enum_verbose_vfs (mca_base_var_enum_t *self, const char *string_value,
|
||||
int *value)
|
||||
{
|
||||
char *tmp;
|
||||
int v;
|
||||
|
||||
/* skip whitespace */
|
||||
string_value += strspn (string_value, " \t\n\v\f\r");
|
||||
|
||||
v = strtol (string_value, &tmp, 10);
|
||||
if (*tmp != '\0') {
|
||||
for (int i = 0 ; verbose_values[i].string ; ++i) {
|
||||
if (0 == strcmp (verbose_values[i].string, string_value)) {
|
||||
*value = verbose_values[i].value;
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return OPAL_ERR_NOT_FOUND;
|
||||
} else if (v < MCA_BASE_VERBOSE_NONE) {
|
||||
v = MCA_BASE_VERBOSE_NONE;
|
||||
} else if (v > MCA_BASE_VERBOSE_MAX) {
|
||||
v = MCA_BASE_VERBOSE_MAX;
|
||||
}
|
||||
|
||||
*value = v;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int mca_base_var_enum_verbose_sfv (mca_base_var_enum_t *self, const int value,
|
||||
const char **string_value)
|
||||
{
|
||||
static char buffer[4];
|
||||
|
||||
if (value < 0 || value > 100) {
|
||||
return OPAL_ERR_VALUE_OUT_OF_BOUNDS;
|
||||
}
|
||||
|
||||
for (int i = 0 ; verbose_values[i].string ; ++i) {
|
||||
if (verbose_values[i].value == value) {
|
||||
*string_value = verbose_values[i].string;
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
snprintf (buffer, 4, "%d", value);
|
||||
if (string_value) {
|
||||
*string_value = buffer;
|
||||
}
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int mca_base_var_enum_verbose_dump (mca_base_var_enum_t *self, char **out)
|
||||
{
|
||||
char *tmp;
|
||||
int ret;
|
||||
|
||||
ret = enum_dump (self, out);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = asprintf (&tmp, "%s, 0 - 100", *out);
|
||||
free (*out);
|
||||
if (0 > ret) {
|
||||
*out = NULL;
|
||||
return OPAL_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
|
||||
*out = tmp;
|
||||
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
mca_base_var_enum_t mca_base_var_enum_verbose = {
|
||||
.super = OPAL_OBJ_STATIC_INIT(opal_object_t),
|
||||
.enum_is_static = true,
|
||||
.enum_name = "verbosity",
|
||||
.get_count = enum_get_count,
|
||||
.get_value = enum_get_value,
|
||||
.value_from_string = mca_base_var_enum_verbose_vfs,
|
||||
.string_from_value = mca_base_var_enum_verbose_sfv,
|
||||
.dump = mca_base_var_enum_verbose_dump,
|
||||
.enum_value_count = 8,
|
||||
.enum_values = verbose_values,
|
||||
};
|
||||
|
||||
|
||||
int mca_base_var_enum_create (const char *name, const mca_base_var_enum_value_t *values, mca_base_var_enum_t **enumerator)
|
||||
{
|
||||
@ -264,6 +372,7 @@ static void mca_base_var_enum_constructor (mca_base_var_enum_t *enumerator)
|
||||
enumerator->value_from_string = enum_value_from_string;
|
||||
enumerator->string_from_value = enum_string_from_value;
|
||||
enumerator->dump = enum_dump;
|
||||
enumerator->enum_is_static = false;
|
||||
}
|
||||
|
||||
static void mca_base_var_enum_destructor (mca_base_var_enum_t *enumerator)
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
|
||||
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
|
||||
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
|
||||
* reserved.
|
||||
* $COPYRIGHT$
|
||||
*
|
||||
@ -106,6 +106,9 @@ typedef struct mca_base_var_enum_value_t mca_base_var_enum_value_t;
|
||||
struct mca_base_var_enum_t {
|
||||
opal_object_t super;
|
||||
|
||||
/** Is the enumerator statically allocated */
|
||||
bool enum_is_static;
|
||||
|
||||
/** Name of this enumerator. This value is duplicated from the argument provided to
|
||||
mca_base_var_enum_create() */
|
||||
char *enum_name;
|
||||
@ -176,5 +179,9 @@ OPAL_DECLSPEC int mca_base_var_enum_create (const char *name, const mca_base_var
|
||||
*/
|
||||
extern mca_base_var_enum_t mca_base_var_enum_bool;
|
||||
|
||||
/**
|
||||
* Verbosity level enumerator
|
||||
*/
|
||||
extern mca_base_var_enum_t mca_base_var_enum_verbose;
|
||||
|
||||
#endif /* !defined(MCA_BASE_VAR_ENUM_H) */
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user