| | |
| | | /** @typedef {(value: string, type: LogTypeEnum, args?: Args) => void} LoggingFunction */ |
| | | |
| | | /** |
| | | * Defines the logger console type used by this module. |
| | | * @typedef {object} LoggerConsole |
| | | * @property {() => void} clear |
| | | * @property {() => void} trace |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Defines the logger options type used by this module. |
| | | * @typedef {object} LoggerOptions |
| | | * @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel |
| | | * @property {FilterTypes|boolean} debug filter for debug logging |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Filter to function. |
| | | * @param {FilterItemTypes} item an input item |
| | | * @returns {FilterFunction | undefined} filter function |
| | | */ |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Enumerates the available values. |
| | | * @enum {number} |
| | | */ |
| | | const LogLevel = { |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns logging function. |
| | | * @param {LoggerOptions} options options object |
| | | * @returns {LoggingFunction} logging function |
| | | */ |
| | |
| | | const loglevel = LogLevel[`${level}`] || 0; |
| | | |
| | | /** |
| | | * Processes the provided name. |
| | | * @param {string} name name of the logger |
| | | * @param {LogTypeEnum} type type of the log entry |
| | | * @param {Args=} args arguments of the log entry |
| | | * @returns {void} |
| | | */ |
| | | const logger = (name, type, args) => { |
| | | /** |
| | | * Returns labeled args. |
| | | * @template T |
| | | * @returns {[string?, ...T[]]} labeled args |
| | | */ |
| | | const labeledArgs = () => { |
| | | if (Array.isArray(args)) { |
| | | if (args.length > 0 && typeof args[0] === "string") { |