open-simulation-platform / cosim-cli

Command-line interface for libcosim
https://open-simulation-platform.github.io/cosim
Mozilla Public License 2.0
10 stars 4 forks source link

Add --log-level and --verbose options #7

Closed kyllingstad closed 5 years ago

kyllingstad commented 5 years ago

This builds on the work in PR #1 and adds the global --log-level option specified in Confluence, as well as a --verbose/-v option which is a shortcut for --log-level=info.

While doing this, I also made a new, general abstraction for global options in the CLI application framework: cli_option_set. I've refactored the --version option to use this abstraction too.

~I've targeted this on the PR #1 branch so that all you see is the stuff I've added. I'll retarget it on master once #1 is merged.~ I'll also update the simulation progress monitor for the "run" commands (#3, #4) once the present PR has been merged, so it logs its output at level info, as specified. This would complete the fixing of issue #6.

I can't really give any examples yet since I based this on a version of the code that doesn't actually log anything. But the help message looks like this:

> cse help
NAME
  cse - Command-line interface to the Core Simulation Environment

SYNOPSIS
  cse <subcommand> <args...> [options...]

DESCRIPTION
  The Core Simulation Environment is free and open-source software for running distributed
  co-simulations.

SUBCOMMANDS
  help                Shows documentation

OPTIONS
  --log-level arg (=warning) Sets the detail/severity level of diagnostic program output.
                             Valid argument values, in order of increasing detail (and
                             decreasing severity), are: error, warning, info, debug, trace.
  -v [ --verbose ]           Shorthand for --log-level=info.
  --version                  Display program version information and exit.
  --help                     Display a help message and exit.

Note: This PR depends on the changes in open-simulation-platform/cse-core#314, so anyone who wants to compile this need to update conanfile.txt to use cse-core/0.4.0@osp/feature_110-user-controllable-logging instead of master.

kyllingstad commented 5 years ago

I've pushed a commit to this branch where I've resolved the merge conflicts, but for some reason, the pull request doesn't get updated. Possibly a bad cache or some subsystem which is down on GitHub. I'll merge it manually.