Skip to content

Commit

Permalink
fix(stark-core): enable correlation-id generation when `loggingFlushD…
Browse files Browse the repository at this point in the history
…isabled == true`

ISSUES CLOSED: #3620
  • Loading branch information
SuperITMan committed Jul 13, 2023
1 parent dd64ce1 commit 1522104
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions packages/stark-core/src/modules/logging/services/logging.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,28 @@ export class StarkLoggingServiceImpl implements StarkLoggingService {
this.consoleWarn = this.getConsole("warn");
this.consoleError = this.getConsole("error");

if (this.appConfig.loggingFlushDisabled) {
return;
}

this.backend = this.appConfig.getBackend("logging");
this.logPersistSize = <number>this.appConfig.loggingFlushPersistSize;
this.logUrl = `${this.backend.url}/${this.appConfig.loggingFlushResourceName}`;
this.generateNewCorrelationId();

if (!this.appConfig.loggingFlushDisabled) {
this.backend = this.appConfig.getBackend("logging");
this.logPersistSize = <number>this.appConfig.loggingFlushPersistSize;
this.logUrl = `${this.backend.url}/${this.appConfig.loggingFlushResourceName}`;

this.store.pipe(select(selectStarkLogging)).subscribe((starkLogging: StarkLogging) => {
this.starkLogging = starkLogging;
this.persistLogMessages();
});

this.store.pipe(select(selectStarkLogging)).subscribe((starkLogging: StarkLogging) => {
this.starkLogging = starkLogging;
this.persistLogMessages();
});

if (window) {
window.addEventListener("beforeunload", (_ev: BeforeUnloadEvent) => {
// Persist the remaining log entries that are still in the store, before leaving the application.
// We need to call the REST service synchronously,
// because the browser has to wait for the REST service to complete.
if (window) {
window.addEventListener("beforeunload", (_ev: BeforeUnloadEvent) => {
// Persist the remaining log entries that are still in the store, before leaving the application.
// We need to call the REST service synchronously,
// because the browser has to wait for the REST service to complete.

const data: string = JSON.stringify(Serialize(this.starkLogging, StarkLoggingImpl));
this.sendRequest(this.logUrl, data, false);
});
const data: string = JSON.stringify(Serialize(this.starkLogging, StarkLoggingImpl));
this.sendRequest(this.logUrl, data, false);
});
}
}

this.debug(starkLoggingServiceName + " loaded");
Expand Down

0 comments on commit 1522104

Please sign in to comment.