Skip to content

Commit 890b92d

Browse files
authored
Merge pull request #160 from vmware/feature/159-restore-vrdt-output-logs
[RunAction, logging] (#159) Restored System and Server logs in VRDT OUTPUT
2 parents b53c2c4 + c1098b0 commit 890b92d

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
name: codecov
8686

8787
- name: Upload artifact
88-
uses: actions/upload-artifact@v2
88+
uses: actions/upload-artifact@v4
8989
if: runner.os == 'ubuntu-latest'
9090
with:
9191
name: vrealize-developer-tools-${{steps.version_step.outputs.version_build}}.vsix

.github/workflows/draft-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
MINISIGN_PASSWORD: ${{ secrets.RELEASE_MINISIGN_PASS }}
7171

7272
- name: Upload artifacts
73-
uses: actions/upload-artifact@v2
73+
uses: actions/upload-artifact@v4
7474
with:
7575
name: vrealize-developer-tools-${{steps.version_step.outputs.version}}
7676
path: |

extension/src/client/command/RunAction.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,13 @@ class ActionRunner {
280280
}
281281

282282
this.logger.info(`Running workflow ${RUN_SCRIPT_WORKFLOW_ID} (vRO ${this.vroVersion})`)
283-
const supportsSysLog = semver.gt(this.vroVersion, "7.3.1")
284283
const params = [
285284
{
286285
name: "script",
287286
type: "string",
288287
value: {
289288
string: { value: fileContent }
290289
}
291-
},
292-
{
293-
name: "printInOutput",
294-
type: "boolean",
295-
value: {
296-
boolean: { value: !supportsSysLog }
297-
}
298290
}
299291
]
300292

@@ -416,11 +408,15 @@ abstract class FetchSysLogsStrategy extends FetchLogsStrategy {
416408
protected abstract getLogMessages(): Promise<LogMessage[]>
417409

418410
async printMessages(): Promise<void> {
411+
if (Logger.level === "off") {
412+
return
413+
}
419414
const timestamp = Date.now() - 10000 // 10sec earlier
420415
const logs = await this.getLogMessages()
421416
logs.forEach(logMessage => {
422417
const timestamp = moment(logMessage.timestamp).format("YYYY-MM-DD HH:mm:ss.SSS ZZ")
423-
const msg = `[${timestamp}] [${logMessage.severity}] ${logMessage.description}`
418+
const origin = !logMessage.origin ? "" : `[${logMessage.origin}] `
419+
const msg = `[${timestamp}] ${origin}[${logMessage.severity}] ${logMessage.description}`
424420
if (!this.printedMessages.has(msg)) {
425421
this.log(msg)
426422
this.printedMessages.add(msg)
@@ -455,7 +451,7 @@ class FetchLogsPre76 extends FetchSysLogsStrategy {
455451
return this.restClient.getWorkflowLogsPre76(
456452
RUN_SCRIPT_WORKFLOW_ID,
457453
this.executionToken,
458-
"debug",
454+
Logger.level,
459455
this.lastTimestamp
460456
)
461457
}
@@ -475,7 +471,7 @@ class FetchLogsPost76 extends FetchSysLogsStrategy {
475471
return this.restClient.getWorkflowLogsPost76(
476472
RUN_SCRIPT_WORKFLOW_ID,
477473
this.executionToken,
478-
"debug",
474+
Logger.level,
479475
this.lastTimestamp
480476
)
481477
}

packages/node/vrdt-common/src/logger.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export default class Logger {
3737
}
3838
}
3939

40+
/**
41+
* Configured log level.
42+
*/
43+
static get level(): LogLevel {
44+
return Logger.logLevel
45+
}
46+
4047
debug(message: string, data?: any): void {
4148
if (this.channel && Logger.logLevel === "debug") {
4249
this.channel.debug(this.format("DEBUG", message, data))

packages/node/vrdt-common/src/rest/VroRestClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,7 @@ export class VroRestClient {
321321
"GET",
322322
`workflows/${workflowId}/executions/${executionId}/syslogs` +
323323
`?conditions=severity=${severity}` +
324-
`&conditions=timestamp${encodeURIComponent(">")}${timestamp}` +
325-
"&conditions=type=system"
324+
`&conditions=timestamp${encodeURIComponent(">")}${timestamp}`
326325
)
327326

328327
const messages: LogMessage[] = []
@@ -335,7 +334,8 @@ export class VroRestClient {
335334
messages.push({
336335
timestamp: e["time-stamp"],
337336
severity: e.severity,
338-
description
337+
description,
338+
origin: e.origin
339339
})
340340
}
341341

packages/node/vrdt-common/src/rest/vro-model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface LogMessage {
1515
timestamp: string
1616
severity: string
1717
description: string
18+
origin?: string
1819
}
1920

2021
export interface Version {

0 commit comments

Comments
 (0)