diff --git a/src/driver/toks_driver_ctx.c b/src/driver/toks_driver_ctx.c index 3fe0043..92c7a15 100644 --- a/src/driver/toks_driver_ctx.c +++ b/src/driver/toks_driver_ctx.c @@ -285,6 +285,7 @@ int toks_get_driver_ctx( const char * program; const char * refstr; int ntokens; + int loglevel; int32_t tokpid; int32_t tsyspid; int32_t ctrlpid; @@ -324,6 +325,7 @@ int toks_get_driver_ctx( csyspid = 0; keylen = 0; ntokens = 0; + loglevel = 0; timeout = (-1); program = argv_program_name(argv[0]); @@ -382,6 +384,12 @@ int toks_get_driver_ctx( csyspid = toks_arg_to_int32((cspid=entry)); break; + case TAG_LOGLEVEL: + loglevel = toks_arg_to_int32(entry); + loglevel = (loglevel > 9) ? (-1) : loglevel; + cctx.loglevel = loglevel; + break; + case TAG_TIMEOUT: timeout = toks_arg_to_int64((msecs=entry)); timeout = (timeout < 0) ? (-2) : timeout; @@ -484,6 +492,14 @@ int toks_get_driver_ctx( return toks_get_driver_ctx_fail(meta); } + if ((cctx.drvflags & TOKS_DRIVER_MODE_SERVER) && (loglevel < 0)) { + if (flags & TOKS_DRIVER_VERBOSITY_ERRORS) + toks_dprintf(STDERR_FILENO, + "%s: error: loglevel must be in the range of 0..9.", + program); + return toks_get_driver_ctx_fail(meta); + } + if (uuid && ntapi->tt_string_to_guid_utf8(uuid->arg,&svcguid)) { if (flags & TOKS_DRIVER_VERBOSITY_ERRORS) toks_dprintf(STDERR_FILENO, diff --git a/src/internal/toksvc_driver_impl.h b/src/internal/toksvc_driver_impl.h index 6d37294..fdd3798 100644 --- a/src/internal/toksvc_driver_impl.h +++ b/src/internal/toksvc_driver_impl.h @@ -42,6 +42,7 @@ enum app_tags { TAG_CTRLPID, TAG_CSYSPID, TAG_LOGFILE, + TAG_LOGLEVEL, }; struct toks_ticks { diff --git a/src/skin/toks_skin_default.c b/src/skin/toks_skin_default.c index cf00237..25e6f5c 100644 --- a/src/skin/toks_skin_default.c +++ b/src/skin/toks_skin_default.c @@ -70,5 +70,8 @@ const struct argv_option toks_default_options[] = { "(x:/path/to/log), or native driver format " "(e.g. \\Device\\HarddiskX\\path\\to\\log"}, + {"log-level", 'O',TAG_LOGLEVEL,ARGV_OPTARG_REQUIRED,0,0,"", + "set the log level to %s in the range of 0..9"}, + {0,0,0,0,0,0,0,0} };