From 8f4d1c7aea5fc94e09f22df491326bba0960fbdc Mon Sep 17 00:00:00 2001 From: Yury Shkoda Date: Tue, 12 Jan 2021 17:26:57 +0300 Subject: [PATCH] chore(*): improved session and job state logging --- src/SASViyaApiClient.ts | 6 +++--- src/SessionManager.ts | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/SASViyaApiClient.ts b/src/SASViyaApiClient.ts index 2ae0b6e..bac2d8e 100644 --- a/src/SASViyaApiClient.ts +++ b/src/SASViyaApiClient.ts @@ -1126,9 +1126,9 @@ export class SASViyaApiClient { postedJobState = jobState.trim() - if (this.debug && postedJobState !== printedState) { - console.log('Polling job status... \n') - console.log(`Current state: ${postedJobState}\n`) + if (this.debug && printedState !== postedJobState) { + console.log('Polling job status...') + console.log(`Current job state: ${postedJobState}`) printedState = postedJobState } diff --git a/src/SessionManager.ts b/src/SessionManager.ts index 1ff7cc2..1b63f17 100644 --- a/src/SessionManager.ts +++ b/src/SessionManager.ts @@ -23,6 +23,10 @@ export class SessionManager { private currentContext: Context | null = null private csrfToken: CsrfToken | null = null private _debug: boolean = false + private printedSessionState = { + printed: false, + state: '' + } public get debug() { return this._debug @@ -175,8 +179,10 @@ export class SessionManager { sessionState === '' ) { if (stateLink) { - if (this.debug) { - console.log('Polling session status... \n') + if (this.debug && !this.printedSessionState.printed) { + console.log('Polling session status...') + + this.printedSessionState.printed = true } const { result: state } = await this.requestSessionStatus( @@ -191,8 +197,11 @@ export class SessionManager { sessionState = state.trim() - if (this.debug) { - console.log(`Current state is '${sessionState}'\n`) + if (this.debug && this.printedSessionState.state !== sessionState) { + console.log(`Current session state is '${sessionState}'`) + + this.printedSessionState.state = sessionState + this.printedSessionState.printed = false } // There is an internal error present in SAS Viya 3.5