Skip to content

Commit f77aa2e

Browse files
committed
Roll back / update logging
1 parent ab10b74 commit f77aa2e

25 files changed

Lines changed: 222 additions & 288 deletions

.vscode/launch.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@
5858
"preLaunchTask": "openflownodered-tsc-watch",
5959
"program": "${workspaceRoot}/OpenFlowNodeRED/src/index.ts",
6060
"request": "launch",
61-
"runtimeArgs": [
62-
"--nolazy",
63-
"--trace-warnings"
64-
],
6561
"showAsyncStacks": true,
62+
// "runtimeArgs": [
63+
// "--nolazy",
64+
// "--trace-warnings"
65+
// ],
6666
"trace": true,
6767
"runtimeExecutable": null,
6868
"sourceMaps": true,

OpenFlow/src/DatabaseConnection.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,8 +1247,8 @@ export class DatabaseConnection {
12471247
} else {
12481248
newObj[key] = value;
12491249
}
1250-
} catch (err) {
1251-
me._logger.error("encryptentity " + err.message);
1250+
} catch (error) {
1251+
me._logger.error(error);
12521252
newObj[key] = value;
12531253
}
12541254
return newObj;
@@ -1277,8 +1277,8 @@ export class DatabaseConnection {
12771277
} else {
12781278
newObj[key] = value;
12791279
}
1280-
} catch (err) {
1281-
me._logger.error("decryptentity " + err.message);
1280+
} catch (error) {
1281+
me._logger.error(error);
12821282
newObj[key] = value;
12831283
}
12841284
return newObj;

OpenFlow/src/Logger.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,27 @@ export class Logger {
2222
colorize: true
2323
},
2424
};
25-
const enumerateErrorFormat = winston.format(info => {
26-
if ((info.message as any) instanceof Error) {
27-
const e = (info.message as any) as Error;
28-
info.message = Object.assign({
29-
message: e.message,
30-
stack: e.stack
31-
}, info.message);
25+
const myFormat = winston.format.printf(info => {
26+
if (info instanceof Error || info.stack) {
27+
return `${info.timestamp} [${info.level}] ${info.message} \n ${info.stack}`;
3228
}
33-
34-
if (info instanceof Error) {
35-
return Object.assign({
36-
message: info.message,
37-
stack: info.stack
38-
}, info);
39-
}
40-
41-
return info;
29+
return `${info.timestamp} [${info.level}] ${info.message}`;
4230
});
31+
options.console.format = winston.format.combine(
32+
winston.format.errors({ stack: true }),
33+
winston.format.timestamp({ format: 'HH:mm:ss' }),
34+
winston.format.colorize(),
35+
winston.format.json(),
36+
myFormat
37+
);
4338
const logger: winston.Logger = winston.createLogger({
4439
level: "debug",
4540
//format: winston.format.json(),
4641
format: winston.format.combine(
47-
enumerateErrorFormat(),
42+
winston.format.errors({ stack: true }),
4843
winston.format.timestamp({ format: 'HH:mm:ss' }),
49-
// winston.format.json()
50-
winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}` + (info.splat !== undefined ? `${info.splat}` : " "))
44+
winston.format.json(),
45+
myFormat
5146
),
5247
transports: [
5348
new winston.transports.File(options.file),

0 commit comments

Comments
 (0)