1 | var _time = require("dr-js/library/common/time");
|
2 | var _format = require("dr-js/library/common/format");
|
3 | var _main = require("./main");
|
4 | const EMPTY_FUNC = () => {};
|
5 | exports.getLogger = ((title = "dev-dep", quiet = !1, padWidth = 120) => {
|
6 | const envTitle = (0, _main.loadEnvKey)("__DEV_LOGGER_TITLE__");
|
7 | title = envTitle ? `${title}|${envTitle}` : title;
|
8 | (0, _main.saveEnvKey)("__DEV_LOGGER_TITLE__", title);
|
9 | const startTime = (0, _time.clock)();
|
10 | let prevTime = (0, _time.clock)();
|
11 | const stepLog = (...args) => console.log(`- (+${(() => {
|
12 | const time = (0, _time.clock)();
|
13 | const stepTime = time - prevTime;
|
14 | prevTime = time;
|
15 | return (0, _format.time)(stepTime);
|
16 | })()}) ${args.join(" ")}`);
|
17 | const log = (...args) => console.log(`- ${args.join(" ")}`);
|
18 | const devLog = _main.__VERBOSE__ ? log : EMPTY_FUNC;
|
19 | return quiet ? {
|
20 | padLog: stepLog,
|
21 | stepLog: devLog,
|
22 | log: devLog,
|
23 | devLog: EMPTY_FUNC
|
24 | } : {
|
25 | padLog: (...args) => {
|
26 | const start = `## ${args.join(" ")} `;
|
27 | const end = ` [${title}|${(() => {
|
28 | const time = (0, _time.clock)();
|
29 | prevTime = time;
|
30 | return (0, _format.time)(time - startTime);
|
31 | })()}]`;
|
32 | console.log(`\n${start.padEnd(padWidth - end.length, "-")}${end}`);
|
33 | },
|
34 | stepLog,
|
35 | log,
|
36 | devLog
|
37 | };
|
38 | }); |
\ | No newline at end of file |