exports_infrastructure.js

/**
 * @file src/exports/cache.js
 * @copyright @spmhome @_2025
 * @author Scott Meesseman @spmeesseman
 *
 * @see {@link https://webpack.js.org/configuration/infrastructure webpack.js.org/infrastructure}
 *
 *//** */

const WpwWebpackExport = require("./base");
// const SpmhWebpackConsole = require("../log/wpconsole");


/**
 * @augments WpwWebpackExport
 */
class WpwInfrastructureLoggingExport extends WpwWebpackExport
{
    /**
     * @param {WpwExportOptions} options Plugin options
     */
    constructor(options) { super(options); }


    /**
     * @override
     */
    static create = WpwInfrastructureLoggingExport.wrap.bind(this);


    /**
     * @override
     */
    create()
    {
        const build = this.build,
              logLevel = build.logger.level;

        build.wpc.infrastructureLogging = {
            colors: true,
            // console: new SpmhWebpackConsole(build.logger),
            level: build.logger.toWpLogLevel(build.logger.isLogLevel(logLevel) ? logLevel : "warn")
        };

        if (logLevel === 5)
        {
            build.wpc.stats.all = true;
            build.wpc.infrastructureLogging.debug = true;
        }

        build.logger.write(`configured logging level is '${build.wpc.infrastructureLogging.level}' [${logLevel}]`, 1);
    }
}


module.exports = WpwInfrastructureLoggingExport.create;