Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --verbose and --VERBOSE with standard long opt format. #824

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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