@akc42/server-utils 2.0.0 → 2.0.2
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/debug.js +4 -2
- package/logger.js +1 -1
- package/package.json +1 -1
- package/responder.js +4 -6
package/debug.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import chalk from 'chalk';
|
|
22
22
|
let config = '';
|
|
23
23
|
let cache = [];
|
|
24
|
+
let cachelimit = 50;
|
|
24
25
|
|
|
25
26
|
export function Debug (topic) {
|
|
26
27
|
const t = topic;
|
|
@@ -42,7 +43,7 @@ export function Debug (topic) {
|
|
|
42
43
|
console.log(output);
|
|
43
44
|
}
|
|
44
45
|
cache.push(output);
|
|
45
|
-
cache.splice(0,cache.length -
|
|
46
|
+
if (cache.length > cachelimit) cache.splice(0,cache.length - cachelimit); //prevent it getting too big
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
export function dumpDebugCache() {
|
|
@@ -54,7 +55,8 @@ export function dumpDebugCache() {
|
|
|
54
55
|
cache.reverse();
|
|
55
56
|
console.log(output);
|
|
56
57
|
};
|
|
57
|
-
export function setDebugConfig(con) {
|
|
58
|
+
export function setDebugConfig(con, limit = 50) {
|
|
59
|
+
cachelimit = limit;
|
|
58
60
|
if (con !== config) {
|
|
59
61
|
config = con;
|
|
60
62
|
const output = `${chalk.greenBright('debug server config')} ${chalk.redBright(`new server config "${config}"`)}`
|
package/logger.js
CHANGED
|
@@ -51,7 +51,7 @@ if (process.env.LOG_NO_ENCODE) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export default
|
|
54
|
+
export default function logger(ip,level, ...messages) {
|
|
55
55
|
if (process.env.LOG_NONE === undefined) {
|
|
56
56
|
let logLine = '';
|
|
57
57
|
if (process.env.LOG_NO_DATE === undefined) logLine += new Date().toISOString() + ': ';
|
package/package.json
CHANGED
package/responder.js
CHANGED
|
@@ -20,9 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import Debug from 'debug';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const debug = Debug('responder');
|
|
23
|
+
const debug = Debug('responder');
|
|
26
24
|
|
|
27
25
|
export default class Responder {
|
|
28
26
|
constructor(response) {
|
|
@@ -49,14 +47,14 @@ export default class Responder {
|
|
|
49
47
|
this.response.write('{"' + name + '": ');
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
if (value !== undefined) {
|
|
50
|
+
if (typeof value !== 'undefined') {
|
|
53
51
|
this.response.write(JSON.stringify(value));
|
|
54
52
|
this.inSection = false;
|
|
55
|
-
debug('
|
|
53
|
+
debug('Write conplete section',name, 'with' , JSON.stringify(value));
|
|
56
54
|
} else {
|
|
57
55
|
this.response.write('[');
|
|
58
56
|
this.inSection = true;
|
|
59
|
-
debug('
|
|
57
|
+
debug('Started Section',name);
|
|
60
58
|
}
|
|
61
59
|
this.doneFirstSection = true;
|
|
62
60
|
this.doneFirstRow = false;
|