Repository navigation
Added osvr_server command-line options - #529
Conversation
…check on creating config file
…absense of config file
…logging-improvements
JeroMiya
left a comment
There was a problem hiding this comment.
See questions/requests. Not sure, but I think this breaks server auto-start and default double-click behavior (with no command line arguments). Should look for a file with the default config file name in the CWD in that case and only use an empty config if that file does not exist either.
| opt::options_description optionsVisible("Command Line Options"); | ||
| opt::positional_options_description optionsPositional; | ||
|
|
||
| optionsPositional.add("config", -1); |
There was a problem hiding this comment.
Does this make the config option the default option when only one argument is passed (like when you drag a config file over the server in windows explorer)? Just making sure we don't change the current behavior in that case.
There was a problem hiding this comment.
Yes. So if you run osvr_server blah.json then it will use blah.json as the configuration file. The same thing happens if you drag and drop blah.json onto the osvr_server.exe program in Windows.
| log->debug("Verbose logging enabled."); | ||
| } | ||
|
|
||
| configName = values["config"].as<std::string>(); |
There was a problem hiding this comment.
what does this line do if no command line arguments are passed?
There was a problem hiding this comment.
@JeroMiya If no configuration file is specified, it will check to see if the file returned by osvr::server::getDefaultConfigFilename() exists and is readable. If it is, then we'll use it. Otherwise, we'll start the server with an empty { } configuration.
| log->info() | ||
| << "Using default config file - pass a filename on the command " | ||
| "line to use a different one."; | ||
| server = osvr::server::configureServerFromString("{ }"); |
There was a problem hiding this comment.
We need to also check for a file called osvr::server::getDefaultConfigFilename() in the current working directory, so that we don't break server auto-start and double-click behavior (i.e. starting with no arguments should load the default config file name from the CWD). Only if the config is not specified, and the default-named config file is not found in the CWD, should we be using a blank config as is done here.
There was a problem hiding this comment.
If no configuration file is specified on the command line, we assume the user specified the filename returned by osvr::server::getDefaultConfigFilename(). If that file exists, we'll use it. If it doesn't, then we'll start the server with an empty { } configuration.
|
If no configuration file is specified, we default to using |
gfrolov
left a comment
There was a problem hiding this comment.
Just a couple clarifications are needed for my comments, but otherwise it looks good
| configPath = boost::none; | ||
| } | ||
|
|
||
| if (configPath) { |
There was a problem hiding this comment.
I'm assuming this check fails if you provide an empty string to boost::optional<fs::path> configPath(configName) on line 111 ?
There was a problem hiding this comment.
@mars979 I think so, since I would expect fs::exists() to return false on an empty string.
| srvConfig.loadConfig(json); | ||
| ret = srvConfig.constructServer(); | ||
| } catch (std::exception &e) { | ||
| log->error() |
There was a problem hiding this comment.
Should we log the std::exception error here ?
There was a problem hiding this comment.
@mars979 We are logging the exception here. (Or are you suggesting we shouldn't log it?)
There was a problem hiding this comment.
@godbyk , I meant to ask if log->error() automatically logs the std::exception &e or do you need to explicitly add log->error(e.what()) (or something similar)
There was a problem hiding this comment.
@mars979 Ah, gotcha. We're logging it a couple lines down. (clang-format's line-wrapping hinders the readability of the line.)
There was a problem hiding this comment.
Ah, it was just wrapped to next line. My bad.
This PR adds command-line options to the server for adjusting the log verbosity and also allows the server to run without specifying a configuration file (in which case it will assume an empty configuration
{ }).Verbose logging sets the log level to
debugand debug logging sets the log level totrace.This subsumes PR #293 by @Outurnate.