source: trip-planner-front/node_modules/webpack/hot/log.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.3 KB
Line 
1var logLevel = "info";
2
3function dummy() {}
4
5function shouldLog(level) {
6 var shouldLog =
7 (logLevel === "info" && level === "info") ||
8 (["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") ||
9 (["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error");
10 return shouldLog;
11}
12
13function logGroup(logFn) {
14 return function (level, msg) {
15 if (shouldLog(level)) {
16 logFn(msg);
17 }
18 };
19}
20
21module.exports = function (level, msg) {
22 if (shouldLog(level)) {
23 if (level === "info") {
24 console.log(msg);
25 } else if (level === "warning") {
26 console.warn(msg);
27 } else if (level === "error") {
28 console.error(msg);
29 }
30 }
31};
32
33/* eslint-disable node/no-unsupported-features/node-builtins */
34var group = console.group || dummy;
35var groupCollapsed = console.groupCollapsed || dummy;
36var groupEnd = console.groupEnd || dummy;
37/* eslint-enable node/no-unsupported-features/node-builtins */
38
39module.exports.group = logGroup(group);
40
41module.exports.groupCollapsed = logGroup(groupCollapsed);
42
43module.exports.groupEnd = logGroup(groupEnd);
44
45module.exports.setLogLevel = function (level) {
46 logLevel = level;
47};
48
49module.exports.formatError = function (err) {
50 var message = err.message;
51 var stack = err.stack;
52 if (!stack) {
53 return message;
54 } else if (stack.indexOf(message) < 0) {
55 return message + "\n" + stack;
56 } else {
57 return stack;
58 }
59};
Note: See TracBrowser for help on using the repository browser.