Skip to content

Commit

Permalink
Merge pull request #160 from vmware/feature/159-restore-vrdt-output-logs
Browse files Browse the repository at this point in the history
[RunAction, logging] (#159) Restored System and Server logs in VRDT OUTPUT
  • Loading branch information
bcpmihail authored Oct 11, 2024
2 parents b53c2c4 + c1098b0 commit 890b92d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
name: codecov

- name: Upload artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: runner.os == 'ubuntu-latest'
with:
name: vrealize-developer-tools-${{steps.version_step.outputs.version_build}}.vsix
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
MINISIGN_PASSWORD: ${{ secrets.RELEASE_MINISIGN_PASS }}

- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: vrealize-developer-tools-${{steps.version_step.outputs.version}}
path: |
Expand Down
18 changes: 7 additions & 11 deletions extension/src/client/command/RunAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,13 @@ class ActionRunner {
}

this.logger.info(`Running workflow ${RUN_SCRIPT_WORKFLOW_ID} (vRO ${this.vroVersion})`)
const supportsSysLog = semver.gt(this.vroVersion, "7.3.1")
const params = [
{
name: "script",
type: "string",
value: {
string: { value: fileContent }
}
},
{
name: "printInOutput",
type: "boolean",
value: {
boolean: { value: !supportsSysLog }
}
}
]

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

async printMessages(): Promise<void> {
if (Logger.level === "off") {
return
}
const timestamp = Date.now() - 10000 // 10sec earlier
const logs = await this.getLogMessages()
logs.forEach(logMessage => {
const timestamp = moment(logMessage.timestamp).format("YYYY-MM-DD HH:mm:ss.SSS ZZ")
const msg = `[${timestamp}] [${logMessage.severity}] ${logMessage.description}`
const origin = !logMessage.origin ? "" : `[${logMessage.origin}] `
const msg = `[${timestamp}] ${origin}[${logMessage.severity}] ${logMessage.description}`
if (!this.printedMessages.has(msg)) {
this.log(msg)
this.printedMessages.add(msg)
Expand Down Expand Up @@ -455,7 +451,7 @@ class FetchLogsPre76 extends FetchSysLogsStrategy {
return this.restClient.getWorkflowLogsPre76(
RUN_SCRIPT_WORKFLOW_ID,
this.executionToken,
"debug",
Logger.level,
this.lastTimestamp
)
}
Expand All @@ -475,7 +471,7 @@ class FetchLogsPost76 extends FetchSysLogsStrategy {
return this.restClient.getWorkflowLogsPost76(
RUN_SCRIPT_WORKFLOW_ID,
this.executionToken,
"debug",
Logger.level,
this.lastTimestamp
)
}
Expand Down
7 changes: 7 additions & 0 deletions packages/node/vrdt-common/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export default class Logger {
}
}

/**
* Configured log level.
*/
static get level(): LogLevel {
return Logger.logLevel
}

debug(message: string, data?: any): void {
if (this.channel && Logger.logLevel === "debug") {
this.channel.debug(this.format("DEBUG", message, data))
Expand Down
6 changes: 3 additions & 3 deletions packages/node/vrdt-common/src/rest/VroRestClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,7 @@ export class VroRestClient {
"GET",
`workflows/${workflowId}/executions/${executionId}/syslogs` +
`?conditions=severity=${severity}` +
`&conditions=timestamp${encodeURIComponent(">")}${timestamp}` +
"&conditions=type=system"
`&conditions=timestamp${encodeURIComponent(">")}${timestamp}`
)

const messages: LogMessage[] = []
Expand All @@ -335,7 +334,8 @@ export class VroRestClient {
messages.push({
timestamp: e["time-stamp"],
severity: e.severity,
description
description,
origin: e.origin
})
}

Expand Down
1 change: 1 addition & 0 deletions packages/node/vrdt-common/src/rest/vro-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface LogMessage {
timestamp: string
severity: string
description: string
origin?: string
}

export interface Version {
Expand Down

0 comments on commit 890b92d

Please sign in to comment.