Skip to content

Commit 7244681

Browse files
committed
added INFOLOGGER_OPTIONS floodProtection
1 parent 191ae89 commit 7244681

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

doc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ achieved on CentOS 7 with e.g. (as root):
279279
- outputMode: the main output mode of the library. As accepted by INFOLOGGER_MODE. Default: infoLoggerD.
280280
- outputModeFallback: the fallback output mode of the library. As accepted by INFOLOGGER_MODE. Default: stdout. The fallback mode is selected on initialization only (not later at runtime), if the main mode fails on first attempt.
281281
- verbose: 0 or 1. Default: 0. If 1, extra information is printed on stdout, e.g. to report the selected output.
282+
- floodProtection: 0 or 1. Default: 1. Enable(1)/disable(0) the message flood protection.
282283
283284
284285

doc/releaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,4 @@ This file describes the main feature changes for each InfoLogger released versio
8686

8787
## next version
8888
- added INFOLOGGER_MODE=debug. In this mode, infoLogger library prints on stdout one line per message, with a list of comma-separated field = value pairs. Undefined fields are not shown.
89+
- added INFOLOGGER_OPTIONS environment variable, which allows overriding some of the built-in client defaults: outputMode, outputModeFallback, verbose, floodProtection.

src/InfoLogger.cxx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,18 @@ class InfoLogger::Impl
199199
throw __LINE__;
200200
}
201201
for (auto& it : kv) {
202+
//printf("%s = %s\n",it.first.c_str(), it.second.c_str());
202203
if (it.first == "outputMode") {
203204
getOutputStreamFromString(it.second.c_str(), mainMode);
204205
} else if (it.first == "outputModeFallback") {
205206
getOutputStreamFromString(it.second.c_str(), fallbackMode);
206207
} else if (it.first == "verbose") {
207208
verbose = atoi(it.second.c_str());
208-
} else {
209+
} else if (it.first == "floodProtection") {
210+
flood_protection = atoi(it.second.c_str());
211+
} else {
209212
// unknown option
210-
// printf("Unknown option %s\n",it.second.c_str());
213+
printf("Unknown infoLogger option %s\n",it.first.c_str());
211214
throw __LINE__;
212215
}
213216
}
@@ -241,6 +244,9 @@ class InfoLogger::Impl
241244
}
242245
if (verbose) {
243246
printf("Using output mode %s\n", getStringFromMode(currentMode.mode));
247+
if (!flood_protection) {
248+
printf("Flood protection disabled\n");
249+
}
244250
}
245251

246252
if (currentMode.mode == OutputMode::file) {
@@ -410,7 +416,7 @@ class InfoLogger::Impl
410416

411417
// message flood prevention
412418
// constants
413-
const bool flood_protection = 1; // if set, flood protection mechanism enabled
419+
bool flood_protection = 1; // if set, flood protection mechanism enabled
414420
const unsigned int flood_maxmsg_sec=500; // maximum messages in one second to trigger flood
415421
const unsigned int flood_maxmsg_min=1000; // maximum messages in one minute to trigger flood
416422
const unsigned int flood_maxmsg_file=1000; // maximum number of messages in overflow log file

0 commit comments

Comments
 (0)