Skip to content

Commit ec0f7d8

Browse files
committed
align logging of cli and ide
1 parent 894c6c9 commit ec0f7d8

11 files changed

Lines changed: 43 additions & 24 deletions

File tree

packages/flowtest-cli/bin/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const argv = yargs(hideBin(process.argv))
5151
})
5252
.option('scan', {
5353
alias: 's',
54-
describe: 'generate and upload build scan',
54+
describe: 'generate and upload flow scan',
5555
});
5656
},
5757
async (argv) => {
@@ -79,7 +79,7 @@ const argv = yargs(hideBin(process.argv))
7979
logger,
8080
);
8181
console.log(chalk.yellow('Running Flow \n'));
82-
if (flowData.nodes.find((n) => n.type === 'complexNode')) {
82+
if (flowData.nodes.find((n) => n.type === 'flowNode')) {
8383
console.log(
8484
chalk.blue(
8585
'[Note] This flow contains nested flows so run it from parent directory of collection. Ignore if already doing that. \n',

packages/flowtest-cli/graph/Graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class Graph {
133133

134134
if (node.type === 'authNode') {
135135
console.log('Authentication Node');
136-
const aNode = new authNode(node.data, this.envVariables);
136+
const aNode = new authNode(node.data, this.envVariables, this.logger);
137137
this.auth = node.data.type ? aNode.evaluate() : undefined;
138138
result = {
139139
status: 'Success',

packages/flowtest-cli/graph/compute/authnode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const { computeVariables } = require('./utils');
22
const Node = require('./node');
33
const chalk = require('chalk');
4+
const { LogLevel } = require('../GraphLogger');
45

56
class authNode extends Node {
67
constructor(auth, envVariables, logger) {

packages/flowtest-cli/graph/compute/requestnode.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ class requestNode extends Node {
5252
console.log(chalk.red(` ✕ `) + chalk.dim(`Request failed: ${JSON.stringify(res.error)}`));
5353
this.logger.add(LogLevel.ERROR, 'HTTP request failed', {
5454
type: 'requestNode',
55-
data: { request: { type: options.method, url: options.url }, response: res.error, preReqVars: evalVariables },
55+
data: {
56+
request: { type: options.method, url: options.url, data: options.data },
57+
response: res.error,
58+
preReqVars: evalVariables,
59+
},
5660
});
5761
return {
5862
status: 'Failed',
@@ -78,7 +82,11 @@ class requestNode extends Node {
7882
}
7983
this.logger.add(LogLevel.INFO, 'HTTP request success', {
8084
type: 'requestNode',
81-
data: { request: { type: options.method, url: options.url }, response: res, preReqVars: evalVariables },
85+
data: {
86+
request: { type: options.method, url: options.url, data: options.data },
87+
response: res,
88+
preReqVars: evalVariables,
89+
},
8290
});
8391
return {
8492
status: 'Success',

packages/flowtest-electron/src/ipc/collection.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ const registerRendererEventHandlers = (mainWindow, watcher) => {
318318
} else {
319319
return {
320320
error: {
321-
message: `An error occurred while running the request : ${error?.message}`,
321+
status: '',
322+
statusText: '',
323+
data: `An error occurred while running the request : ${error?.message}`,
322324
},
323325
};
324326
}

src/components/molecules/flow/graph/Graph.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ class Graph {
6969
console.debug('Executing node: ', node);
7070

7171
if (node.type === 'outputNode') {
72-
//this.logs.push(`Output: ${JSON.stringify(prevNodeOutputData)}`);
73-
this.logger.add(LogLevel.INFO, '', { type: 'outputNode', data: prevNodeOutputData });
72+
this.logger.add(LogLevel.INFO, '', { type: 'outputNode', data: { output: prevNodeOutputData } });
7473
if (this.caller === 'main') {
7574
useCanvasStore.getState().setOutputNode(node.id, prevNodeOutputData);
7675
}
@@ -109,15 +108,15 @@ class Graph {
109108
return new Promise((resolve) => setTimeout(resolve, Math.min(ms, this.timeout)));
110109
};
111110
await wait(delay);
112-
this.logger.add(LogLevel.INFO, '', { type: 'delayNode', data: delay });
111+
this.logger.add(LogLevel.INFO, '', { type: 'delayNode', data: { delay } });
113112
result = {
114113
status: 'Success',
115114
data: prevNodeOutputData,
116115
};
117116
}
118117

119118
if (node.type === 'authNode') {
120-
const aNode = new authNode(node.data, this.envVariables);
119+
const aNode = new authNode(node.data, this.envVariables, this.logger);
121120
this.auth = node.data.type ? aNode.evaluate() : undefined;
122121
result = {
123122
status: 'Success',
@@ -181,7 +180,7 @@ class Graph {
181180
}
182181

183182
if (this.#checkTimeout()) {
184-
throw `Timeout of ${this.timeout} ms exceeded, stopping graph run`;
183+
throw Error(`Timeout of ${this.timeout} ms exceeded, stopping graph run`);
185184
}
186185
} catch (err) {
187186
this.logger.add(LogLevel.ERROR, `Flow failed due to ${err}`, node);

src/components/molecules/flow/graph/compute/assertnode.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class assertNode extends Node {
3232

3333
const operator = this.operator;
3434
if (operator == undefined) {
35-
throw 'Operator undefined';
35+
throw Error('Operator undefined');
3636
}
3737

3838
let result;
@@ -50,7 +50,7 @@ class assertNode extends Node {
5050
result = var1 < var2;
5151
break;
5252
default:
53-
throw 'Unsupported operator';
53+
throw Error('Unsupported operator');
5454
}
5555
this.logger.add(LogLevel.INFO, '', { type: 'assertNode', data: { var1, var2, operator, result } });
5656

src/components/molecules/flow/graph/compute/authnode.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import { computeVariables } from './utils';
22
import Node from './node';
3+
import { LogLevel } from '../GraphLogger';
34

45
class authNode extends Node {
5-
constructor(auth, envVariables) {
6+
constructor(auth, envVariables, logger) {
67
super('authNode');
78
(this.auth = auth), (this.envVariables = envVariables);
9+
this.logger = logger;
810
}
911

1012
evaluate() {
1113
console.log('Evaluating an auth node');
1214
if (this.auth.type === 'basic-auth') {
15+
this.logger.add(LogLevel.INFO, '', { type: 'authNode', data: { authType: 'Basic Authentication' } });
1316
this.auth.username = computeVariables(this.auth.username, this.envVariables);
1417
this.auth.password = computeVariables(this.auth.password, this.envVariables);
1518

1619
return this.auth;
1720
} else if (this.auth.type === 'no-auth') {
21+
this.logger.add(LogLevel.INFO, '', { type: 'authNode', data: { authType: 'No Authentication' } });
1822
return this.auth;
1923
} else {
2024
throw Error(`auth type: ${this.auth.type} is not valid`);

src/components/molecules/flow/graph/compute/nestedflownode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Node from './node';
33

44
class nestedFlowNode extends Node {
55
constructor(nodes, edges, startTime, initialEnvVars, logger, caller) {
6-
super('complexNode');
6+
super('flowNode');
77
this.internalGraph = new Graph1(nodes, edges, startTime, initialEnvVars, logger, caller);
88
}
99

src/components/molecules/flow/graph/compute/requestnode.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ class requestNode extends Node {
3535
if (res.error) {
3636
this.logger.add(LogLevel.ERROR, 'HTTP request failed', {
3737
type: 'requestNode',
38-
data: { request: { type: options.method, url: options.url }, response: res.error, preReqVars: evalVariables },
38+
data: {
39+
request: { type: options.method, url: options.url, data: options.data },
40+
response: res.error,
41+
preReqVars: evalVariables,
42+
},
3943
});
4044
return {
4145
status: 'Failed',
@@ -60,7 +64,11 @@ class requestNode extends Node {
6064
}
6165
this.logger.add(LogLevel.INFO, 'HTTP request success', {
6266
type: 'requestNode',
63-
data: { request: { type: options.method, url: options.url }, response: res, preReqVars: evalVariables },
67+
data: {
68+
request: { type: options.method, url: options.url, data: options.data },
69+
response: res,
70+
preReqVars: evalVariables,
71+
},
6472
});
6573
return {
6674
status: 'Success',

0 commit comments

Comments
 (0)