nodefony 7.0.0-beta.2 → 7.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +534 -8028
- package/README.md +33 -30
- package/autoloader.es6 +46 -48
- package/builder.es6 +66 -76
- package/cli/builder/bundles/bundle.js +57 -63
- package/cli/builder/bundles/controller.js +34 -38
- package/cli/builder/bundles/users-bundle/Command/fixtureTask.js +11 -12
- package/cli/builder/bundles/users-bundle/Command/usersCommand.js +23 -24
- package/cli/builder/bundles/users-bundle/Entity/mongoose/userEntity.js +25 -30
- package/cli/builder/bundles/users-bundle/Entity/sequelize/userEntity.js +42 -31
- package/cli/builder/bundles/users-bundle/Fixtures/users.js +24 -26
- package/cli/builder/bundles/users-bundle/Fixtures/usersFixtures.js +28 -29
- package/cli/builder/bundles/users-bundle/Resources/config/config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/routing.js +2 -2
- package/cli/builder/bundles/users-bundle/Resources/config/security.js +9 -8
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.dev.config.js +3 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack/webpack.prod.config.js +4 -3
- package/cli/builder/bundles/users-bundle/Resources/config/webpack.config.js +74 -75
- package/cli/builder/bundles/users-bundle/Resources/scss/awesome/font-awesome.config.js +9 -9
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/login.js +13 -13
- package/cli/builder/bundles/users-bundle/Resources/swagger/openapi/users.js +14 -14
- package/cli/builder/bundles/users-bundle/controller/api/graphql/graphqlController.js +13 -15
- package/cli/builder/bundles/users-bundle/controller/api/graphql/userResolver.js +29 -29
- package/cli/builder/bundles/users-bundle/controller/api/graphql/usertype.js +2 -2
- package/cli/builder/bundles/users-bundle/controller/api/openapi/loginApiController.js +34 -36
- package/cli/builder/bundles/users-bundle/controller/api/openapi/restUserController.js +32 -36
- package/cli/builder/bundles/users-bundle/controller/loginController.js +30 -34
- package/cli/builder/bundles/users-bundle/controller/usersController.js +54 -60
- package/cli/builder/bundles/users-bundle/package.json +27 -25
- package/cli/builder/bundles/users-bundle/pnpm-lock.yaml +4262 -0
- package/cli/builder/bundles/users-bundle/readme.md +7 -7
- package/cli/builder/bundles/users-bundle/services/usersService.js +97 -102
- package/cli/builder/bundles/users-bundle/src/providers/mongoose/userProvider.js +6 -8
- package/cli/builder/bundles/users-bundle/src/providers/sequelize/userProvider.js +9 -10
- package/cli/builder/bundles/users-bundle/tests/loginTest.js +119 -70
- package/cli/builder/bundles/users-bundle/usersBundle.js +2 -3
- package/cli/builder/microService/microService.js +139 -141
- package/cli/builder/microService/skeletons/package.json +23 -22
- package/cli/builder/project/project.js +228 -181
- package/cli/builder/project/skeletons/README.md +33 -30
- package/cli/builder/project/skeletons/bin/dev-deploy.sh +5 -0
- package/cli/builder/project/skeletons/bin/prod-deploy.sh +3 -0
- package/cli/builder/project/skeletons/config/config.js.skeleton +1 -0
- package/cli/builder/project/skeletons/config/pm2.config.js.skeleton +41 -17
- package/cli/builder/project/skeletons/eslintignore.skeleton +15 -0
- package/cli/builder/project/skeletons/eslintrc.js.skeleton +97 -0
- package/cli/builder/project/skeletons/gitignore.skeleton +1 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.37.entity-user.js +137 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.38.entity-session.js +97 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.39.entity-requests.js +115 -0
- package/cli/builder/project/skeletons/migrations/2022.12.25T17.37.40.entity-jwts.js +97 -0
- package/cli/builder/project/skeletons/migrations/migrations.skeleton.js +0 -2
- package/cli/builder/project/skeletons/package.json.twig +70 -0
- package/cli/builder/react/reactBuilder.js +59 -65
- package/cli/builder/sandbox/sandBoxBuilder.js +132 -134
- package/cli/builder/skeletons/app/appKernel.js +120 -2
- package/cli/builder/skeletons/config/config.js +1 -1
- package/cli/builder/skeletons/config/nodefony/framework-bundle.js +2 -1
- package/cli/builder/skeletons/config/nodefony/http-bundle.js +1 -0
- package/cli/builder/skeletons/config/nodefony/mongoose-bundle.js +38 -12
- package/cli/builder/skeletons/config/nodefony/monitoring-bundle.js +21 -2
- package/cli/builder/skeletons/config/nodefony/sequelize-bundle.js +122 -13
- package/cli/builder/skeletons/package.json.twig +57 -0
- package/cli/builder/skeletons/unittest/testFile.js +44 -45
- package/cli/builder/vue/skeletons/vue.config.js +84 -10
- package/cli/builder/vue/vueBuilder.js +116 -114
- package/cli/generate/generate.es6 +38 -39
- package/cli/install/install.js +45 -58
- package/cli/sequelize/sequelize.js +50 -39
- package/cli/start.js +353 -347
- package/cli/tools/pm2.es6 +55 -57
- package/cli/tools/tools.es6 +36 -37
- package/cli.es6 +280 -228
- package/container.es6 +51 -59
- package/error.es6 +25 -27
- package/fileClass.es6 +53 -55
- package/finder/file.es6 +5 -4
- package/finder/fileResult.es6 +23 -22
- package/finder/finder2.es6 +46 -54
- package/finder.es6 +88 -97
- package/kernel/annotations/annotations.es6 +44 -46
- package/kernel/api/api.es6 +6 -8
- package/kernel/api/graphqlApi.es6 +21 -21
- package/kernel/api/jsonApi.es6 +40 -45
- package/kernel/api/openApi.es6 +9 -11
- package/kernel/api/schemas/openApiSchema.js +61 -32
- package/kernel/babylon.es6 +31 -38
- package/kernel/bundle.es6 +252 -220
- package/kernel/cliKernel.es6 +157 -170
- package/kernel/command.es6 +17 -20
- package/kernel/commands/nodefonyCommand.es6 +111 -58
- package/kernel/commands/tasks/bundlesTask.es6 +14 -19
- package/kernel/controllers/controller.es6 +167 -180
- package/kernel/fixture.es6 +4 -7
- package/kernel/injections/injections.es6 +97 -103
- package/kernel/kernel.es6 +476 -384
- package/kernel/kernelWatcher.es6 +64 -54
- package/kernel/orm/entity.es6 +10 -12
- package/kernel/orm/orm.es6 +68 -48
- package/kernel/reader.es6 +45 -47
- package/kernel/security/encoder.es6 +8 -6
- package/kernel/security/factories/factory.es6 +34 -37
- package/kernel/security/factories/passeportFactory.es6 +13 -14
- package/kernel/security/provider.es6 +11 -13
- package/kernel/security/providers/chainProvider.es6 +13 -28
- package/kernel/security/providers/memoryProvider.es6 +7 -11
- package/kernel/security/providers/providerManager.es6 +11 -14
- package/kernel/security/providers/userEntityProvider.es6 +7 -8
- package/kernel/security/role.es6 +3 -3
- package/kernel/security/secureArea.es6 +143 -149
- package/kernel/security/tokens/token.es6 +30 -32
- package/kernel/security/user.es6 +19 -19
- package/kernel/serviceRealTime.es6 +5 -7
- package/kernel/services/connectionsService.es6 +20 -22
- package/kernel/services/cron/cronService.es6 +14 -16
- package/kernel/task.es6 +20 -26
- package/kernel/templates.es6 +4 -5
- package/kernel/templating/twig.es6 +56 -47
- package/kernel/tests/cliTest.js +7 -11
- package/kernel/tests/containerTest.js +25 -37
- package/kernel/tests/kernelTest.js +9 -16
- package/nodefony.es6 +279 -256
- package/notificationsCenter.es6 +28 -20
- package/package.json +40 -40
- package/protocol.es6 +19 -21
- package/protocols/bayeux.es6 +35 -38
- package/protocols/jsonRpc/jsonrpc.es6 +12 -14
- package/result.es6 +11 -12
- package/service.es6 +62 -62
- package/syslog/pdu.es6 +99 -91
- package/syslog/syslog.es6 +101 -102
- package/watcher.es6 +21 -20
- package/cli/builder/project/skeletons/jshintignore.skeleton +0 -1
- package/cli/builder/project/skeletons/jshintrc.skeleton +0 -60
- package/cli/builder/project/skeletons/package.json.skeleton +0 -52
- package/cli/builder/skeletons/package.json +0 -61
package/syslog/syslog.es6
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const red = clc.red.bold;
|
|
2
2
|
const cyan = clc.cyan.bold;
|
|
3
3
|
const blue = clc.blueBright.bold;
|
|
4
|
-
const green = clc
|
|
4
|
+
const {green} = clc;
|
|
5
5
|
const yellow = clc.yellow.bold;
|
|
6
6
|
|
|
7
7
|
const formatDebug = function (debug) {
|
|
@@ -34,7 +34,7 @@ const formatDebug = function (debug) {
|
|
|
34
34
|
default:
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
};
|
|
38
38
|
|
|
39
39
|
const conditionOptions = function (environment, debug = undefined) {
|
|
40
40
|
debug = formatDebug(debug);
|
|
@@ -43,21 +43,21 @@ const conditionOptions = function (environment, debug = undefined) {
|
|
|
43
43
|
obj = {
|
|
44
44
|
severity: {
|
|
45
45
|
operator: "<=",
|
|
46
|
-
data:
|
|
46
|
+
data: debug === false ? 6 : 7
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
} else {
|
|
50
50
|
obj = {
|
|
51
51
|
severity: {
|
|
52
52
|
operator: "<=",
|
|
53
|
-
data:
|
|
53
|
+
data: debug ? 7 : 6
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
if (typeof debug === "object") {
|
|
58
58
|
obj.msgid = {
|
|
59
59
|
data: debug
|
|
60
|
-
}
|
|
60
|
+
};
|
|
61
61
|
}
|
|
62
62
|
return obj;
|
|
63
63
|
};
|
|
@@ -89,33 +89,33 @@ const defaultSettings = {
|
|
|
89
89
|
const sysLogSeverity = nodefony.PDU.sysLogSeverity();
|
|
90
90
|
|
|
91
91
|
const operators = {
|
|
92
|
-
"<"
|
|
92
|
+
"<" (ele1, ele2) {
|
|
93
93
|
return ele1 < ele2;
|
|
94
94
|
},
|
|
95
|
-
">"
|
|
95
|
+
">" (ele1, ele2) {
|
|
96
96
|
return ele1 > ele2;
|
|
97
97
|
},
|
|
98
|
-
"<="
|
|
98
|
+
"<=" (ele1, ele2) {
|
|
99
99
|
return ele1 <= ele2;
|
|
100
100
|
},
|
|
101
|
-
">="
|
|
101
|
+
">=" (ele1, ele2) {
|
|
102
102
|
return ele1 >= ele2;
|
|
103
103
|
},
|
|
104
|
-
"=="
|
|
104
|
+
"==" (ele1, ele2) {
|
|
105
105
|
return ele1 === ele2;
|
|
106
106
|
},
|
|
107
|
-
"!="
|
|
107
|
+
"!=" (ele1, ele2) {
|
|
108
108
|
return ele1 !== ele2;
|
|
109
109
|
},
|
|
110
|
-
"RegExp"
|
|
111
|
-
return
|
|
110
|
+
"RegExp" (ele1, ele2) {
|
|
111
|
+
return ele2.test(ele1);
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
const conditionsObj = {
|
|
116
116
|
severity: (pdu, condition) => {
|
|
117
|
-
for (
|
|
118
|
-
|
|
117
|
+
for (const sev in condition.data) {
|
|
118
|
+
const res = operators[condition.operator](pdu.severity, condition.data[sev]);
|
|
119
119
|
if (res) {
|
|
120
120
|
return true;
|
|
121
121
|
}
|
|
@@ -123,23 +123,21 @@ const conditionsObj = {
|
|
|
123
123
|
return false;
|
|
124
124
|
},
|
|
125
125
|
msgid: (pdu, condition) => {
|
|
126
|
-
for (
|
|
127
|
-
|
|
126
|
+
for (const sev in condition.data) {
|
|
127
|
+
const res = operators[condition.operator](pdu.msgid, sev);
|
|
128
128
|
if (res) {
|
|
129
129
|
return true;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
return false;
|
|
133
133
|
},
|
|
134
|
-
date: (pdu, condition) =>
|
|
135
|
-
return operators[condition.operator](pdu.timeStamp, condition.data);
|
|
136
|
-
}
|
|
134
|
+
date: (pdu, condition) => operators[condition.operator](pdu.timeStamp, condition.data)
|
|
137
135
|
};
|
|
138
136
|
|
|
139
137
|
const logicCondition = {
|
|
140
138
|
"&&": (myConditions, pdu) => {
|
|
141
139
|
let res = null;
|
|
142
|
-
for (
|
|
140
|
+
for (const ele in myConditions) {
|
|
143
141
|
res = conditionsObj[ele](pdu, myConditions[ele]);
|
|
144
142
|
if (!res) {
|
|
145
143
|
break;
|
|
@@ -149,7 +147,7 @@ const logicCondition = {
|
|
|
149
147
|
},
|
|
150
148
|
"||": (myConditions, pdu) => {
|
|
151
149
|
let res = null;
|
|
152
|
-
for (
|
|
150
|
+
for (const ele in myConditions) {
|
|
153
151
|
res = conditionsObj[ele](pdu, myConditions[ele]);
|
|
154
152
|
if (res) {
|
|
155
153
|
break;
|
|
@@ -172,8 +170,8 @@ const checkFormatSeverity = (ele) => {
|
|
|
172
170
|
res = [ele];
|
|
173
171
|
break;
|
|
174
172
|
default:
|
|
175
|
-
console.trace(ele)
|
|
176
|
-
|
|
173
|
+
console.trace(ele);
|
|
174
|
+
const error = `checkFormatSeverity bad format type : ${nodefony.typeOf(ele)}`;
|
|
177
175
|
throw new Error(error);
|
|
178
176
|
}
|
|
179
177
|
return res;
|
|
@@ -189,7 +187,7 @@ const checkFormatDate = function (ele) {
|
|
|
189
187
|
res = new Date(ele);
|
|
190
188
|
break;
|
|
191
189
|
default:
|
|
192
|
-
throw new Error(
|
|
190
|
+
throw new Error(`checkFormatDate bad format ${nodefony.typeOf(ele)} : ${ele}`);
|
|
193
191
|
}
|
|
194
192
|
return res;
|
|
195
193
|
};
|
|
@@ -210,13 +208,13 @@ const checkFormatMsgId = function (ele) {
|
|
|
210
208
|
res = ele;
|
|
211
209
|
break;
|
|
212
210
|
default:
|
|
213
|
-
throw new Error(
|
|
211
|
+
throw new Error(`checkFormatMsgId bad format ${nodefony.typeOf(ele)} : ${ele}`);
|
|
214
212
|
}
|
|
215
213
|
return res;
|
|
216
214
|
};
|
|
217
215
|
|
|
218
216
|
const severityToString = function (severity) {
|
|
219
|
-
|
|
217
|
+
const myint = parseInt(severity, 10);
|
|
220
218
|
let ele = null;
|
|
221
219
|
if (!isNaN(myint)) {
|
|
222
220
|
ele = sysLogSeverity[myint];
|
|
@@ -240,7 +238,7 @@ const wrapperCondition = function (conditions, callback) {
|
|
|
240
238
|
myFuncCondition = logicCondition[this.settings.checkConditions];
|
|
241
239
|
}
|
|
242
240
|
Conditions = sanitizeConditions(conditions);
|
|
243
|
-
//console.log("Sanitize : ", conditions)
|
|
241
|
+
// console.log("Sanitize : ", conditions)
|
|
244
242
|
switch (nodefony.typeOf(callback)) {
|
|
245
243
|
case "function":
|
|
246
244
|
return (pdu) => {
|
|
@@ -250,7 +248,7 @@ const wrapperCondition = function (conditions, callback) {
|
|
|
250
248
|
}
|
|
251
249
|
};
|
|
252
250
|
case "array":
|
|
253
|
-
|
|
251
|
+
const tab = [];
|
|
254
252
|
for (let i = 0; i < callback.length; i++) {
|
|
255
253
|
const res = myFuncCondition(Conditions, callback[i]);
|
|
256
254
|
if (res) {
|
|
@@ -271,15 +269,15 @@ const sanitizeConditions = function (settingsCondition) {
|
|
|
271
269
|
if (nodefony.typeOf(settingsCondition) !== "object") {
|
|
272
270
|
return false;
|
|
273
271
|
}
|
|
274
|
-
for (
|
|
272
|
+
for (const ele in settingsCondition) {
|
|
275
273
|
if (!(ele in conditionsObj)) {
|
|
276
274
|
return false;
|
|
277
275
|
}
|
|
278
|
-
|
|
279
|
-
//console.log("condi ready : ",condi)
|
|
276
|
+
const condi = settingsCondition[ele];
|
|
277
|
+
// console.log("condi ready : ",condi)
|
|
280
278
|
|
|
281
279
|
if (condi.operator && !(condi.operator in operators)) {
|
|
282
|
-
throw new Error(
|
|
280
|
+
throw new Error(`Contitions bad operator : ${condi.operator}`);
|
|
283
281
|
}
|
|
284
282
|
if (condi.data) {
|
|
285
283
|
switch (ele) {
|
|
@@ -288,11 +286,11 @@ const sanitizeConditions = function (settingsCondition) {
|
|
|
288
286
|
condi.operator = "==";
|
|
289
287
|
}
|
|
290
288
|
res = checkFormatSeverity(condi.data);
|
|
291
|
-
//console.log(`checkFormatSeverity : `, condi.data, "==>" , res)
|
|
289
|
+
// console.log(`checkFormatSeverity : `, condi.data, "==>" , res)
|
|
292
290
|
if (res !== false) {
|
|
293
291
|
condi.data = {};
|
|
294
292
|
for (let i = 0; i < res.length; i++) {
|
|
295
|
-
|
|
293
|
+
const mySeverity = severityToString(res[i]);
|
|
296
294
|
if (mySeverity) {
|
|
297
295
|
condi.data[mySeverity] = sysLogSeverity[mySeverity];
|
|
298
296
|
} else {
|
|
@@ -309,7 +307,7 @@ const sanitizeConditions = function (settingsCondition) {
|
|
|
309
307
|
}
|
|
310
308
|
res = checkFormatMsgId(condi.data);
|
|
311
309
|
if (res !== false) {
|
|
312
|
-
|
|
310
|
+
const format = nodefony.typeOf(res);
|
|
313
311
|
if (format === "array") {
|
|
314
312
|
condi.data = {};
|
|
315
313
|
for (let i = 0; i < res.length; i++) {
|
|
@@ -338,7 +336,7 @@ const sanitizeConditions = function (settingsCondition) {
|
|
|
338
336
|
}
|
|
339
337
|
}
|
|
340
338
|
return settingsCondition;
|
|
341
|
-
//console.log(settingsCondition);
|
|
339
|
+
// console.log(settingsCondition);
|
|
342
340
|
};
|
|
343
341
|
|
|
344
342
|
const createPDU = function (payload, severity, moduleName, msgid, msg) {
|
|
@@ -348,10 +346,7 @@ const createPDU = function (payload, severity, moduleName, msgid, msg) {
|
|
|
348
346
|
} else {
|
|
349
347
|
myseverity = severity;
|
|
350
348
|
}
|
|
351
|
-
return new nodefony.PDU(payload, myseverity,
|
|
352
|
-
moduleName,
|
|
353
|
-
msgid,
|
|
354
|
-
msg);
|
|
349
|
+
return new nodefony.PDU(payload, myseverity, moduleName, msgid, msg);
|
|
355
350
|
};
|
|
356
351
|
|
|
357
352
|
/**
|
|
@@ -364,10 +359,9 @@ const createPDU = function (payload, severity, moduleName, msgid, msg) {
|
|
|
364
359
|
* @return syslog
|
|
365
360
|
*/
|
|
366
361
|
class Syslog extends nodefony.Events {
|
|
367
|
-
|
|
368
|
-
constructor(settings) {
|
|
369
|
-
|
|
362
|
+
constructor (settings) {
|
|
370
363
|
super(settings);
|
|
364
|
+
|
|
371
365
|
/**
|
|
372
366
|
* extended settings
|
|
373
367
|
* @property settings
|
|
@@ -375,24 +369,28 @@ class Syslog extends nodefony.Events {
|
|
|
375
369
|
* @see defaultSettings
|
|
376
370
|
*/
|
|
377
371
|
this.settings = nodefony.extend({}, defaultSettings, settings);
|
|
372
|
+
|
|
378
373
|
/**
|
|
379
374
|
* ring buffer structure container instances of PDU
|
|
380
375
|
* @property ringStack
|
|
381
376
|
* @type Array
|
|
382
377
|
*/
|
|
383
378
|
this.ringStack = [];
|
|
379
|
+
|
|
384
380
|
/**
|
|
385
381
|
* Ratelimit Management log printed
|
|
386
382
|
* @property burstPrinted
|
|
387
383
|
* @type Number
|
|
388
384
|
*/
|
|
389
385
|
this.burstPrinted = 0;
|
|
386
|
+
|
|
390
387
|
/**
|
|
391
388
|
* Ratelimit Management log dropped
|
|
392
389
|
* @property missed
|
|
393
390
|
* @type Number
|
|
394
391
|
*/
|
|
395
392
|
this.missed = 0;
|
|
393
|
+
|
|
396
394
|
/**
|
|
397
395
|
* Management log invalid
|
|
398
396
|
* @property invalid
|
|
@@ -406,6 +404,7 @@ class Syslog extends nodefony.Events {
|
|
|
406
404
|
* @type Number
|
|
407
405
|
*/
|
|
408
406
|
this.valid = 0;
|
|
407
|
+
|
|
409
408
|
/**
|
|
410
409
|
* Ratelimit Management begin of burst
|
|
411
410
|
* @property start
|
|
@@ -416,25 +415,27 @@ class Syslog extends nodefony.Events {
|
|
|
416
415
|
this.fire = this.settings.async ? super.fireAsync : super.fire;
|
|
417
416
|
}
|
|
418
417
|
|
|
419
|
-
static formatDebug(debug) {
|
|
420
|
-
return formatDebug(debug)
|
|
418
|
+
static formatDebug (debug) {
|
|
419
|
+
return formatDebug(debug);
|
|
421
420
|
}
|
|
422
421
|
|
|
423
|
-
init(environment = nodefony.environment, debug = nodefony.debug, options = null) {
|
|
424
|
-
return this.listenWithConditions(
|
|
425
|
-
(
|
|
426
|
-
|
|
427
|
-
|
|
422
|
+
init (environment = nodefony.environment, debug = nodefony.debug, options = null) {
|
|
423
|
+
return this.listenWithConditions(
|
|
424
|
+
options || conditionOptions(environment, debug),
|
|
425
|
+
(pdu) => Syslog.normalizeLog(pdu)
|
|
426
|
+
);
|
|
428
427
|
}
|
|
429
428
|
|
|
430
|
-
clean() {
|
|
429
|
+
clean () {
|
|
431
430
|
return this.reset();
|
|
432
431
|
}
|
|
433
432
|
|
|
434
|
-
reset() {
|
|
433
|
+
reset () {
|
|
435
434
|
this.ringStack.length = 0;
|
|
436
435
|
this.removeAllListeners();
|
|
437
436
|
}
|
|
437
|
+
|
|
438
|
+
|
|
438
439
|
/**
|
|
439
440
|
* Clear stack of logs
|
|
440
441
|
*
|
|
@@ -443,15 +444,15 @@ class Syslog extends nodefony.Events {
|
|
|
443
444
|
*
|
|
444
445
|
*
|
|
445
446
|
*/
|
|
446
|
-
clearLogStack() {
|
|
447
|
+
clearLogStack () {
|
|
447
448
|
this.ringStack.length = 0;
|
|
448
449
|
}
|
|
449
450
|
|
|
450
|
-
pushStack(pdu) {
|
|
451
|
+
pushStack (pdu) {
|
|
451
452
|
if (this.ringStack.length === this.settings.maxStack) {
|
|
452
453
|
this.ringStack.shift();
|
|
453
454
|
}
|
|
454
|
-
|
|
455
|
+
const index = this.ringStack.push(pdu);
|
|
455
456
|
this.valid++;
|
|
456
457
|
return index;
|
|
457
458
|
}
|
|
@@ -464,10 +465,10 @@ class Syslog extends nodefony.Events {
|
|
|
464
465
|
* @param {String} msgid informations for message. example(Name of function for debug)
|
|
465
466
|
* @param {String} msg message to add in log. example (I18N)
|
|
466
467
|
*/
|
|
467
|
-
log(payload, severity, msgid, msg) {
|
|
468
|
+
log (payload, severity, msgid, msg) {
|
|
468
469
|
let pdu = null;
|
|
469
470
|
if (this.settings.rateLimit) {
|
|
470
|
-
|
|
471
|
+
const now = new Date().getTime();
|
|
471
472
|
this.start = this.start || now;
|
|
472
473
|
if (now > this.start + this.settings.rateLimit) {
|
|
473
474
|
this.burstPrinted = 0;
|
|
@@ -496,24 +497,23 @@ class Syslog extends nodefony.Events {
|
|
|
496
497
|
this.missed++;
|
|
497
498
|
pdu.status = "DROPPED";
|
|
498
499
|
return pdu;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
}
|
|
506
|
-
} catch (e) {
|
|
507
|
-
console.error(e);
|
|
508
|
-
this.invalid++;
|
|
509
|
-
pdu.status = "INVALID";
|
|
510
|
-
return pdu;
|
|
500
|
+
}
|
|
501
|
+
try {
|
|
502
|
+
if (payload instanceof nodefony.PDU) {
|
|
503
|
+
pdu = payload;
|
|
504
|
+
} else {
|
|
505
|
+
pdu = createPDU.call(this, payload, severity, this.settings.moduleName, msgid || this.settings.msgid, msg);
|
|
511
506
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
this.
|
|
507
|
+
} catch (e) {
|
|
508
|
+
console.error(e);
|
|
509
|
+
this.invalid++;
|
|
510
|
+
pdu.status = "INVALID";
|
|
515
511
|
return pdu;
|
|
516
512
|
}
|
|
513
|
+
this.pushStack(pdu);
|
|
514
|
+
pdu.status = "ACCEPTED";
|
|
515
|
+
this.fire("onLog", pdu);
|
|
516
|
+
return pdu;
|
|
517
517
|
}
|
|
518
518
|
|
|
519
519
|
/**
|
|
@@ -524,7 +524,7 @@ class Syslog extends nodefony.Events {
|
|
|
524
524
|
* @return {array} new array between start end
|
|
525
525
|
* @return {PDU} pdu
|
|
526
526
|
*/
|
|
527
|
-
getLogStack(start, end, contition) {
|
|
527
|
+
getLogStack (start, end, contition) {
|
|
528
528
|
let stack = null;
|
|
529
529
|
if (contition) {
|
|
530
530
|
stack = this.getLogs(contition);
|
|
@@ -549,7 +549,7 @@ class Syslog extends nodefony.Events {
|
|
|
549
549
|
* @param {Object} conditions .
|
|
550
550
|
* @return {array} new array with matches conditions
|
|
551
551
|
*/
|
|
552
|
-
getLogs(conditions = null, stack = null) {
|
|
552
|
+
getLogs (conditions = null, stack = null) {
|
|
553
553
|
if (conditions) {
|
|
554
554
|
return wrapperCondition.call(this, conditions, stack || this.ringStack);
|
|
555
555
|
}
|
|
@@ -561,7 +561,7 @@ class Syslog extends nodefony.Events {
|
|
|
561
561
|
* @method logToJson
|
|
562
562
|
* @return {String} string in JSON format
|
|
563
563
|
*/
|
|
564
|
-
logToJson(conditions, stack = null) {
|
|
564
|
+
logToJson (conditions, stack = null) {
|
|
565
565
|
let res = null;
|
|
566
566
|
if (conditions) {
|
|
567
567
|
res = this.getLogs(conditions, stack);
|
|
@@ -579,7 +579,7 @@ class Syslog extends nodefony.Events {
|
|
|
579
579
|
* @param {function} callback before fire conditions events
|
|
580
580
|
* @return {String}
|
|
581
581
|
*/
|
|
582
|
-
loadStack(stack, doEvent = false, beforeConditions = null) {
|
|
582
|
+
loadStack (stack, doEvent = false, beforeConditions = null) {
|
|
583
583
|
let st = null;
|
|
584
584
|
if (!stack) {
|
|
585
585
|
throw new Error("syslog loadStack : not stack in arguments ");
|
|
@@ -587,7 +587,7 @@ class Syslog extends nodefony.Events {
|
|
|
587
587
|
switch (nodefony.typeOf(stack)) {
|
|
588
588
|
case "string":
|
|
589
589
|
try {
|
|
590
|
-
//console.log(stack);
|
|
590
|
+
// console.log(stack);
|
|
591
591
|
st = JSON.parse(stack);
|
|
592
592
|
return this.loadStack(st, doEvent, beforeConditions);
|
|
593
593
|
} catch (e) {
|
|
@@ -598,7 +598,7 @@ class Syslog extends nodefony.Events {
|
|
|
598
598
|
case "object":
|
|
599
599
|
try {
|
|
600
600
|
for (let i = 0; i < stack.length; i++) {
|
|
601
|
-
|
|
601
|
+
const pdu = new nodefony.PDU(stack[i].payload, stack[i].severity, stack[i].moduleName || this.settings.moduleName, stack[i].msgid, stack[i].msg, stack[i].timeStamp);
|
|
602
602
|
this.pushStack(pdu);
|
|
603
603
|
if (doEvent) {
|
|
604
604
|
if (beforeConditions && typeof beforeConditions === "function") {
|
|
@@ -622,8 +622,7 @@ class Syslog extends nodefony.Events {
|
|
|
622
622
|
* @method filter
|
|
623
623
|
*
|
|
624
624
|
*/
|
|
625
|
-
filter(conditions = null, callback = null) {
|
|
626
|
-
|
|
625
|
+
filter (conditions = null, callback = null) {
|
|
627
626
|
if (!conditions) {
|
|
628
627
|
throw new Error("filter conditions not found ");
|
|
629
628
|
}
|
|
@@ -644,37 +643,37 @@ class Syslog extends nodefony.Events {
|
|
|
644
643
|
* @method listenWithConditions
|
|
645
644
|
*
|
|
646
645
|
*/
|
|
647
|
-
listenWithConditions(conditions, callback) {
|
|
646
|
+
listenWithConditions (conditions, callback) {
|
|
648
647
|
return this.filter(conditions, callback);
|
|
649
648
|
}
|
|
650
649
|
|
|
651
|
-
error(data) {
|
|
650
|
+
error (data) {
|
|
652
651
|
return this.log(data, "ERROR");
|
|
653
652
|
}
|
|
654
653
|
|
|
655
|
-
warn(data) {
|
|
654
|
+
warn (data) {
|
|
656
655
|
return this.log(data, "WARNING");
|
|
657
656
|
}
|
|
658
657
|
|
|
659
|
-
warnning(data) {
|
|
658
|
+
warnning (data) {
|
|
660
659
|
return this.log(data, "WARNING");
|
|
661
660
|
}
|
|
662
661
|
|
|
663
|
-
info(data) {
|
|
662
|
+
info (data) {
|
|
664
663
|
return this.log(data, "INFO");
|
|
665
664
|
}
|
|
666
665
|
|
|
667
|
-
debug(data) {
|
|
666
|
+
debug (data) {
|
|
668
667
|
return this.log(data, "DEBUG");
|
|
669
668
|
}
|
|
670
669
|
|
|
671
|
-
trace(data) {
|
|
670
|
+
trace (data) {
|
|
672
671
|
return this.log(data, "NOTICE");
|
|
673
672
|
}
|
|
674
673
|
|
|
675
|
-
static wrapper(pdu) {
|
|
674
|
+
static wrapper (pdu) {
|
|
676
675
|
if (!pdu) {
|
|
677
|
-
throw new Error(
|
|
676
|
+
throw new Error("Syslog pdu not defined");
|
|
678
677
|
}
|
|
679
678
|
const date = new Date(pdu.timeStamp);
|
|
680
679
|
switch (pdu.severity) {
|
|
@@ -685,36 +684,36 @@ class Syslog extends nodefony.Events {
|
|
|
685
684
|
return {
|
|
686
685
|
logger: console.error,
|
|
687
686
|
text: `${date.toDateString()} ${date.toLocaleTimeString()} ${red(pdu.severityName)} ${green(pdu.msgid)} : `
|
|
688
|
-
}
|
|
687
|
+
};
|
|
689
688
|
case 4:
|
|
690
689
|
return {
|
|
691
690
|
logger: console.warn,
|
|
692
691
|
text: `${date.toDateString()} ${date.toLocaleTimeString()} ${yellow(pdu.severityName)} ${green(pdu.msgid)} : `
|
|
693
|
-
}
|
|
692
|
+
};
|
|
694
693
|
case 5:
|
|
695
694
|
return {
|
|
696
695
|
logger: console.log,
|
|
697
696
|
text: `${date.toDateString()} ${date.toLocaleTimeString()} ${red(pdu.severityName)} ${green(pdu.msgid)} : `
|
|
698
|
-
}
|
|
697
|
+
};
|
|
699
698
|
case 6:
|
|
700
699
|
return {
|
|
701
700
|
logger: console.info,
|
|
702
701
|
text: `${date.toDateString()} ${date.toLocaleTimeString()} ${blue(pdu.severityName)} ${green(pdu.msgid)} : `
|
|
703
|
-
}
|
|
702
|
+
};
|
|
704
703
|
case 7:
|
|
705
704
|
return {
|
|
706
705
|
logger: console.debug,
|
|
707
706
|
text: `${date.toDateString()} ${date.toLocaleTimeString()} ${cyan(pdu.severityName)} ${green(pdu.msgid)} : `
|
|
708
|
-
}
|
|
707
|
+
};
|
|
709
708
|
default:
|
|
710
709
|
return {
|
|
711
710
|
logger: console.log,
|
|
712
711
|
text: `${date.toDateString()} ${date.toLocaleTimeString()} ${cyan(pdu.severityName)} ${green(pdu.msgid)} : `
|
|
713
|
-
}
|
|
712
|
+
};
|
|
714
713
|
}
|
|
715
714
|
}
|
|
716
715
|
|
|
717
|
-
static normalizeLog(pdu, pid = "") {
|
|
716
|
+
static normalizeLog (pdu, pid = "") {
|
|
718
717
|
if (pdu.payload === "" || pdu.payload === undefined) {
|
|
719
718
|
console.warn(`${pdu.severityName} ${pdu.msgid} : logger message empty !!!!`);
|
|
720
719
|
console.trace(pdu);
|
|
@@ -724,12 +723,12 @@ class Syslog extends nodefony.Events {
|
|
|
724
723
|
switch (typeof message) {
|
|
725
724
|
case "object":
|
|
726
725
|
switch (true) {
|
|
727
|
-
case
|
|
726
|
+
case message instanceof nodefony.Error:
|
|
728
727
|
if (this.kernel && this.kernel.console) {
|
|
729
728
|
message = message.message;
|
|
730
729
|
}
|
|
731
730
|
break;
|
|
732
|
-
case
|
|
731
|
+
case message instanceof Error:
|
|
733
732
|
if (this.kernel && this.kernel.console) {
|
|
734
733
|
message = message.message;
|
|
735
734
|
} else {
|
|
@@ -741,12 +740,12 @@ class Syslog extends nodefony.Events {
|
|
|
741
740
|
default:
|
|
742
741
|
}
|
|
743
742
|
if (pdu.severity === -1) {
|
|
744
|
-
process.stdout.write("\u001b[0G")
|
|
743
|
+
process.stdout.write("\u001b[0G");
|
|
745
744
|
process.stdout.write(`${green(pdu.msgid)} : ${message}`);
|
|
746
|
-
process.stdout.write("\u001b[90m\u001b[0m")
|
|
745
|
+
process.stdout.write("\u001b[90m\u001b[0m");
|
|
747
746
|
return pdu;
|
|
748
747
|
}
|
|
749
|
-
|
|
748
|
+
const wrap = Syslog.wrapper(pdu, message);
|
|
750
749
|
wrap.logger(`${pid} ${wrap.text}`, message);
|
|
751
750
|
return pdu;
|
|
752
751
|
}
|
package/watcher.es6
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
const chokidar = require(
|
|
1
|
+
const chokidar = require("chokidar");
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
const defaultWatcherSettings = {
|
|
5
5
|
persistent: true,
|
|
6
6
|
followSymlinks: true,
|
|
7
|
-
cwd:
|
|
8
|
-
//useFsEvents: true,
|
|
7
|
+
cwd: ".",
|
|
8
|
+
// useFsEvents: true,
|
|
9
9
|
usePolling: true,
|
|
10
10
|
interval: 100,
|
|
11
11
|
binaryInterval: 300,
|
|
12
|
-
//alwaysStat: false,
|
|
13
|
-
//depth: 99,
|
|
14
|
-
//awaitWriteFinish: {
|
|
12
|
+
// alwaysStat: false,
|
|
13
|
+
// depth: 99,
|
|
14
|
+
// awaitWriteFinish: {
|
|
15
15
|
// stabilityThreshold: 2000,
|
|
16
16
|
// pollInterval: 100
|
|
17
|
-
//},
|
|
18
|
-
//ignorePermissionErrors: false,
|
|
17
|
+
// },
|
|
18
|
+
// ignorePermissionErrors: false,
|
|
19
19
|
atomic: true // or a custom 'atomicity delay', in milliseconds (default 100)
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
class Watcher extends nodefony.Service {
|
|
23
|
-
constructor(Path, settings, container) {
|
|
23
|
+
constructor (Path, settings, container) {
|
|
24
24
|
super("WATCHER", container);
|
|
25
25
|
this.chokidar = chokidar;
|
|
26
26
|
this.watcher = null;
|
|
@@ -31,10 +31,10 @@ class Watcher extends nodefony.Service {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
watch(Path, settings) {
|
|
34
|
+
watch (Path, settings) {
|
|
35
35
|
try {
|
|
36
36
|
if (this.watcher) {
|
|
37
|
-
|
|
37
|
+
const error = new Error(`Already watching : ${Path}`);
|
|
38
38
|
this.fire("onError", error);
|
|
39
39
|
throw error;
|
|
40
40
|
}
|
|
@@ -45,7 +45,7 @@ class Watcher extends nodefony.Service {
|
|
|
45
45
|
if (this.path) {
|
|
46
46
|
this.initialize(this.path, settings);
|
|
47
47
|
} else {
|
|
48
|
-
|
|
48
|
+
const error = new Error("WATCHER no path");
|
|
49
49
|
this.fire("onError", error);
|
|
50
50
|
throw error;
|
|
51
51
|
}
|
|
@@ -56,7 +56,7 @@ class Watcher extends nodefony.Service {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
unwatch(file) {
|
|
59
|
+
unwatch (file) {
|
|
60
60
|
try {
|
|
61
61
|
return this.watcher.unwatch(file);
|
|
62
62
|
} catch (e) {
|
|
@@ -66,7 +66,7 @@ class Watcher extends nodefony.Service {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
getWatched(file) {
|
|
69
|
+
getWatched (file) {
|
|
70
70
|
if (!file) {
|
|
71
71
|
if (this.watcher) {
|
|
72
72
|
return this.watcher.getWatched();
|
|
@@ -74,7 +74,7 @@ class Watcher extends nodefony.Service {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
close(removeEvents) {
|
|
77
|
+
close (removeEvents) {
|
|
78
78
|
if (this.watcher) {
|
|
79
79
|
this.watcher.close();
|
|
80
80
|
this.fire("onClose", this.watcher);
|
|
@@ -84,17 +84,18 @@ class Watcher extends nodefony.Service {
|
|
|
84
84
|
this.watcher = null;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
|
|
88
|
+
initialize (Path, settings) {
|
|
88
89
|
try {
|
|
89
90
|
this.watcher = this.chokidar.watch(Path, nodefony.extend(true, {}, this.settings, settings));
|
|
90
91
|
this.fire("onInitialize", this.watcher, Path);
|
|
91
|
-
super.log(
|
|
92
|
-
this.watcher.on(
|
|
92
|
+
super.log(`INITIALISE WATCHING PATH : ${Path}`, "DEBUG");
|
|
93
|
+
this.watcher.on("all", (event, Path) => {
|
|
93
94
|
this.fire("all", event, Path);
|
|
94
95
|
try {
|
|
95
|
-
|
|
96
|
+
const stats = null;
|
|
96
97
|
event = event.charAt(0).toUpperCase() + event.slice(1);
|
|
97
|
-
this.fire(
|
|
98
|
+
this.fire(`on${event}`, Path, stats, this.watcher);
|
|
98
99
|
} catch (e) {
|
|
99
100
|
this.fire("onError", e);
|
|
100
101
|
this.log(e, "ERROR");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
node_modules
|