/**
* @file lib/log/logcolors.js
* @copyright @spmhome @_2025
* @author Scott Meesseman @spmeesseman
*/
const { isNulled } = require("@spmhome/type-utils");
const WpwLogger = require("./log");
/**
* @implements {WebpackLogger}
*/
class SpmhWebpackConsole
{
/**
* @type {NodeJS.WriteStream}
*/
_stdout;
/**
* @type {NodeJS.WriteStream}
*/
_stderr;
/**
* @type {boolean}
*/
_ignoreErrors = false;
/**
* @type {WpwLogger}
*/
logger;
/**
* @type {Record<string, number>}
*/
counts = {};
/**
* @type {ConsoleConstructor}
*/
Console = this.constructor.prototype;
// /**
// * @type {import("console").ConsoleConstructor}
// */
// Console = this.constructor.prototype;
// prototype = this.constructor.prototype;s
/**
* @class
* @param {WpwLogger} logger
*/
constructor(logger)
{
this.logger = logger;
this._stdout = process.stdout;
this._stderr = process.stderr;
}
/**
* @class
* @param {NodeJS.WriteStream} stdout
* @param {NodeJS.WriteStream} [stderr]
* @param {boolean} [ignoreErrors]
*/
new(stdout, stderr, ignoreErrors)
{
this._stdout = stdout;
this._stderr = stderr;
this._ignoreErrors = ignoreErrors;
this.logger = /** @type {WpwLogger} */(
WpwLogger.getLoggerInst({ envTag1: "external", envTag2: "webpack", color: "hotpink" })
);
}
/**
* @param {any} _value
* @param {string} [_message]
* @param {...any[]} [_optionalParams]
*/
assert(_value, _message, ..._optionalParams) {}
clear() {}
/**
* @param {string} [label]
*/
count(label)
{
if (isNulled(label)) {
label = "undefined__null";
}
if (!this.counts[label]) {
this.counts[label] = 0;
}
return ++this.counts[label];
}
/**
* @param {string} [label]
*/
countReset(label)
{
if (isNulled(label)) {
label = "undefined__null";
}
if (!this.counts[label]) {
this.counts[label] = 1;
}
--this.counts[label];
}
/**
* @param {any} [_message]
* @param {...any} [_optionalParams]
*/
debug(_message, ..._optionalParams) {}
/**
* @param {any} _obj
* @param {any} [_inspectOptions]
*/
dir(_obj, _inspectOptions) {}
/**
* @param {any[]} _data
*/
dirxml(..._data) {}
/**
* @param {any} message
* @param {...any} optionalParams
*/
error(message, ...optionalParams)
{
const icon = this.logger.icons.color.error;
this.logger.write(message, 1,WpwLogger.lastPad, icon, null, false, null, [ "webpack" ]);
this.logger.value(" additional parameters", optionalParams, 1, WpwLogger.lastPad, icon, null, [ "webpack" ]);
}
/**
* @param {string | any} _arg
*/
getChildLogger(_arg) { return new SpmhWebpackConsole(this.logger); }
/**
* @param {...any} _label
*/
group(..._label) {}
/**
* @param {...any} _label
*/
groupCollapsed(..._label) {}
groupEnd() {}
/**
* @param {any} message
* @param {...any} optionalParams
*/
info(message, ...optionalParams)
{
this.logger.write(message, 1,WpwLogger.lastPad, null, null, false, null, [ "webpack" ]);
this.logger.value(" additional parameters", optionalParams, 1, WpwLogger.lastPad, null, null, [ "webpack" ]);
}
/**
* @param {any} message
* @param {...any} optionalParams
*/
log(message, ...optionalParams)
{
this.logger.write(message, 1, WpwLogger.lastPad, null, null, false, null, [ "webpack" ]);
this.logger.value(" additional parameters", optionalParams, 1, WpwLogger.lastPad, null, null, [ "webpack" ]);
}
/**
* @param {string} fnName
*/
notImplemented(fnName)
{
const icon = this.logger.icons.color.warn;
this.logger.write(
`webpack console interface function '${fnName}' is not yet implemented`,
1, WpwLogger.lastPad, icon, null, false, null, [ "webpack" ]
);
}
/**
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
* // ┌─────────┬─────┐
* // │ (index) │ a │
* // ├─────────┼─────┤
* // │ 0 │ 1 │
* // │ 1 │ 'Z' │
* // └─────────┴─────┘
*/
/**
* @param {Record<string, string|number|boolean>} _tabularData
* @param {Readonly<string[]>} [_properties] alternate properties for constructing the table
*/
table(_tabularData, _properties) {}
/**
* @param {string} [_label]
*/
time(_label) {}
/**
* @param {string} [_label]
*/
timeEnd(_label) {}
/**
* @param {string} [_label]
* @param {...any} _data
*/
timeLog(_label, ..._data) {}
/**
* @param {string} pct
* @param {string} msg
* @param {...unknown} _args
*/
status(pct, msg, ..._args)
{
this.logger.valuestar(msg, `progress::[italic(${pct})]`, 1);
}
timeAggregate(_label) {}
timeAggregateEnd(_label) {}
trace() {}
/**
* @param {any} message
* @param {...any} optionalParams
*/
warn(message, ...optionalParams)
{
const icon = this.logger.icons.color.warn;
this.logger.write(message, 1, WpwLogger.lastPad, icon, null, false, null, [ "webpack" ]);
this.logger.value(" additional parameters", optionalParams, 1, WpwLogger.lastPad, icon, null, [ "webpack" ]);
}
/**
* @param {string} [_label]
*/
profile(_label) {}
/**
* @param {string} [_label]
*/
profileEnd(_label) {}
/**
* @param {string} [_label]
*/
timeStamp(_label) {}
}
module.exports = SpmhWebpackConsole;