Simple bug zapping for your node application.
const BugZapper = require("bugzapper");
const bz = new BugZapper({
showFileName: true
});
function checkDoor(isBarred) {
bz.var({isBarred})
if (isBarred) {
bz.pt
return "move on"
} else {
bz.ptm("The door should never be unbarred")
return "open"
}
}
checkDoor(true)
// door.js - Line 6 fired: isBarred = true
// door.js - Point fired at line 9
checkDoor(false)
// door.js - Line 6 fired: isBarred = false
// door.js - Point fired at line 12: The door should never be unbarred
// With Defaults
const bz = new BugZapper({
showFileName: false, // Show name of file.
fullFilePath: false // Show the entire path to file.
pointMessage: "Point fired at line %l" // Redefine the message for bz.pt and bz.pt(), %l = line number
varMessage: "Line %l fired: %k = %v" // Redefine the message for bz.var(), %l = line number, %v = the variables mapped as name = value, ...
alterVarLN: -1 // Offset the line number shown for bz.var() compared to its location in the code + (moves down) or - (moves up)
alterPtLN: 0 // Offset the line number shown for bz.pt and bz.pt() compared to their location in the code + or -
})
bz.pt; // myfile.js - Point fired at line 152
bz.ptm("This should never happen"); // myfile.js - Point fired at line 892: This should never happen
bz.var({variable[, ...]}) - Mark a variable in your code to have its name and value logged when it is reached, must be an object,
let myVar = true
let myFalseVar = false
bz.var({myVar, myFalseVar}) // myfile.js - Line 536 fired: myVar = true, myFalseVar = false