// SPDX-FileCopyrightText: 2021 Johannes Loher // // SPDX-License-Identifier: MIT 'use strict'; const loggingContext = 'DDV'; const loggingSeparator = '|'; /** * @typedef {'debug' | 'info' | 'warning' | 'error'} LogLevel */ /** * @typedef {(...args: unknown[]) => void} LoggingFunction */ /** * @param {LogLevel} [type = 'info'] - The log level of the requested logger * @returns {LoggingFunction} */ function getLoggingFunction(type = 'info') { const log = { debug: console.debug, info: console.info, warning: console.warn, error: console.error }[type]; return (...data) => log(loggingContext, loggingSeparator, ...data); } const logger = Object.freeze({ debug: getLoggingFunction('debug'), info: getLoggingFunction('info'), warn: getLoggingFunction('warn'), error: getLoggingFunction('error'), getLoggingFunction, }); export default logger;