1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const level_1 = require("./level");
|
4 | const helper_1 = require("./helper");
|
5 | const backend_logging_1 = require("./backend-logging");
|
6 | if (helper_1.isNode) {
|
7 |
|
8 | var chalk = require('chalk');
|
9 | var path = require('path');
|
10 |
|
11 | }
|
12 | class Display {
|
13 | static msg(message, params, moduleName, moduleColor, level, moduleWidth) {
|
14 | let color = 'gray';
|
15 | if (level === level_1.Level.INFO)
|
16 | color = 'deepskyblue';
|
17 | if (level === level_1.Level.ERROR)
|
18 | color = 'red';
|
19 | if (level === level_1.Level.WARN)
|
20 | color = 'orange';
|
21 | if (moduleWidth) {
|
22 | const diff = moduleWidth - moduleName.length;
|
23 | if (diff > 0) {
|
24 | for (let i = 0; i < diff; i++) {
|
25 | moduleName += ' ';
|
26 | }
|
27 | }
|
28 | }
|
29 | if (helper_1.isBrowser) {
|
30 | if (typeof message === 'string') {
|
31 | let a1 = '%c ' + moduleName + ' %c ' + message + ' ';
|
32 | let a2 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + moduleColor + '; ';
|
33 | let a3 = 'border: 1px solid ' + color + '; ';
|
34 | params.unshift(a3);
|
35 | params.unshift(a2);
|
36 | params.unshift(a1);
|
37 | }
|
38 | else {
|
39 | let a1 = '%c ' + moduleName + ' ';
|
40 | let a2 = 'background: ' + moduleColor + ';color:white; border: 1px solid ' + color + '; ';
|
41 | params.push(message);
|
42 | params.unshift(a2);
|
43 | params.unshift(a1);
|
44 | }
|
45 | console.log.apply(console, params);
|
46 | }
|
47 | if (helper_1.isNode) {
|
48 | let a1 = chalk.bgHex(moduleColor)(chalk.black(moduleName));
|
49 | let p = params;
|
50 | if (typeof message === 'string') {
|
51 | a1 = a1 + chalk.keyword(color)(' [') + chalk.dim(message) + chalk.keyword(color)('] ');
|
52 | }
|
53 | else {
|
54 | p = [message].concat(params);
|
55 | }
|
56 | backend_logging_1.consoleLog(a1, level);
|
57 | backend_logging_1.displayParams(p, level);
|
58 | }
|
59 | }
|
60 | }
|
61 | exports.Display = Display;
|
62 |
|
\ | No newline at end of file |