Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RunAction, logging] (#159) Restored System and Server logs in VRDT OUTPUT #160

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading