Skip to content

Commit

Permalink
Add logging of events
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Sep 9, 2024
1 parent 9a154d3 commit 337c7b0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Add logging of events

### Changed

- Bump sdmx-dl from 3.0.0-beta.12 to [3.0.0-beta.13](https://github.com/nbbrd/sdmx-dl/releases/tag/v3.0.0-beta.13)

## [3.1.0] - 2023-10-16

This is a feature release of SDMX extensions for JDemetra+ v3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import java.io.IOException;
import java.util.Locale;
import java.util.Properties;
import java.util.logging.Level;

@lombok.extern.java.Log
@lombok.Data
public class SdmxWebConfiguration {

Expand Down Expand Up @@ -57,6 +59,10 @@ public class SdmxWebConfiguration {
private static final boolean DEFAULT_DISPLAY_CODES = false;
private boolean displayCodes = DEFAULT_DISPLAY_CODES;

private static final String LOG_EVENTS_PROPERTY = "logEvents";
private static final boolean DEFAULT_LOG_EVENTS = false;
private boolean logEvents = DEFAULT_LOG_EVENTS;

@MightBeGenerated
public static SdmxWebConfiguration copyOf(SdmxWebConfiguration bean) {
SdmxWebConfiguration result = new SdmxWebConfiguration();
Expand All @@ -68,6 +74,7 @@ public static SdmxWebConfiguration copyOf(SdmxWebConfiguration bean) {
result.noDefaultSSL = bean.noDefaultSSL;
result.noSystemSSL = bean.noSystemSSL;
result.displayCodes = bean.displayCodes;
result.logEvents = bean.logEvents;
return result;
}

Expand Down Expand Up @@ -95,10 +102,18 @@ public Languages toLanguages() {

private void reportEvent(WebSource source, String marker, CharSequence message) {
StatusDisplayer.getDefault().setStatusText(message.toString());
if (logEvents) {
log.log(Level.INFO, () -> asLogMessage(source, marker, message));
}
}

private void reportError(WebSource source, String marker, CharSequence message, IOException error) {
NotificationDisplayer.getDefault().notify(message.toString(), SdmxIcons.getDefaultIcon(), "", null);
log.log(Level.SEVERE, error, () -> asLogMessage(source, marker, message));
}

private static String asLogMessage(WebSource source, String marker, CharSequence message) {
return "[" + source.getId() + "] (" + marker + ") " + message;
}

Sheet toSheet() {
Expand Down Expand Up @@ -147,6 +162,11 @@ Sheet toSheet() {
.display("No system SSL")
.description("Disable system truststore")
.add();
b.withBoolean()
.select(this, LOG_EVENTS_PROPERTY)
.display("Log events")
.description("Log events in IDE logs")
.add();
result.put(b.build());

return result;
Expand All @@ -165,5 +185,6 @@ Sheet toSheet() {
.with(PropertyHandler.onEnum(NO_DEFAULT_SSL_PROPERTY, DEFAULT_NO_DEFAULT_SSL), SdmxWebConfiguration::getNoDefaultSSL, SdmxWebConfiguration::setNoDefaultSSL)
.with(PropertyHandler.onEnum(NO_SYSTEM_SSL_PROPERTY, DEFAULT_NO_SYSTEM_SSL), SdmxWebConfiguration::getNoSystemSSL, SdmxWebConfiguration::setNoSystemSSL)
.with(PropertyHandler.onBoolean(DISPLAY_CODES_PROPERTY, DEFAULT_DISPLAY_CODES), SdmxWebConfiguration::isDisplayCodes, SdmxWebConfiguration::setDisplayCodes)
.with(PropertyHandler.onBoolean(LOG_EVENTS_PROPERTY, DEFAULT_LOG_EVENTS), SdmxWebConfiguration::isLogEvents, SdmxWebConfiguration::setLogEvents)
.build();
}

0 comments on commit 337c7b0

Please sign in to comment.