1 | 'use strict' |
||
0 ignored issues
–
show
|
|||
2 | var dir = __dirname; |
||
0 ignored issues
–
show
|
|||
3 | function Logger(options) { |
||
4 | |||
5 | var pino = require('pino'); |
||
0 ignored issues
–
show
|
|||
6 | |||
7 | //var pretty = pino.pretty() |
||
8 | //pretty.pipe(process.stdout) |
||
9 | var log = pino(options);//,pretty); |
||
10 | var loggers = [log]; |
||
11 | //AOP: Inject trace behavior in all function calls |
||
12 | /* Should this be handled by an external jstrace instead? |
||
13 | (function () { |
||
14 | var oldCall = Function.prototype.call; |
||
15 | var newCall = function(self) { |
||
16 | Function.prototype.call = oldCall; |
||
17 | if (this.name){ |
||
18 | log.trace('Function called:', this.name); |
||
19 | } |
||
20 | var args = Array.prototype.slice.call(arguments, 1); |
||
21 | var res = this.apply(self, args); |
||
22 | Function.prototype.call = newCall; |
||
23 | return res |
||
24 | } |
||
25 | Function.prototype.call = newCall; |
||
26 | })(); |
||
27 | */ |
||
28 | |||
29 | const Arborsculpt = require('pino-arborsculpture') |
||
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: ![]() |
|||
30 | const arbor = new Arborsculpt({ |
||
0 ignored issues
–
show
|
|||
31 | path: dir+'/adjustments.json', |
||
32 | loggers: loggers, //Will this capture children as well? If not we will need Arborsculpt entries for them as well. |
||
33 | interval: 60000 // the default |
||
34 | }) |
||
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: ![]() |
|||
35 | log._tagged = true; |
||
36 | log.info('monitoring ', dir+'/adjustments.json', ' for logging adjustments.'); |
||
37 | |||
38 | arbor.on('error', function (err) { |
||
39 | log.error(err,'there was a problem reading the file or setting the level'); |
||
40 | }) |
||
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: ![]() |
|||
41 | |||
42 | log.on('level-change', function(lvl, val, prevLvl, prevVal){ |
||
43 | if ((prevLvl !== undefined) && (lvl!==prevLvl)){ |
||
44 | this[lvl](`logging level changed from ${prevLvl} to ${lvl}`); |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
45 | } |
||
46 | if (!this._tagged){ |
||
47 | //this is the first time we have seen the logger, it could be a child. |
||
48 | this._tagged = true; |
||
49 | loggers.push(this); |
||
50 | } |
||
51 | }) |
||
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: ![]() |
|||
52 | |||
53 | log.monitor=function(logger,path){ |
||
54 | var childArbor = new Arborsculpt({ |
||
55 | path: path, |
||
56 | loggers: [logger], //Will this capture children as well? If not we will need Arborsculpt entries for them as well. |
||
57 | interval: 60000 // the default |
||
58 | }) |
||
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: ![]() |
|||
59 | } |
||
0 ignored issues
–
show
There should be a semicolon.
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers. Further Readings: ![]() |
|||
60 | |||
61 | return log; |
||
62 | } |
||
63 | |||
64 | |||
65 | module.exports = Logger; |
||
0 ignored issues
–
show
|
Requirement of semicolons purely is a coding style issue since JavaScript has specific rules about semicolons which are followed by all browsers.
Further Readings: