Add version info to debug output

- Initialize the log at the start of ipmi_main() to allow for proper
  logging at the start;
- Remove the unused log_level_get() function;
- Update log_level_set() to take verbosity instead of log level
  (default verbosity is 0, which is LOG_NOTICE log level),
  use the function to update log level as `-v` is encountered
  in command line;
- Move IANA PEN list debugging to verbosity 6. The list is too long
  to see it in each debug output of verbosity 5 that is used for
  debugging lan/lanplus packets;
- For verbosity >= 2 (that is `-vv`) add the ipmitool version
  information at the start.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin
2020-07-17 03:29:42 +03:00
committed by Alexander Amelkin
parent 3a1a9cb283
commit 16f937a117
3 changed files with 16 additions and 15 deletions

View File

@ -358,12 +358,16 @@ ipmi_main(int argc, char ** argv,
/* Set program locale according to system settings */
setlocale(LC_ALL, "");
/* save program name */
progname = strrchr(argv[0], '/');
progname = ((!progname) ? argv[0] : progname+1);
signal(SIGINT, ipmi_catch_sigint);
memset(kgkey, 0, sizeof(kgkey));
/* setup log */
log_init(progname, 0, 0);
while ((argflag = getopt(argc, (char **)argv, OPTION_STRING)) != -1)
{
switch (argflag) {
@ -443,7 +447,11 @@ ipmi_main(int argc, char ** argv,
break;
#endif /* IPMI_INTF_LANPLUS */
case 'v':
verbose++;
log_level_set(++verbose);
if (verbose == 2) {
/* add version info to debug output */
lprintf(LOG_DEBUG, "%s version %s\n", progname, VERSION);
}
break;
case 'c':
csv_output = 1;
@ -844,9 +852,6 @@ ipmi_main(int argc, char ** argv,
goto out_free;
}
/* setup log */
log_init(progname, 0, verbose);
/* load the IANA PEN registry */
if (ipmi_oem_info_init()) {
lprintf(LOG_ERR, "Failed to initialize the OEM info dictionary");