improve logging

This commit is contained in:
Ean Milligan 2025-08-06 15:04:30 -04:00
parent 2cfa923093
commit 59d4435c32
2 changed files with 5 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import { QueuedRoll } from 'artigen/managers/manager.d.ts';
import { reduceCountDetails } from 'artigen/utils/counter.ts'; import { reduceCountDetails } from 'artigen/utils/counter.ts';
import { cmdSplitRegex, escapeCharacters, withYVarsDash } from 'artigen/utils/escape.ts'; import { cmdSplitRegex, escapeCharacters, withYVarsDash } from 'artigen/utils/escape.ts';
import { loggingEnabled, loopLoggingEnabled } from 'artigen/utils/logFlag.ts'; import { loggingEnabled, showLoopCountDebug } from 'artigen/utils/logFlag.ts';
import { assertPrePostBalance } from 'artigen/utils/parenBalance.ts'; import { assertPrePostBalance } from 'artigen/utils/parenBalance.ts';
import { reduceRollDistMaps } from 'artigen/utils/rollDist.ts'; import { reduceRollDistMaps } from 'artigen/utils/rollDist.ts';
import { compareTotalRolls, compareTotalRollsReverse, sortYVars } from 'artigen/utils/sortFuncs.ts'; import { compareTotalRolls, compareTotalRollsReverse, sortYVars } from 'artigen/utils/sortFuncs.ts';
@ -179,7 +179,7 @@ export const runCmd = (rollRequest: QueuedRoll): SolvedRoll => {
[returnMsg.errorCode, returnMsg.errorMsg] = translateError(solverError); [returnMsg.errorCode, returnMsg.errorMsg] = translateError(solverError);
} }
if (loopLoggingEnabled) returnMsg.footer = `Loop Count: ${getLoopCount()}`; if (showLoopCountDebug) returnMsg.footer = `Loop Count: ${getLoopCount()}`;
return returnMsg; return returnMsg;
}; };

View File

@ -95,12 +95,13 @@ export const mathSolver = (conf: MathConf[], wrapDetails = false): SolvedStep =>
]; ];
allCurOps.forEach((curOps) => { allCurOps.forEach((curOps) => {
// No loopCountCheck here since its finite/will always be 3 loops // No loopCountCheck here since its finite/will always be 3 loops
loggingEnabled && log(LT.LOG, `Evaluating roll ${JSON.stringify(conf)} | Evaluating ${JSON.stringify(curOps)}`); loggingEnabled && log(LT.LOG, `Cur Ops ${JSON.stringify(curOps)}`);
// Iterate thru all operators/operands in the conf // Iterate thru all operators/operands in the conf
for (let i = 0; i < conf.length; i++) { for (let i = 0; i < conf.length; i++) {
loggingEnabled && log(LT.LOG, `Evaluating roll ${JSON.stringify(conf)} | Evaluating ${JSON.stringify(curOps)} | Checking ${JSON.stringify(conf[i])}`); loggingEnabled && log(LT.LOG, `Checking ${JSON.stringify(conf[i])}`);
// Check if the current index is in the active tier of operators // Check if the current index is in the active tier of operators
if (curOps.includes(conf[i].toString())) { if (curOps.includes(conf[i].toString())) {
loggingEnabled && log(LT.LOG, `Evaluating roll ${JSON.stringify(conf)} as ${JSON.stringify(conf[i])} is in curOps`);
loopCountCheck('mathSolver.ts - evaluating roll'); loopCountCheck('mathSolver.ts - evaluating roll');
// Grab the operands from before and after the operator // Grab the operands from before and after the operator
const operand1 = conf[i - 1]; const operand1 = conf[i - 1];