-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce log spam: gated logging for high frequency items.
- Loading branch information
jmacxx
committed
Oct 15, 2023
1 parent
ce8634a
commit e2cf7e1
Showing
4 changed files
with
72 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.price.util; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.time.Instant; | ||
|
||
/* Per https://github.com/bisq-network/bisq-pricenode/issues/33 | ||
* There's too much logging of outlier filtering data, fills up the logs too fast and obliterates other valid logging. | ||
* It correlates with client requests. Change that logging so its output once per minute. | ||
*/ | ||
|
||
@Slf4j | ||
public class GatedLogging { | ||
private long timestampOfLastLogMessage = 0; | ||
|
||
public void maybeLogInfo(String format, Object... params) { | ||
if (gatingOperation()) { | ||
log.info(format, params); | ||
} | ||
} | ||
|
||
public boolean gatingOperation() { | ||
if (Instant.now().getEpochSecond() - timestampOfLastLogMessage > 60) { | ||
timestampOfLastLogMessage = Instant.now().getEpochSecond(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |