Skip to content

Commit 30f5446

Browse files
committed
Replace loglevel logging with console logging for temporary debugging
1 parent 0660683 commit 30f5446

4 files changed

Lines changed: 71 additions & 45 deletions

File tree

src/FEAScript.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@ export class FEAScriptModel {
2626
this.meshConfig = {};
2727
this.boundaryConditions = {};
2828
this.solverMethod = "lusolve"; // Default solver method
29-
log.info("FEAScriptModel instance created");
29+
console.log("FEAScriptModel instance created");
3030
}
3131

3232
setSolverConfig(solverConfig) {
3333
this.solverConfig = solverConfig;
34-
log.debug(`Solver config set to: ${solverConfig}`);
34+
console.log(`Solver config set to: ${solverConfig}`);
3535
}
3636

3737
setMeshConfig(meshConfig) {
3838
this.meshConfig = meshConfig;
39-
log.debug(`Mesh config set with dimensions: ${meshConfig.meshDimension}, elements: ${meshConfig.numElementsX}x${meshConfig.numElementsY || 1}`);
39+
console.log(`Mesh config set with dimensions: ${meshConfig.meshDimension}, elements: ${meshConfig.numElementsX}x${meshConfig.numElementsY || 1}`);
4040
}
4141

4242
addBoundaryCondition(boundaryKey, condition) {
4343
this.boundaryConditions[boundaryKey] = condition;
44-
log.debug(`Boundary condition added for key: ${boundaryKey}, type: ${condition[0]}`);
44+
console.log(`Boundary condition added for key: ${boundaryKey}, type: ${condition[0]}`);
4545
}
4646

4747
setSolverMethod(solverMethod) {
4848
this.solverMethod = solverMethod;
49-
log.debug(`Solver method set to: ${solverMethod}`);
49+
console.log(`Solver method set to: ${solverMethod}`);
5050
}
5151

