mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx-test: add --loglevel=
option.
This commit is contained in:
parent
bb377fd20e
commit
e875d2128e
@ -106,7 +106,7 @@ bool parse_option<unsigned>(int argc, char *const argv[], int &narg,
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!scan->verb)
|
if (!scan->verb)
|
||||||
failure("Unknown verb '%.*s', for option '==%s'\n", (int)len, list,
|
failure("Unknown verb '%.*s', for option '--%s'\n", (int)len, list,
|
||||||
option);
|
option);
|
||||||
if (strlen(scan->verb) == len && strncmp(list, scan->verb, len) == 0) {
|
if (strlen(scan->verb) == len && strncmp(list, scan->verb, len) == 0) {
|
||||||
mask = strikethrough ? mask & ~scan->mask : mask | scan->mask;
|
mask = strikethrough ? mask & ~scan->mask : mask | scan->mask;
|
||||||
@ -257,6 +257,69 @@ bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
||||||
|
logging::loglevel &loglevel) {
|
||||||
|
const char *value_cstr;
|
||||||
|
if (!parse_option(argc, argv, narg, option, &value_cstr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "min") == 0 || strcmp(value_cstr, "minimal") == 0 ||
|
||||||
|
strcmp(value_cstr, "fatal") == 0) {
|
||||||
|
loglevel = logging::failure;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "error") == 0 || strcmp(value_cstr, "err") == 0) {
|
||||||
|
loglevel = logging::error;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "warning") == 0 || strcmp(value_cstr, "warn") == 0) {
|
||||||
|
loglevel = logging::error;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "default") == 0 || strcmp(value_cstr, "notice") == 0) {
|
||||||
|
loglevel = logging::notice;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "verbose") == 0) {
|
||||||
|
loglevel = logging::verbose;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "debug") == 0) {
|
||||||
|
loglevel = logging::debug;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "trace") == 0) {
|
||||||
|
loglevel = logging::trace;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(value_cstr, "max") == 0 || strcmp(value_cstr, "maximal") == 0 ||
|
||||||
|
strcmp(value_cstr, "extra") == 0) {
|
||||||
|
loglevel = logging::extra;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *suffix = nullptr;
|
||||||
|
unsigned long long raw = strtoull(value_cstr, &suffix, 0);
|
||||||
|
if ((suffix && *suffix) || errno) {
|
||||||
|
suffix = nullptr;
|
||||||
|
errno = 0;
|
||||||
|
raw = strtoull(value_cstr, &suffix, 10);
|
||||||
|
}
|
||||||
|
if ((!suffix || !*suffix) && !errno && raw < 8) {
|
||||||
|
loglevel = static_cast<logging::loglevel>(raw);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
failure("Unknown log-level '%s', for option '--%s'\n", value_cstr, option);
|
||||||
|
}
|
||||||
|
|
||||||
bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
||||||
bool &value) {
|
bool &value) {
|
||||||
const char *value_cstr = nullptr;
|
const char *value_cstr = nullptr;
|
||||||
|
@ -133,6 +133,8 @@ inline bool parse_option_intptr(int argc, char *const argv[], int &narg,
|
|||||||
int32_t(maxval), int32_t(default_value));
|
int32_t(maxval), int32_t(default_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool parse_option(int argc, char *const argv[], int &narg, const char *option,
|
||||||
|
logging::loglevel &);
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
struct keygen_params_pod {
|
struct keygen_params_pod {
|
||||||
|
@ -24,6 +24,7 @@ MDBX_NORETURN void usage(void) {
|
|||||||
"usage:\n"
|
"usage:\n"
|
||||||
" --help or -h Show this text\n"
|
" --help or -h Show this text\n"
|
||||||
"Common parameters:\n"
|
"Common parameters:\n"
|
||||||
|
" --loglevel=[0-7]|[extra..fatal]"
|
||||||
" --pathname=... Path and/or name of database files\n"
|
" --pathname=... Path and/or name of database files\n"
|
||||||
" --repeat=N Set repeat counter\n"
|
" --repeat=N Set repeat counter\n"
|
||||||
" --threads=N Number of thread (unsupported for now)\n"
|
" --threads=N Number of thread (unsupported for now)\n"
|
||||||
@ -319,6 +320,13 @@ int main(int argc, char *const argv[]) {
|
|||||||
config::duration, 1))
|
config::duration, 1))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
logging::loglevel loglevel;
|
||||||
|
if (config::parse_option(argc, argv, narg, "loglevel", loglevel)) {
|
||||||
|
logging::setup(loglevel, "main");
|
||||||
|
params.loglevel = static_cast<uint8_t>(loglevel);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const char *value = nullptr;
|
const char *value = nullptr;
|
||||||
if (config::parse_option(argc, argv, narg, "case", &value)) {
|
if (config::parse_option(argc, argv, narg, "case", &value)) {
|
||||||
fixup4qemu(params);
|
fixup4qemu(params);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user