laamaa / m8c

Cross-platform M8 tracker headless client
Other
409 stars 85 forks source link

Add command line option parsing and granular logging control #52

Closed daniel214 closed 2 years ago

daniel214 commented 2 years ago

This PR

Known Issues

Sample output:

% ./m8c --help
Usage: m8c [OPTION...] 
An open-source graphical console for the Dirtywave M8 by Jonne Kokkonen
See https://github.com/laamaa/m8c/blob/main/LICENSE for license info.

 Global Log Options:
  -L, --log=LEVEL            Set global log level
  -q, -s, --quiet, --silent  Don't produce any output (-L CRITICAL)
  -v, --verbose              Produce verbose output (-L VERBOSE)

 Log Category Options:
      --log-app=LEVEL        Set app log level
      --log-comms=LEVEL      Set M8 comms log level
      --log-config=LEVEL     Set config log level
      --log-input=LEVEL      Set input log level
      --log-render=LEVEL     Set render log level
      --log-serial=LEVEL     Set serial log level

 Informational Options:
  -?, --help                 Give this help list
      --usage                Give a short usage message
  -V, --version              Print program version

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

Log levels:
    VERBOSE     All log messages
    DEBUG       .
    INFO        .
    WARN        .
    ERROR       .
    CRITICAL    Program termination messages only

Note that you can mix -L and specific log modifiers. The specific modifiers
will override the global setting for that log topic.

Report bugs to https://github.com/laamaa/m8c/issues.
daniel214 commented 2 years ago

Oops, meant "skip-checks: true" on that last one! 😬

laamaa commented 2 years ago

For adding better debug output only adding an external dependency feels a bit overkill... :) but this feature might have some other uses as well, like the config file parameter you already had started or specifying a device in case there's multiple M8s connected etc.

This seems to break Windows builds currently, would probably need the relevant library package added there as well and the .dll file added to the output zip before this can be merged. I can try to add them/test the Win build at some point, not sure yet when exactly...

daniel214 commented 2 years ago

Yes, I agree, but as you said there are a lot of possibilities to make things quite a bit easier. My intention with splitting off the logs is so that you can easily tackle things like #51 by adding a few more debug lines and calling with --log-input=verbose. It could also assist with graphics issues using --log-render=debug which now prints driver info and enables the fps log message.

When I selected argp, I didn't realize it is almost completely unsupported in windows. I think there are really easy ways to do it, but I'm also wary of statically linking a GPL library.

laamaa commented 2 years ago

Thanks for the PR. Unfortunately I don't think I want to add another dependency for now, especially something that might cause cross-platform problems. Those users who need deeper debug messages probably are capable of uncommenting the relevant define in code or passing the compile time flag. This method could be a good possibility though at some point if more advanced command line parsing is needed.