Skip to content

Commit

Permalink
Issue #106: Unmute new yet unregistered loggers if connection logs ar…
Browse files Browse the repository at this point in the history
…e enabled for the connection.

This allows lazy initialisation of connection loggers without losing log entries if connection logs were enabled for a connection before the connection logger was registered.

Signed-off-by: Juergen Fickel <juergen.fickel@bosch.io>
  • Loading branch information
Juergen Fickel committed Dec 17, 2021
1 parent 4a94e04 commit fb9f818
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -506,22 +506,35 @@ public ConnectionLogger getLogger(
}
}

private ConnectionLogger newLogger(final ConnectionId connectionId, final LogCategory logCategory,
private ConnectionLogger newLogger(final ConnectionId connectionId,
final LogCategory logCategory,
final LogType logType,
@Nullable final String address) {

final ConnectionLogger evictingLogger = ConnectionLoggerFactory.newEvictingLogger(
successCapacity, failureCapacity, logCategory, logType, address);
final MuteableConnectionLogger muteableLogger = ConnectionLoggerFactory.newMuteableLogger(
connectionId, evictingLogger);
final ConnectionLogger result;
final var evictingLogger = ConnectionLoggerFactory.newEvictingLogger(successCapacity,
failureCapacity,
logCategory,
logType,
address);
final var muteableLogger = ConnectionLoggerFactory.newMuteableLogger(connectionId, evictingLogger);
if (isActiveForConnection(connectionId)) {
muteableLogger.unmute();
} else {
muteableLogger.mute();
}

if (null != fluentPublishingConnectionLoggerContext) {
final FluentPublishingConnectionLogger publishingLogger = ConnectionLoggerFactory.newPublishingLogger(
connectionId, logCategory, logType, address, fluentPublishingConnectionLoggerContext);
return new CompoundConnectionLogger(List.of(muteableLogger, publishingLogger));
final var publishingLogger = ConnectionLoggerFactory.newPublishingLogger(connectionId,
logCategory,
logType,
address,
fluentPublishingConnectionLoggerContext);
result = new CompoundConnectionLogger(List.of(muteableLogger, publishingLogger));
} else {
return muteableLogger;
result = muteableLogger;
}
return result;
}

@Override
Expand Down

0 comments on commit fb9f818

Please sign in to comment.