5252
solve() {
5353
if (!this.solverConfig || !this.meshConfig || !this.boundaryConditions) {
5454
const error = "Solver config, mesh config, and boundary conditions must be set before solving.";
55-
log.error(error);
55+
console.error(error);
5656
throw new Error(error);
5757
}
5858

@@ -62,26 +62,26 @@ export class FEAScriptModel {
6262
let nodesCoordinates = {}; // Object to store x and y coordinates of nodes
6363

6464
// Assembly matrices
65-
log.info("Beginning matrix assembly...");
65+
console.log("Beginning matrix assembly...");
6666
console.time("assemblyMatrices");
6767
if (this.solverConfig === "solidHeatTransferScript") {
68-
log.info(`Using solver: ${this.solverConfig}`);
68+
console.log(`Using solver: ${this.solverConfig}`);
6969
({ jacobianMatrix, residualVector, nodesCoordinates } = assembleSolidHeatTransferMat(
7070
this.meshConfig,
7171
this.boundaryConditions
7272
));
7373
}
7474
console.timeEnd("assemblyMatrices");
75-
log.info("Matrix assembly completed");
75+
console.log("Matrix assembly completed");
7676

7777
// System solving
78-
log.info(`Solving system using ${this.solverMethod}...`);
78+
console.log(`Solving system using ${this.solverMethod}...`);
7979
console.time("systemSolving");
8080
if (this.solverMethod === "lusolve") {
8181
solutionVector = math.lusolve(jacobianMatrix, residualVector); // Solve the system of linear equations using LU decomposition
8282
}
8383
console.timeEnd("systemSolving");
84-
log.info("System solved successfully");
84+
console.log("System solved successfully");
8585

8686
// Return the solution matrix and nodes coordinates
8787
return {

src/solvers/solidHeatTransferScript.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const log = loggers.solver;
2626
* - nodesCoordinates: Object containing x and y coordinates of nodes
2727
*/
2828
export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
29-
log.info("Starting solid heat transfer matrix assembly");
29+
// log.info("Starting solid heat transfer matrix assembly");
30+
console.log("Starting solid heat transfer matrix assembly");
3031

3132
// Extract mesh details from the configuration object
3233
const {
@@ -38,7 +39,8 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
3839
elementOrder, // The order of elements
3940
} = meshConfig;
4041

41-
log.debug(`Mesh configuration: ${meshDimension}, Elements: ${numElementsX}x${numElementsY || 1}, Size: ${maxX}x${maxY || 0}, Order: ${elementOrder}`);
42+
// log.debug(`Mesh configuration: ${meshDimension}, Elements: ${numElementsX}x${numElementsY || 1}, Size: ${maxX}x${maxY || 0}, Order: ${elementOrder}`);
43+
console.log(`Mesh configuration: ${meshDimension}, Elements: ${numElementsX}x${numElementsY || 1}, Size: ${maxX}x${maxY || 0}, Order: ${elementOrder}`);
4244

4345
// Extract boundary conditions from the configuration object
4446
let convectionHeatTranfCoeff = [];
@@ -48,12 +50,14 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
4850
if (boundaryCondition[0] === "convection") {
4951
convectionHeatTranfCoeff[key] = boundaryCondition[1];
5052
convectionExtTemp[key] = boundaryCondition[2];
51-
log.debug(`Convection boundary condition on boundary ${key}: h=${boundaryCondition[1]}, T=${boundaryCondition[2]}`);
53+
// log.debug(`Convection boundary condition on boundary ${key}: h=${boundaryCondition[1]}, T=${boundaryCondition[2]}`);
54+
console.log(`Convection boundary condition on boundary ${key}: h=${boundaryCondition[1]}, T=${boundaryCondition[2]}`);
5255
}
5356
});
5457

5558
// Create a new instance of the meshGeneration class
56-
log.debug("Generating mesh...");
59+
// log.debug("Generating mesh...");
60+
console.log("Generating mesh...");
5761
const meshGenerationData = new meshGeneration({
5862
numElementsX,
5963
numElementsY,
@@ -65,7 +69,8 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
6569

6670
// Generate the mesh
6771
const nodesCoordinatesAndNumbering = meshGenerationData.generateMesh();
68-
log.debug("Mesh generated successfully");
72+
// log.debug("Mesh generated successfully");
73+
console.log("Mesh generated successfully");
6974

7075
// Extract nodes coordinates and nodal numbering (NOP) from the mesh data
7176
let nodesXCoordinates = nodesCoordinatesAndNumbering.nodesXCoordinates;
@@ -78,7 +83,8 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
7883
// Initialize variables for matrix assembly
7984
const totalElements = numElementsX * (meshDimension === "2D" ? numElementsY : 1); // Total number of elements
8085
const totalNodes = totalNodesX * (meshDimension === "2D" ? totalNodesY : 1); // Total number of nodes
81-
log.debug(`Total elements: ${totalElements}, Total nodes: ${totalNodes}`);
86+
// log.debug(`Total elements: ${totalElements}, Total nodes: ${totalNodes}`);
87+
console.log(`Total elements: ${totalElements}, Total nodes: ${totalNodes}`);
8288

8389
// Initialize variables for matrix assembly
8490
let localNodalNumbers = []; // Local nodal numbering
@@ -109,14 +115,16 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
109115
}
110116

111117
// Initialize the basisFunctions class
112-
log.debug("Initializing basis functions...");
118+
// log.debug("Initializing basis functions...");
119+
console.log("Initializing basis functions...");
113120
const basisFunctionsData = new basisFunctions({
114121
meshDimension,
115122
elementOrder,
116123
});
117124

118125
// Initialize the numericalIntegration class
119-
log.debug("Setting up numerical integration...");
126+
// log.debug("Setting up numerical integration...");
127+
console.log("Setting up numerical integration...");
120128
const numIntegrationData = new numericalIntegration({
121129
meshDimension,
122130
elementOrder,
@@ -130,7 +138,8 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
130138
// Determine the number of nodes in the reference element based on the first element in the nop array
131139
const numNodes = nop[0].length;
132140

133-
log.info(`Beginning matrix assembly for ${totalElements} elements...`);
141+
// log.info(`Beginning matrix assembly for ${totalElements} elements...`);
142+
console.log(`Beginning matrix assembly for ${totalElements} elements...`);
134143

135144
// Matrix assembly
136145
for (let elementIndex = 0; elementIndex < totalElements; elementIndex++) {
@@ -253,7 +262,8 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
253262
}
254263

255264
// Create an instance of ThermalBoundaryConditions
256-
log.debug("Applying thermal boundary conditions...");
265+
// log.debug("Applying thermal boundary conditions...");
266+
console.log("Applying thermal boundary conditions...");
257267
const thermalBoundaryConditions = new ThermalBoundaryConditions(
258268
boundaryConditions,
259269
boundaryElements,
@@ -274,13 +284,16 @@ export function assembleSolidHeatTransferMat(meshConfig, boundaryConditions) {
274284
convectionHeatTranfCoeff,
275285
convectionExtTemp
276286
);
277-
log.debug("Convection boundary conditions applied");
287+
// log.debug("Convection boundary conditions applied");
288+
console.log("Convection boundary conditions applied");
278289

279290
// Impose ConstantTemp boundary conditions
280291
thermalBoundaryConditions.imposeConstantTempBoundaryConditions(residualVector, jacobianMatrix);
281-
log.debug("Constant temperature boundary conditions applied");
292+
// log.debug("Constant temperature boundary conditions applied");
293+
console.log("Constant temperature boundary conditions applied");
282294

283-
log.info("Solid heat transfer matrix assembly completed");
295+
// log.info("Solid heat transfer matrix assembly completed");
296+
console.log("Solid heat transfer matrix assembly completed");
284297

285298
return {
286299
jacobianMatrix,

src/utilities/loggerScript.js

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,35 @@
88
// |_| | |_ //
99
// Website: https://feascript.com/ \__| //
1010

11-
// Import loglevel - since it's using CommonJS exports, we need to import it as a namespace
12-
import * as logModule from '../../third-party/loglevel.min.js';
11+
// TEMPORARILY DISABLED LOGLEVEL IMPORT DUE TO MODULE LOADING ISSUES
12+
// import * as logModule from '../../third-party/loglevel.min.js';
13+
// const log = logModule.default || logModule;
1314

14-
// Access the main log object
15-
const log = logModule.default || logModule;
16-
17-
// Configure default log level (can be overridden)
18-
log.setDefaultLevel(log.levels.INFO);
15+
// Create a simple no-op logger to replace loglevel temporarily
16+
const createNoOpLogger = (name) => {
17+
return {
18+
name,
19+
trace: () => {},
20+
debug: () => {},
21+
info: () => {},
22+
warn: () => {},
23+
error: () => {},
24+
setLevel: () => {}
25+
};
26+
};
1927

20-
// Create namespace-specific loggers for different parts of the app
28+
// Mock loggers with no-op functions
2129
const loggers = {
22-
main: log.getLogger('FEAScript'),
23-
solver: log.getLogger('Solver'),
24-
mesh: log.getLogger('Mesh'),
25-
visualization: log.getLogger('Viz')
30+
main: createNoOpLogger('FEAScript'),
31+
solver: createNoOpLogger('Solver'),
32+
mesh: createNoOpLogger('Mesh'),
33+
visualization: createNoOpLogger('Viz')
2634
};
2735

28-
// Helper method to set all loggers to a specific level
29-
export function setAllLogLevels(level) {
30-
Object.values(loggers).forEach(logger => logger.setLevel(level));
36+
// Helper method (no-op)
37+
export function setAllLogLevels() {
38+
// No-op function
3139
}
3240

33-
// Export the configured loggers
41+
// Export the mock loggers
3442
export default loggers;

src/utilities/utilitiesScript.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ const log = loggers.main;
1616
* Function to handle version information and fetch the latest update date and release from GitHub
1717
*/
1818
export async function printVersion() {
19-
log.info("Fetching latest FEAScript version information...");
19+
// log.info("Fetching latest FEAScript version information...");
20+
console.log("Fetching latest FEAScript version information...");
2021
try {
2122
// Fetch the latest commit date
2223
const commitResponse = await fetch("https://api.github.com/repos/FEAScript/FEAScript/commits/main");
2324
const commitData = await commitResponse.json();
2425
const latestCommitDate = new Date(commitData.commit.committer.date).toLocaleString();
25-
log.info(`Latest FEAScript update: ${latestCommitDate}`);
26+
// log.info(`Latest FEAScript update: ${latestCommitDate}`);
27+
console.log(`Latest FEAScript update: ${latestCommitDate}`);
2628
return latestCommitDate;
2729
} catch (error) {
28-
log.error("Failed to fetch version information:", error);
30+
// log.error("Failed to fetch version information:", error);
31+
console.error("Failed to fetch version information:", error);
2932
return "Version information unavailable";
3033
}
3134
}
@@ -35,6 +38,8 @@ export async function printVersion() {
3538
* @param {string} level - The log level to set (trace, debug, info, warn, error)
3639
*/
3740
export function setLogLevel(level) {
38-
loggers.setAllLogLevels(level);
39-
log.info(`Log level set to: ${level}`);
41+
// Logging is temporarily disabled
42+
// loggers.setAllLogLevels(level);
43+
// log.info(`Log level set to: ${level}`);
44+
console.log(`Log level set to: ${level} (logging temporarily disabled)`);
4045
}

0 commit comments

Comments
 (0)