main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[79a0317] | 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 | * @param {string} name name of the logger
|
---|
| 22 | * @returns {Logger} a logger
|
---|
| 23 | */
|
---|
| 24 | module.exports.getLogger = name =>
|
---|
| 25 | new Logger(
|
---|
| 26 | (type, args) => {
|
---|
| 27 | if (module.exports.hooks.log.call(name, type, args) === undefined) {
|
---|
| 28 | currentDefaultLogger(name, type, args);
|
---|
| 29 | }
|
---|
| 30 | },
|
---|
| 31 | childName => module.exports.getLogger(`${name}/${childName}`)
|
---|
| 32 | );
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
| 35 | * @param {createConsoleLogger.LoggerOptions} options new options, merge with old options
|
---|
| 36 | * @returns {void}
|
---|
| 37 | */
|
---|
| 38 | module.exports.configureDefaultLogger = options => {
|
---|
| 39 | Object.assign(currentDefaultLoggerOptions, options);
|
---|
| 40 | currentDefaultLogger = createConsoleLogger(currentDefaultLoggerOptions);
|
---|
| 41 | };
|
---|
| 42 |
|
---|
| 43 | module.exports.hooks = {
|
---|
| 44 | log: new SyncBailHook(["origin", "type", "args"])
|
---|
| 45 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.