Skip to content

Commit

Permalink
Add support for --verbose and --VERBOSE with standard long opt format.
Browse files Browse the repository at this point in the history
ELPP will now support --verbose which will set maximum verbosity or with
a specified level (both in short and long option form):
  * --v=2
  * --verbose=2
  * --verbose (sets verbosity to 9)

Fixes abumq#823
  • Loading branch information
jshort committed Oct 19, 2022
1 parent 8489989 commit d3166b8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [9.97.1] - 19-10-2022
### Bug Fixes
* Support for long option verbosity with argument (--verbose=5)

## [9.97.0] - 25-12-2020
### Features
* Support for QNX OS
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,9 @@ Following table will explain all command line arguments that you may use to defi
| Argument | Description |
|----------------------------|-----------------------------------------------------------------------------------------|
| `-v` | Activates maximum verbosity |
| `--v=2` | Activates verbosity upto verbose level 2 (valid range: 0-9) |
| `--verbose` | Activates maximum verbosity |
| `--v=2` | Activates verbosity upto verbose level 2 (valid range: 0-9) |
| `--verbose=5` | Activates verbosity upto verbose level 5 (valid range: 0-9) |
| `-vmodule=MODULE_NAME` | Activates verbosity for files starting with main to level 1, the rest of the files depend on logging flag `AllowVerboseIfModuleNotSpecified` Please see Logging Flags section above. Two modules can be separated by comma. Please note vmodules are last in order of precedence of checking arguments for verbose logging, e.g, if we have -v in application arguments before vmodules, vmodules will be ignored. |
| `--logging-flags=3` | Sets logging flag. In example `i.e, 3`, it sets logging flag to `NewLineForContainer` and `AllowVerboseIfModuleNotSpecified`. See logging flags section above for further details and values. See macros section to disable this function. |
| `--default-log-file=FILE` |Sets default log file for existing and future loggers. You may want to consider defining `ELPP_NO_DEFAULT_LOG_FILE` to prevent creation of default empty log file during pre-processing. See macros section to disable this function. |
Expand Down Expand Up @@ -989,7 +990,7 @@ Here is a good example of your own handler
INITIALIZE_EASYLOGGINGPP
void myCrashHandler(int sig) {
LOG(ERROR) << "Woops! Crashed!";
LOG(ERROR) << "Woops! Crashed!";
// FOLLOWING LINE IS ABSOLUTELY NEEDED AT THE END IN ORDER TO ABORT APPLICATION
el::Helpers::crashAbort(sig);
}
Expand Down
10 changes: 7 additions & 3 deletions src/easylogging++.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2041,13 +2041,17 @@ bool VRegistry::allowed(base::type::VerboseLevel vlevel, const char* file) {
}

void VRegistry::setFromArgs(const base::utils::CommandLineArgs* commandLineArgs) {
if (commandLineArgs->hasParam("-v") || commandLineArgs->hasParam("--verbose") ||
commandLineArgs->hasParam("-V") || commandLineArgs->hasParam("--VERBOSE")) {
setLevel(base::consts::kMaxVerboseLevel);
if (commandLineArgs->hasParamWithValue("--verbose")) {
setLevel(static_cast<base::type::VerboseLevel>(atoi(commandLineArgs->getParamValue("--verbose"))));
} else if (commandLineArgs->hasParamWithValue("--VERBOSE")) {
setLevel(static_cast<base::type::VerboseLevel>(atoi(commandLineArgs->getParamValue("--VERBOSE"))));
} else if (commandLineArgs->hasParamWithValue("--v")) {
setLevel(static_cast<base::type::VerboseLevel>(atoi(commandLineArgs->getParamValue("--v"))));
} else if (commandLineArgs->hasParamWithValue("--V")) {
setLevel(static_cast<base::type::VerboseLevel>(atoi(commandLineArgs->getParamValue("--V"))));
} else if (commandLineArgs->hasParam("-v") || commandLineArgs->hasParam("--verbose") ||
commandLineArgs->hasParam("-V") || commandLineArgs->hasParam("--VERBOSE")) {
setLevel(base::consts::kMaxVerboseLevel);
} else if ((commandLineArgs->hasParamWithValue("-vmodule")) && vModulesEnabled()) {
setModules(commandLineArgs->getParamValue("-vmodule"));
} else if (commandLineArgs->hasParamWithValue("-VMODULE") && vModulesEnabled()) {
Expand Down

0 comments on commit d3166b8

Please sign in to comment.