typespeed 2.4.1 → 2.4.3
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/dist/database.decorator.js +2 -4
- package/dist/typespeed.js +4 -1
- package/introduction/tsconfig.json +20 -0
- package/package.json +2 -4
- package/src/database.decorator.ts +2 -4
- package/src/typespeed.ts +4 -1
- package/app/node_modules/.package-lock.json +0 -134
- package/app/node_modules/@types/body-parser/LICENSE +0 -21
- package/app/node_modules/@types/body-parser/README.md +0 -16
- package/app/node_modules/@types/body-parser/index.d.ts +0 -107
- package/app/node_modules/@types/body-parser/package.json +0 -58
- package/app/node_modules/@types/connect/LICENSE +0 -21
- package/app/node_modules/@types/connect/README.md +0 -16
- package/app/node_modules/@types/connect/index.d.ts +0 -93
- package/app/node_modules/@types/connect/package.json +0 -32
- package/app/node_modules/@types/express/LICENSE +0 -21
- package/app/node_modules/@types/express/README.md +0 -16
- package/app/node_modules/@types/express/index.d.ts +0 -136
- package/app/node_modules/@types/express/package.json +0 -45
- package/app/node_modules/@types/express-serve-static-core/LICENSE +0 -21
- package/app/node_modules/@types/express-serve-static-core/README.md +0 -16
- package/app/node_modules/@types/express-serve-static-core/index.d.ts +0 -1281
- package/app/node_modules/@types/express-serve-static-core/package.json +0 -55
- package/app/node_modules/@types/mime/LICENSE +0 -21
- package/app/node_modules/@types/mime/Mime.d.ts +0 -10
- package/app/node_modules/@types/mime/README.md +0 -16
- package/app/node_modules/@types/mime/index.d.ts +0 -35
- package/app/node_modules/@types/mime/lite.d.ts +0 -7
- package/app/node_modules/@types/mime/package.json +0 -29
- package/app/node_modules/@types/node/LICENSE +0 -21
- package/app/node_modules/@types/node/README.md +0 -16
- package/app/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/app/node_modules/@types/node/assert.d.ts +0 -961
- package/app/node_modules/@types/node/async_hooks.d.ts +0 -518
- package/app/node_modules/@types/node/buffer.d.ts +0 -2323
- package/app/node_modules/@types/node/child_process.d.ts +0 -1399
- package/app/node_modules/@types/node/cluster.d.ts +0 -410
- package/app/node_modules/@types/node/console.d.ts +0 -412
- package/app/node_modules/@types/node/constants.d.ts +0 -18
- package/app/node_modules/@types/node/crypto.d.ts +0 -3973
- package/app/node_modules/@types/node/dgram.d.ts +0 -545
- package/app/node_modules/@types/node/diagnostics_channel.d.ts +0 -192
- package/app/node_modules/@types/node/dns/promises.d.ts +0 -370
- package/app/node_modules/@types/node/dns.d.ts +0 -660
- package/app/node_modules/@types/node/dom-events.d.ts +0 -126
- package/app/node_modules/@types/node/domain.d.ts +0 -170
- package/app/node_modules/@types/node/events.d.ts +0 -682
- package/app/node_modules/@types/node/fs/promises.d.ts +0 -1159
- package/app/node_modules/@types/node/fs.d.ts +0 -3976
- package/app/node_modules/@types/node/globals.d.ts +0 -303
- package/app/node_modules/@types/node/globals.global.d.ts +0 -1
- package/app/node_modules/@types/node/http.d.ts +0 -1714
- package/app/node_modules/@types/node/http2.d.ts +0 -2133
- package/app/node_modules/@types/node/https.d.ts +0 -542
- package/app/node_modules/@types/node/index.d.ts +0 -134
- package/app/node_modules/@types/node/inspector.d.ts +0 -2741
- package/app/node_modules/@types/node/module.d.ts +0 -115
- package/app/node_modules/@types/node/net.d.ts +0 -883
- package/app/node_modules/@types/node/os.d.ts +0 -473
- package/app/node_modules/@types/node/package.json +0 -237
- package/app/node_modules/@types/node/path.d.ts +0 -191
- package/app/node_modules/@types/node/perf_hooks.d.ts +0 -625
- package/app/node_modules/@types/node/process.d.ts +0 -1488
- package/app/node_modules/@types/node/punycode.d.ts +0 -117
- package/app/node_modules/@types/node/querystring.d.ts +0 -131
- package/app/node_modules/@types/node/readline/promises.d.ts +0 -143
- package/app/node_modules/@types/node/readline.d.ts +0 -653
- package/app/node_modules/@types/node/repl.d.ts +0 -424
- package/app/node_modules/@types/node/stream/consumers.d.ts +0 -12
- package/app/node_modules/@types/node/stream/promises.d.ts +0 -42
- package/app/node_modules/@types/node/stream/web.d.ts +0 -330
- package/app/node_modules/@types/node/stream.d.ts +0 -1440
- package/app/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/app/node_modules/@types/node/test.d.ts +0 -783
- package/app/node_modules/@types/node/timers/promises.d.ts +0 -93
- package/app/node_modules/@types/node/timers.d.ts +0 -101
- package/app/node_modules/@types/node/tls.d.ts +0 -1111
- package/app/node_modules/@types/node/trace_events.d.ts +0 -171
- package/app/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
- package/app/node_modules/@types/node/ts4.8/assert.d.ts +0 -961
- package/app/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -518
- package/app/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2323
- package/app/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1399
- package/app/node_modules/@types/node/ts4.8/cluster.d.ts +0 -410
- package/app/node_modules/@types/node/ts4.8/console.d.ts +0 -412
- package/app/node_modules/@types/node/ts4.8/constants.d.ts +0 -18
- package/app/node_modules/@types/node/ts4.8/crypto.d.ts +0 -3972
- package/app/node_modules/@types/node/ts4.8/dgram.d.ts +0 -545
- package/app/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -192
- package/app/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -370
- package/app/node_modules/@types/node/ts4.8/dns.d.ts +0 -660
- package/app/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -126
- package/app/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
- package/app/node_modules/@types/node/ts4.8/events.d.ts +0 -682
- package/app/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1138
- package/app/node_modules/@types/node/ts4.8/fs.d.ts +0 -3875
- package/app/node_modules/@types/node/ts4.8/globals.d.ts +0 -302
- package/app/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
- package/app/node_modules/@types/node/ts4.8/http.d.ts +0 -1651
- package/app/node_modules/@types/node/ts4.8/http2.d.ts +0 -2133
- package/app/node_modules/@types/node/ts4.8/https.d.ts +0 -542
- package/app/node_modules/@types/node/ts4.8/index.d.ts +0 -88
- package/app/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2741
- package/app/node_modules/@types/node/ts4.8/module.d.ts +0 -115
- package/app/node_modules/@types/node/ts4.8/net.d.ts +0 -883
- package/app/node_modules/@types/node/ts4.8/os.d.ts +0 -473
- package/app/node_modules/@types/node/ts4.8/path.d.ts +0 -191
- package/app/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -625
- package/app/node_modules/@types/node/ts4.8/process.d.ts +0 -1488
- package/app/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
- package/app/node_modules/@types/node/ts4.8/querystring.d.ts +0 -131
- package/app/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -143
- package/app/node_modules/@types/node/ts4.8/readline.d.ts +0 -653
- package/app/node_modules/@types/node/ts4.8/repl.d.ts +0 -424
- package/app/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
- package/app/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -42
- package/app/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -330
- package/app/node_modules/@types/node/ts4.8/stream.d.ts +0 -1440
- package/app/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
- package/app/node_modules/@types/node/ts4.8/test.d.ts +0 -784
- package/app/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
- package/app/node_modules/@types/node/ts4.8/timers.d.ts +0 -94
- package/app/node_modules/@types/node/ts4.8/tls.d.ts +0 -1111
- package/app/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -171
- package/app/node_modules/@types/node/ts4.8/tty.d.ts +0 -206
- package/app/node_modules/@types/node/ts4.8/url.d.ts +0 -902
- package/app/node_modules/@types/node/ts4.8/util.d.ts +0 -2017
- package/app/node_modules/@types/node/ts4.8/v8.d.ts +0 -541
- package/app/node_modules/@types/node/ts4.8/vm.d.ts +0 -644
- package/app/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
- package/app/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -695
- package/app/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
- package/app/node_modules/@types/node/tty.d.ts +0 -206
- package/app/node_modules/@types/node/url.d.ts +0 -902
- package/app/node_modules/@types/node/util.d.ts +0 -2017
- package/app/node_modules/@types/node/v8.d.ts +0 -541
- package/app/node_modules/@types/node/vm.d.ts +0 -644
- package/app/node_modules/@types/node/wasi.d.ts +0 -158
- package/app/node_modules/@types/node/worker_threads.d.ts +0 -695
- package/app/node_modules/@types/node/zlib.d.ts +0 -517
- package/app/node_modules/@types/qs/LICENSE +0 -21
- package/app/node_modules/@types/qs/README.md +0 -16
- package/app/node_modules/@types/qs/index.d.ts +0 -62
- package/app/node_modules/@types/qs/package.json +0 -65
- package/app/node_modules/@types/range-parser/LICENSE +0 -21
- package/app/node_modules/@types/range-parser/README.md +0 -55
- package/app/node_modules/@types/range-parser/index.d.ts +0 -35
- package/app/node_modules/@types/range-parser/package.json +0 -25
- package/app/node_modules/@types/send/LICENSE +0 -21
- package/app/node_modules/@types/send/README.md +0 -16
- package/app/node_modules/@types/send/index.d.ts +0 -231
- package/app/node_modules/@types/send/package.json +0 -33
- package/app/node_modules/@types/serve-static/LICENSE +0 -21
- package/app/node_modules/@types/serve-static/README.md +0 -16
- package/app/node_modules/@types/serve-static/index.d.ts +0 -113
- package/app/node_modules/@types/serve-static/package.json +0 -38
- package/app/node_modules/colors/LICENSE +0 -25
- package/app/node_modules/colors/README.md +0 -221
- package/app/node_modules/colors/examples/normal-usage.js +0 -82
- package/app/node_modules/colors/examples/safe-string.js +0 -79
- package/app/node_modules/colors/index.d.ts +0 -136
- package/app/node_modules/colors/lib/colors.js +0 -211
- package/app/node_modules/colors/lib/custom/trap.js +0 -46
- package/app/node_modules/colors/lib/custom/zalgo.js +0 -110
- package/app/node_modules/colors/lib/extendStringPrototype.js +0 -110
- package/app/node_modules/colors/lib/index.js +0 -13
- package/app/node_modules/colors/lib/maps/america.js +0 -10
- package/app/node_modules/colors/lib/maps/rainbow.js +0 -12
- package/app/node_modules/colors/lib/maps/random.js +0 -11
- package/app/node_modules/colors/lib/maps/zebra.js +0 -5
- package/app/node_modules/colors/lib/styles.js +0 -95
- package/app/node_modules/colors/lib/system/has-flag.js +0 -35
- package/app/node_modules/colors/lib/system/supports-colors.js +0 -151
- package/app/node_modules/colors/package.json +0 -45
- package/app/node_modules/colors/safe.d.ts +0 -48
- package/app/node_modules/colors/safe.js +0 -10
- package/app/node_modules/colors/themes/generic-logging.js +0 -12
- package/app/node_modules/dateformat/LICENSE +0 -20
- package/app/node_modules/dateformat/Readme.md +0 -204
- package/app/node_modules/dateformat/lib/dateformat.js +0 -1
- package/app/node_modules/dateformat/package.json +0 -38
- package/app/node_modules/mkdirp/CHANGELOG.md +0 -15
- package/app/node_modules/mkdirp/LICENSE +0 -21
- package/app/node_modules/mkdirp/bin/cmd.js +0 -68
- package/app/node_modules/mkdirp/index.js +0 -31
- package/app/node_modules/mkdirp/lib/find-made.js +0 -29
- package/app/node_modules/mkdirp/lib/mkdirp-manual.js +0 -64
- package/app/node_modules/mkdirp/lib/mkdirp-native.js +0 -39
- package/app/node_modules/mkdirp/lib/opts-arg.js +0 -23
- package/app/node_modules/mkdirp/lib/path-arg.js +0 -29
- package/app/node_modules/mkdirp/lib/use-native.js +0 -10
- package/app/node_modules/mkdirp/package.json +0 -44
- package/app/node_modules/mkdirp/readme.markdown +0 -266
- package/app/node_modules/tinytim/.travis.yml +0 -5
- package/app/node_modules/tinytim/README.md +0 -212
- package/app/node_modules/tinytim/index.js +0 -1
- package/app/node_modules/tinytim/lib/index.js +0 -55
- package/app/node_modules/tinytim/lib/tinytim.js +0 -50
- package/app/node_modules/tinytim/package.json +0 -24
- package/app/node_modules/tinytim/test/files/html.tim +0 -1
- package/app/node_modules/tinytim/test/files/string.tim +0 -1
- package/app/node_modules/tinytim/test/files/string2.tim +0 -1
- package/app/node_modules/tinytim/test/render-file-replace.js +0 -39
- package/app/node_modules/tinytim/test/render-replace.js +0 -94
- package/app/node_modules/tinytim/test/tim-replace.js +0 -95
- package/app/node_modules/tracer/README.md +0 -747
- package/app/node_modules/tracer/lib/color_console.js +0 -15
- package/app/node_modules/tracer/lib/console.js +0 -165
- package/app/node_modules/tracer/lib/dailyfile.js +0 -92
- package/app/node_modules/tracer/lib/index.js +0 -10
- package/app/node_modules/tracer/lib/settings.js +0 -25
- package/app/node_modules/tracer/lib/utils.js +0 -58
- package/app/node_modules/tracer/package.json +0 -53
- package/app/node_modules/tracer/types/index.d.ts +0 -189
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var colors = require('colors/safe');
|
|
3
|
-
module.exports = function(conf) {
|
|
4
|
-
return require('./console')({
|
|
5
|
-
filters : {
|
|
6
|
-
//log : do nothing
|
|
7
|
-
trace : colors.magenta,
|
|
8
|
-
debug : colors.cyan,
|
|
9
|
-
info : colors.green,
|
|
10
|
-
warn : colors.yellow,
|
|
11
|
-
error : colors.red.bold,
|
|
12
|
-
fatal : colors.red.bold
|
|
13
|
-
}
|
|
14
|
-
}, conf);
|
|
15
|
-
};
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var tinytim = require('tinytim'), dateFormat = require('dateformat'), utils = require('./utils'), path = require('path'), settings = require('./settings').settings;
|
|
3
|
-
|
|
4
|
-
var noop = function(){};
|
|
5
|
-
|
|
6
|
-
var fwrap = function(fn){
|
|
7
|
-
return function(str){ return fn(str) };
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// Stack trace format :
|
|
11
|
-
// https://github.com/v8/v8/wiki/Stack%20Trace%20API
|
|
12
|
-
var stackReg = /at\s+(.*)\s+\((.*):(\d*):(\d*)\)/i;
|
|
13
|
-
var stackReg2 = /at\s+()(.*):(\d*):(\d*)/i;
|
|
14
|
-
|
|
15
|
-
// main log method
|
|
16
|
-
function logMain(config, level, title, format, filters, needstack, args) {
|
|
17
|
-
//check level of global settings
|
|
18
|
-
var gLevel = settings.level;
|
|
19
|
-
if (typeof (gLevel) == 'string')
|
|
20
|
-
gLevel = config.methods.indexOf(gLevel);
|
|
21
|
-
if (level < gLevel) { return; }
|
|
22
|
-
|
|
23
|
-
var data = {
|
|
24
|
-
timestamp : dateFormat(new Date(), config.dateformat),
|
|
25
|
-
message : "",
|
|
26
|
-
title : title,
|
|
27
|
-
level : level,
|
|
28
|
-
args : args
|
|
29
|
-
};
|
|
30
|
-
data.method = data.path = data.line = data.pos = data.file = data.folder = '';
|
|
31
|
-
|
|
32
|
-
if (needstack) {
|
|
33
|
-
// get call stack, and analyze it
|
|
34
|
-
// get all file,method and line number
|
|
35
|
-
var stacklist = (new Error()).stack.split('\n').slice(3);
|
|
36
|
-
var s = stacklist[config.stackIndex] || stacklist[0],
|
|
37
|
-
sp = stackReg.exec(s) || stackReg2.exec(s);
|
|
38
|
-
if (sp && sp.length === 5) {
|
|
39
|
-
data.method = sp[1];
|
|
40
|
-
data.path = sp[2];
|
|
41
|
-
data.line = sp[3];
|
|
42
|
-
data.pos = sp[4];
|
|
43
|
-
data.folder = path.dirname(config.rootDir && path.isAbsolute(config.rootDir)
|
|
44
|
-
? data.path.replace(new RegExp('^'+config.rootDir+path.sep+'?'), '')
|
|
45
|
-
: path.resolve(data.path));
|
|
46
|
-
data.file = path.basename(data.path);
|
|
47
|
-
|
|
48
|
-
data.stack = stacklist.join('\n');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
config.preprocess(data);
|
|
53
|
-
var msg = utils.format.apply(config, data.args);
|
|
54
|
-
data.message = msg;
|
|
55
|
-
|
|
56
|
-
// call micro-template to ouput
|
|
57
|
-
data.output = tinytim.tim(format, data);
|
|
58
|
-
|
|
59
|
-
// save unprocessed output
|
|
60
|
-
data.rawoutput = data.output;
|
|
61
|
-
|
|
62
|
-
// process every filter method
|
|
63
|
-
var len = filters.length;
|
|
64
|
-
for ( var i = 0; i < len; i += 1) {
|
|
65
|
-
data.output = fwrap(filters[i])(data.output);
|
|
66
|
-
if (!data.output)
|
|
67
|
-
return data;
|
|
68
|
-
// cancel next process if return a false(include null, undefined)
|
|
69
|
-
}
|
|
70
|
-
// trans the final result
|
|
71
|
-
config.transport.forEach(function(tras) {
|
|
72
|
-
tras(data);
|
|
73
|
-
});
|
|
74
|
-
return data;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = (function() {
|
|
78
|
-
// default config
|
|
79
|
-
var _config = {
|
|
80
|
-
rootDir: '',
|
|
81
|
-
format : "{{timestamp}} <{{title}}> {{file}}:{{line}} ({{method}}) {{message}}",
|
|
82
|
-
dateformat : "isoDateTime",
|
|
83
|
-
preprocess : function() {
|
|
84
|
-
},
|
|
85
|
-
transport : function(data) {
|
|
86
|
-
if (data.title == 'warn') {
|
|
87
|
-
console.warn(data.output)
|
|
88
|
-
} else if (data.level > 4) {
|
|
89
|
-
console.error(data.output)
|
|
90
|
-
} else (
|
|
91
|
-
console.log(data.output)
|
|
92
|
-
)
|
|
93
|
-
},
|
|
94
|
-
filters : [],
|
|
95
|
-
level : 'log',
|
|
96
|
-
methods : [ 'log', 'trace', 'debug', 'info', 'warn', 'error', 'fatal' ],
|
|
97
|
-
stackIndex : 0, // get the specified index of stack as file information. It is userful for development package.
|
|
98
|
-
inspectOpt : {
|
|
99
|
-
showHidden : false, //if true then the object's non-enumerable properties will be shown too. Defaults to false
|
|
100
|
-
depth : 2 //tells inspect how many times to recurse while formatting the object. This is useful for inspecting large complicated objects. Defaults to 2. To make it recurse indefinitely pass null.
|
|
101
|
-
},
|
|
102
|
-
supportConsoleMethods : true
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
var userConfig = arguments;
|
|
106
|
-
if(typeof userConfig[0] === 'string') {
|
|
107
|
-
userConfig = [eval("require")(userConfig[0])];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// union user's config and default
|
|
111
|
-
_config = utils.union(_config, userConfig);
|
|
112
|
-
|
|
113
|
-
var _self = {};
|
|
114
|
-
|
|
115
|
-
_config.format = Array.isArray(_config.format) ? _config.format
|
|
116
|
-
: [ _config.format ];
|
|
117
|
-
|
|
118
|
-
_config.filters = Array.isArray(_config.filters) ? _config.filters
|
|
119
|
-
: [ _config.filters ];
|
|
120
|
-
|
|
121
|
-
_config.transport = Array.isArray(_config.transport) ? _config.transport : [_config.transport];
|
|
122
|
-
|
|
123
|
-
var fLen = _config.filters.length, lastFilter;
|
|
124
|
-
if (fLen > 0)
|
|
125
|
-
if (Object.prototype.toString.call(_config.filters[--fLen]) != '[object Function]') {
|
|
126
|
-
lastFilter = _config.filters[fLen];
|
|
127
|
-
_config.filters = _config.filters.slice(0, fLen);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (typeof (_config.level) == 'string')
|
|
131
|
-
_config.level = _config.methods.indexOf(_config.level);
|
|
132
|
-
|
|
133
|
-
_config.methods.forEach(function(title, i) {
|
|
134
|
-
if (i < _config.level)
|
|
135
|
-
_self[title] = noop;
|
|
136
|
-
else {
|
|
137
|
-
var format = _config.format[0];
|
|
138
|
-
if (_config.format.length === 2 && _config.format[1][title])
|
|
139
|
-
format = _config.format[1][title];
|
|
140
|
-
var needstack = /{{(method|path|line|pos|file|folder|stack)}}/i.test(format);
|
|
141
|
-
|
|
142
|
-
var filters;
|
|
143
|
-
if (lastFilter && lastFilter[title])
|
|
144
|
-
filters = Array.isArray(lastFilter[title]) ? lastFilter[title]
|
|
145
|
-
: [ lastFilter[title] ];
|
|
146
|
-
else
|
|
147
|
-
filters = _config.filters;
|
|
148
|
-
|
|
149
|
-
// interface
|
|
150
|
-
_self[title] = function() {
|
|
151
|
-
return logMain(_config, i, title, format, filters, needstack, arguments);
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
if(_config.supportConsoleMethods) {
|
|
157
|
-
Object.getOwnPropertyNames(console).forEach(function(title) {
|
|
158
|
-
if (!_self[title]) {
|
|
159
|
-
_self[title] = console[title];
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return _self;
|
|
165
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var fs = require('fs'), dateFormat = require('dateformat'), tinytim = require('tinytim'), utils = require('./utils'), spawn = require('child_process').spawn, spawnSync = require('child_process').spawnSync;
|
|
3
|
-
// var path = require('path');
|
|
4
|
-
var os = require('os');
|
|
5
|
-
var mkdirp = require('mkdirp');
|
|
6
|
-
|
|
7
|
-
function checkLogFile(path) {
|
|
8
|
-
if (os.type() === 'Windows_NT') {
|
|
9
|
-
if (!fs.existsSync(path)) {
|
|
10
|
-
mkdirp(path);
|
|
11
|
-
}
|
|
12
|
-
} else {
|
|
13
|
-
spawnSync('mkdir', ['-p', path]);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
module.exports = function (conf) {
|
|
18
|
-
var _conf = {
|
|
19
|
-
root: '.',
|
|
20
|
-
logPathFormat: '{{root}}/{{prefix}}.{{date}}.log',
|
|
21
|
-
splitFormat: 'yyyymmdd',
|
|
22
|
-
allLogsFileName: false,
|
|
23
|
-
maxLogFiles: 10
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
_conf = utils.union(_conf, [conf]);
|
|
27
|
-
|
|
28
|
-
function LogFile(prefix, date) {
|
|
29
|
-
this.date = date;
|
|
30
|
-
this.path = tinytim.tim(_conf.logPathFormat, { root: _conf.root, prefix: prefix, date: date });
|
|
31
|
-
checkLogFile(_conf.root);
|
|
32
|
-
this.stream = fs.createWriteStream(this.path, {
|
|
33
|
-
flags: "a",
|
|
34
|
-
encoding: "utf8",
|
|
35
|
-
mode: parseInt('0644', 8)
|
|
36
|
-
// When engines node >= 4.0.0, following notation will be better:
|
|
37
|
-
//mode: 0o644
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
LogFile.prototype.write = function (str) {
|
|
42
|
-
this.stream.write(str + "\n");
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
LogFile.prototype.destroy = function () {
|
|
46
|
-
if (this.stream) {
|
|
47
|
-
this.stream.end();
|
|
48
|
-
this.stream.destroySoon();
|
|
49
|
-
this.stream = null;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
var _logMap = {};
|
|
54
|
-
|
|
55
|
-
function _push2File(str, title) {
|
|
56
|
-
if (_conf.allLogsFileName) {
|
|
57
|
-
var allLogFile = _logMap.allLogFile, now = dateFormat(new Date(), _conf.splitFormat);
|
|
58
|
-
if (allLogFile && allLogFile.date != now) {
|
|
59
|
-
allLogFile.destroy();
|
|
60
|
-
allLogFile = null;
|
|
61
|
-
}
|
|
62
|
-
if (!allLogFile) {
|
|
63
|
-
allLogFile = _logMap.allLogFile = new LogFile(_conf.allLogsFileName, now);
|
|
64
|
-
spawn('find', [_conf.root, '-type', 'f', '-name', '*.log', '-mtime', '+' + _conf.maxLogFiles, '-exec', 'rm', '{}', ';']);
|
|
65
|
-
}
|
|
66
|
-
allLogFile.write(str);
|
|
67
|
-
} else {
|
|
68
|
-
var logFile = _logMap[title], nowAgain = dateFormat(new Date(), _conf.splitFormat);
|
|
69
|
-
if (logFile && logFile.date != nowAgain) {
|
|
70
|
-
logFile.destroy();
|
|
71
|
-
logFile = null;
|
|
72
|
-
}
|
|
73
|
-
if (!logFile) {
|
|
74
|
-
logFile = _logMap[title] = new LogFile(title, nowAgain);
|
|
75
|
-
spawn('find', [_conf.root, '-type', 'f', '-name', '*.log', '-mtime', '+' + _conf.maxLogFiles, '-exec', 'rm', '{}', ';']);
|
|
76
|
-
}
|
|
77
|
-
logFile.write(str);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function dailyFileTransport(data) {
|
|
82
|
-
_push2File(data.output, data.title);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (conf.transport) {
|
|
86
|
-
conf.transport = Array.isArray(conf.transport) ? conf.transport : [conf.transport];
|
|
87
|
-
conf.transport.push(dailyFileTransport)
|
|
88
|
-
} else {
|
|
89
|
-
conf.transport = [dailyFileTransport];
|
|
90
|
-
}
|
|
91
|
-
return require('./console')(conf);
|
|
92
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.console = require('./console');
|
|
3
|
-
exports.colorConsole = require('./color_console');
|
|
4
|
-
exports.dailyfile = require('./dailyfile');
|
|
5
|
-
|
|
6
|
-
//global settings
|
|
7
|
-
var settings = require('./settings');
|
|
8
|
-
exports.close = settings.close;
|
|
9
|
-
exports.setLevel = settings.setLevel;
|
|
10
|
-
exports.getLevel = settings.getLevel;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var settings = {
|
|
3
|
-
level : undefined
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
//end all of output
|
|
7
|
-
var close = function(){
|
|
8
|
-
settings.level = Number.MAX_VALUE;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
//dynamically change the log level, all of output
|
|
12
|
-
var setLevel = function(level){
|
|
13
|
-
settings.level = level;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
//get the current log level
|
|
17
|
-
var getLevel = function(){
|
|
18
|
-
return settings.level;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
exports.settings = settings;
|
|
23
|
-
exports.close = close;
|
|
24
|
-
exports.setLevel = setLevel;
|
|
25
|
-
exports.getLevel = getLevel;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.union = function(obj, args) {
|
|
3
|
-
for (var i = 0, len = args.length; i < len; i += 1) {
|
|
4
|
-
var source = args[i];
|
|
5
|
-
for ( var prop in source) {
|
|
6
|
-
obj[prop] = source[prop];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return obj;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
var formatRegExp = /%[sdjt]/g;
|
|
13
|
-
var util = require('util');
|
|
14
|
-
exports.format = function(f) {
|
|
15
|
-
var inspectOpt = this.inspectOpt;
|
|
16
|
-
var args = arguments;
|
|
17
|
-
var i = 0;
|
|
18
|
-
|
|
19
|
-
if (typeof f !== 'string') {
|
|
20
|
-
var objects = [];
|
|
21
|
-
for (; i < args.length; i++) {
|
|
22
|
-
objects.push(util.inspect(args[i], inspectOpt));
|
|
23
|
-
}
|
|
24
|
-
return objects.join(' ');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
i = 1;
|
|
28
|
-
var str = String(f).replace(formatRegExp, function(x) {
|
|
29
|
-
switch (x) {
|
|
30
|
-
case '%s':
|
|
31
|
-
return String(args[i++]);
|
|
32
|
-
case '%d':
|
|
33
|
-
return Number(args[i++]);
|
|
34
|
-
case '%j':
|
|
35
|
-
try {
|
|
36
|
-
if (args[i] instanceof Error) {
|
|
37
|
-
return JSON.stringify(args[i++], ['message', 'stack', 'type', 'name']);
|
|
38
|
-
} else {
|
|
39
|
-
return JSON.stringify(args[i++]);
|
|
40
|
-
}
|
|
41
|
-
} catch(e) {
|
|
42
|
-
return '[Circular]';
|
|
43
|
-
}
|
|
44
|
-
case '%t':
|
|
45
|
-
return util.inspect(args[i++], inspectOpt);
|
|
46
|
-
default:
|
|
47
|
-
return x;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
for ( var len = args.length, x = args[i]; i < len; x = args[++i]) {
|
|
51
|
-
if (x === null || typeof x !== 'object') {
|
|
52
|
-
str += ' ' + x;
|
|
53
|
-
} else {
|
|
54
|
-
str += ' ' + util.inspect(x, inspectOpt);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return str;
|
|
58
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tracer",
|
|
3
|
-
"description": "A powerful and customizable logging library for node.js. support color console with timestamp, line number, method name, file name and call stack. you can set transport to file, stream, database(ex: mongodb and clouddb, simpledb). keywords: log, logger, trace ",
|
|
4
|
-
"homepage": "http://github.com/baryon/tracer",
|
|
5
|
-
"repository": {
|
|
6
|
-
"type": "git",
|
|
7
|
-
"url": "git://github.com/baryon/tracer.git"
|
|
8
|
-
},
|
|
9
|
-
"version": "1.1.6",
|
|
10
|
-
"author": "LI Long <lilong@gmail.com>",
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"colors": "1.4.0",
|
|
14
|
-
"dateformat": "4.5.1",
|
|
15
|
-
"mkdirp": "^1.0.4",
|
|
16
|
-
"tinytim": "0.1.1"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"cli-color": "^2.0.0",
|
|
20
|
-
"dtslint": "^4.2.1",
|
|
21
|
-
"eslint": "^7.12.1",
|
|
22
|
-
"mocha": "^10.0.0",
|
|
23
|
-
"mongoskin": "^0.3.7",
|
|
24
|
-
"nyc": "^15.1.0",
|
|
25
|
-
"ssri": ">=6.0.2",
|
|
26
|
-
"tslint": "^6.1.3",
|
|
27
|
-
"typescript": "^4.0.5"
|
|
28
|
-
},
|
|
29
|
-
"main": "./lib/index",
|
|
30
|
-
"types": "./types/index.d.ts",
|
|
31
|
-
"keywords": [
|
|
32
|
-
"log",
|
|
33
|
-
"logger",
|
|
34
|
-
"trace",
|
|
35
|
-
"debug"
|
|
36
|
-
],
|
|
37
|
-
"scripts": {
|
|
38
|
-
"test": "mocha test/*",
|
|
39
|
-
"lint:fix": "eslint --fix .",
|
|
40
|
-
"lint": "eslint .",
|
|
41
|
-
"posttest": "npm run lint",
|
|
42
|
-
"test:coverage": "nyc npm run test",
|
|
43
|
-
"posttest:coverage": "npm run lint",
|
|
44
|
-
"dtslint": "dtslint types"
|
|
45
|
-
},
|
|
46
|
-
"files": [
|
|
47
|
-
"lib/*",
|
|
48
|
-
"types/index.d.ts"
|
|
49
|
-
],
|
|
50
|
-
"engines": {
|
|
51
|
-
"node": ">= 0.10.0"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// TypeScript Version: 2.6
|
|
2
|
-
|
|
3
|
-
export namespace Tracer {
|
|
4
|
-
export interface LogOutput {
|
|
5
|
-
/**
|
|
6
|
-
* Current time.
|
|
7
|
-
*/
|
|
8
|
-
timestamp: string;
|
|
9
|
-
/**
|
|
10
|
-
* The result of formating the template and arguments in `args`.
|
|
11
|
-
*/
|
|
12
|
-
message: string;
|
|
13
|
-
/**
|
|
14
|
-
* Method name, default is `log`, `trace`, `debug`, `info`, `warn`, `error`, `fatal`.
|
|
15
|
-
*/
|
|
16
|
-
title: string;
|
|
17
|
-
/**
|
|
18
|
-
* Method level, default is `log`: 0, `trace`: 1, `debug`: 2, `info`: 3, `warn`: 4, `error`: 5, `fatal`: 6.
|
|
19
|
-
*/
|
|
20
|
-
level: number;
|
|
21
|
-
/**
|
|
22
|
-
* Arguments of `Logger` method.
|
|
23
|
-
*/
|
|
24
|
-
args: any[];
|
|
25
|
-
/**
|
|
26
|
-
* Method name of caller.
|
|
27
|
-
*/
|
|
28
|
-
method: string;
|
|
29
|
-
/**
|
|
30
|
-
* File's path.
|
|
31
|
-
*/
|
|
32
|
-
path: string;
|
|
33
|
-
/**
|
|
34
|
-
* Line number.
|
|
35
|
-
*/
|
|
36
|
-
line: string;
|
|
37
|
-
/**
|
|
38
|
-
* Position.
|
|
39
|
-
*/
|
|
40
|
-
pos: string;
|
|
41
|
-
/**
|
|
42
|
-
* folder path.
|
|
43
|
-
*/
|
|
44
|
-
folder: string;
|
|
45
|
-
/**
|
|
46
|
-
* File's name.
|
|
47
|
-
*/
|
|
48
|
-
file: string;
|
|
49
|
-
/**
|
|
50
|
-
* Call stack message.
|
|
51
|
-
*/
|
|
52
|
-
stack: string;
|
|
53
|
-
/**
|
|
54
|
-
* The output to be written
|
|
55
|
-
*/
|
|
56
|
-
output: string;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Any custom keys
|
|
60
|
-
*/
|
|
61
|
-
[key: string]: any;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type LevelOption<T, M extends string> = Partial<Record<M, T>>
|
|
65
|
-
export type FilterFunction = (data: string) => string | boolean | null | void;
|
|
66
|
-
export type TransportFunction = (data: LogOutput) => void;
|
|
67
|
-
|
|
68
|
-
export interface LoggerConfig<M extends string = "log" | "trace" | "debug" | "info" | "warn" | "error" | "fatal"> {
|
|
69
|
-
/**
|
|
70
|
-
* Output format (Using `tinytim` templating)
|
|
71
|
-
*
|
|
72
|
-
* Defaults to: `"{{timestamp}} <{{title}}> {{file}}:{{line}} ({{method}}) {{message}}"`
|
|
73
|
-
*
|
|
74
|
-
* Possible values:
|
|
75
|
-
* - timestamp: current time
|
|
76
|
-
* - title: method name, default is 'log', 'trace', 'debug', 'info', 'warn', 'error','fatal'
|
|
77
|
-
* - level: method level, default is 'log':0, 'trace':1, 'debug':2, 'info':3, 'warn':4, 'error':5, 'fatal':6
|
|
78
|
-
* - message: printf message, support %s string, %d number, %j JSON and auto inspect
|
|
79
|
-
* - file: file name
|
|
80
|
-
* - line: line number
|
|
81
|
-
* - pos: position
|
|
82
|
-
* - path: file's path
|
|
83
|
-
* - method: method name of caller
|
|
84
|
-
* - stack: call stack message
|
|
85
|
-
*/
|
|
86
|
-
format?: string | [string, LevelOption<string, M>];
|
|
87
|
-
/**
|
|
88
|
-
* rootDir of folder path.
|
|
89
|
-
*/
|
|
90
|
-
rootDir?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Datetime format (Using `Date Format`)
|
|
93
|
-
*/
|
|
94
|
-
dateformat?: string;
|
|
95
|
-
filters?: FilterFunction[] | LevelOption<FilterFunction | FilterFunction[], M> | Array<FilterFunction | LevelOption<FilterFunction | FilterFunction[], M>>;
|
|
96
|
-
/**
|
|
97
|
-
* Output the log, if level of log larger than or equal to `level`.
|
|
98
|
-
*/
|
|
99
|
-
level?: string | number;
|
|
100
|
-
methods?: M[];
|
|
101
|
-
/**
|
|
102
|
-
* Get the specified index of stack as file information. It is useful for development package.
|
|
103
|
-
*/
|
|
104
|
-
stackIndex?: number;
|
|
105
|
-
inspectOpt?: {
|
|
106
|
-
/**
|
|
107
|
-
* If true then the object's non-enumerable properties will be shown too. Defaults to false.
|
|
108
|
-
*/
|
|
109
|
-
showHidden: boolean,
|
|
110
|
-
/**
|
|
111
|
-
* Tells inspect how many times to recurse while formatting the object.
|
|
112
|
-
* This is useful for inspecting large complicated objects.
|
|
113
|
-
* Defaults to 2. To make it recurse indefinitely pass null.
|
|
114
|
-
*/
|
|
115
|
-
depth: number | null
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Pre-process the log object.
|
|
120
|
-
*/
|
|
121
|
-
preprocess?(data: LogOutput): void;
|
|
122
|
-
/**
|
|
123
|
-
* Transport function (e.g. console.log)
|
|
124
|
-
*/
|
|
125
|
-
transport?: TransportFunction | TransportFunction[];
|
|
126
|
-
}
|
|
127
|
-
export interface DailyFileConfig {
|
|
128
|
-
/**
|
|
129
|
-
* All daily log file's dir, default to: `'.'`.
|
|
130
|
-
*/
|
|
131
|
-
root?: string;
|
|
132
|
-
/**
|
|
133
|
-
* Log file path format.
|
|
134
|
-
*
|
|
135
|
-
* Default to: `'{{root}}/{{prefix}}.{{date}}.log'`
|
|
136
|
-
*
|
|
137
|
-
* Possible values:
|
|
138
|
-
* - `root`: all daily log file's dir, default to: `'.'`.
|
|
139
|
-
* - `prefix`: it equal to `allLogsFileName`, if `allLogsFileName` is provided; else it will be the method name.
|
|
140
|
-
* - `date`: today's date.
|
|
141
|
-
*/
|
|
142
|
-
logPathFormat?: string;
|
|
143
|
-
/**
|
|
144
|
-
* Datetime format (Using `Date Format`)
|
|
145
|
-
*/
|
|
146
|
-
splitFormat?: string;
|
|
147
|
-
/**
|
|
148
|
-
* If `allLogsFileName` is provided then all level logs will be move to one daily log file.
|
|
149
|
-
*/
|
|
150
|
-
allLogsFileName?: boolean | string;
|
|
151
|
-
maxLogFiles?: number;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export type Logger<M extends string> = Record<M, (...args: any[]) => LogOutput>
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Create a console for printing color log.
|
|
159
|
-
* @param [config] Configurate how logs are printed.
|
|
160
|
-
*/
|
|
161
|
-
export function colorConsole<M extends string>(config?: Tracer.LoggerConfig<M>): Tracer.Logger<M>;
|
|
162
|
-
/**
|
|
163
|
-
* Create a console without color.
|
|
164
|
-
* @param [config] Configurate how logs are printed.
|
|
165
|
-
*/
|
|
166
|
-
export function console<M extends string>(config?: Tracer.LoggerConfig<M>): Tracer.Logger<M>;
|
|
167
|
-
/**
|
|
168
|
-
* DailyLog will output all types log to diff files every day like log4j.
|
|
169
|
-
* @param config Configurate how logs are printed & how log files are saved.
|
|
170
|
-
*/
|
|
171
|
-
export function dailyfile<M extends string>(config?: Tracer.LoggerConfig<M> & Tracer.DailyFileConfig): Tracer.Logger<M>;
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* End all the output.
|
|
175
|
-
*
|
|
176
|
-
* Equivalent to: `tracer.setLevel(Number.MAX_VALUE)`.
|
|
177
|
-
*/
|
|
178
|
-
export function close(): void;
|
|
179
|
-
/**
|
|
180
|
-
* Change the log level in run time, for all the output.
|
|
181
|
-
*
|
|
182
|
-
* Notice: If you set level in initialize, you can't change more lower level than the initial level.
|
|
183
|
-
* @param level Output the log, if level of log larger than or equal to `level`.
|
|
184
|
-
*/
|
|
185
|
-
export function setLevel(level: number | string): void;
|
|
186
|
-
/**
|
|
187
|
-
* Get the current log level.
|
|
188
|
-
*/
|
|
189
|
-
export function getLevel(): number | string;
|