|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
|---|
| 3 | Author Tobias Koppers @sokra
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | "use strict";
|
|---|
| 7 |
|
|---|
| 8 | const { SyncBailHook } = require("tapable");
|
|---|
| 9 | const { Logger } = require("./Logger");
|
|---|
| 10 | const createConsoleLogger = require("./createConsoleLogger");
|
|---|
| 11 |
|
|---|
| 12 | /** @type {createConsoleLogger.LoggerOptions} */
|
|---|
| 13 | const currentDefaultLoggerOptions = {
|
|---|
| 14 | level: "info",
|
|---|
| 15 | debug: false,
|
|---|
| 16 | console
|
|---|
| 17 | };
|
|---|
| 18 | let currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
|---|
| 19 |
|
|---|
| 20 | /**
|
|---|
| 21 | * Processes the provided create console logger.logger option.
|
|---|
| 22 | * @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
|---|
| 23 | * @returns {void}
|
|---|
| 24 | */
|
|---|
| 25 | module.exports.configureDefaultLogger = (options) => {
|
|---|
| 26 | Object.assign(currentDefaultLoggerOptions, options);
|
|---|
| 27 | currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | /**
|
|---|
| 31 | * Returns a logger.
|
|---|
| 32 | * @param {string} name name of the logger
|
|---|
| 33 | * @returns {Logger} a logger
|
|---|
| 34 | */
|
|---|
| 35 | module.exports.getLogger = (name) =>
|
|---|
| 36 | new Logger(
|
|---|
| 37 | (type, args) => {
|
|---|
| 38 | if (module.exports.hooks.log.call(name, type, args) === undefined) {
|
|---|
| 39 | currentDefaultLogger(name, type, args);
|
|---|
| 40 | }
|
|---|
| 41 | },
|
|---|
| 42 | (childName) => module.exports.getLogger(`${name}/${childName}`)
|
|---|
| 43 | );
|
|---|
| 44 |
|
|---|
| 45 | module.exports.hooks = {
|
|---|
| 46 | log: new SyncBailHook(["origin", "type", "args"])
|
|---|
| 47 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.