Skip to content

Commit

Permalink
refine error handling
Browse files Browse the repository at this point in the history
Signed-off-by: georgi-l95 <[email protected]>
  • Loading branch information
georgi-l95 committed Dec 5, 2024
1 parent 85ae18b commit 73af5b2
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import javax.inject.Inject;

/** BlockStream Simulator App */
Expand Down Expand Up @@ -136,9 +139,18 @@ public StreamStatus getStreamStatus() {
}

private void loadLoggingProperties() {
final LogManager logManager = LogManager.getLogManager();
try (InputStream is = BlockStreamSimulator.class.getClassLoader().getResourceAsStream(LOGGING_PROPERTIES)) {
LogManager.getLogManager().readConfiguration(is);
} catch (IOException e) {
logManager.readConfiguration(is);
} catch (IOException | NullPointerException e) {
logManager.reset();
Logger rootLogger = logManager.getLogger("");
ConsoleHandler consoleHandler = new ConsoleHandler();

Check warning on line 148 in simulator/src/main/java/com/hedera/block/simulator/BlockStreamSimulatorApp.java

View check run for this annotation

Codecov / codecov/patch

simulator/src/main/java/com/hedera/block/simulator/BlockStreamSimulatorApp.java#L145-L148

Added lines #L145 - L148 were not covered by tests

consoleHandler.setLevel(Level.INFO);
rootLogger.setLevel(Level.INFO);
rootLogger.addHandler(consoleHandler);

Check warning on line 152 in simulator/src/main/java/com/hedera/block/simulator/BlockStreamSimulatorApp.java

View check run for this annotation

Codecov / codecov/patch

simulator/src/main/java/com/hedera/block/simulator/BlockStreamSimulatorApp.java#L150-L152

Added lines #L150 - L152 were not covered by tests

LOGGER.log(

Check warning on line 154 in simulator/src/main/java/com/hedera/block/simulator/BlockStreamSimulatorApp.java

View check run for this annotation

Codecov / codecov/patch

simulator/src/main/java/com/hedera/block/simulator/BlockStreamSimulatorApp.java#L154

Added line #L154 was not covered by tests
ERROR,
"Loading Logging Configuration failed, continuing with default. Error is: %s"
Expand Down

0 comments on commit 73af5b2

Please sign in to comment.