Forge efficient log management with LogForge. Streamline error tracking, debugging, and gain insights into your application. Powerful tools for creating, managing logs, and an intuitive dashboard for seamless integration.
npm install logforge
To import LogForge in your JavaScript or TypeScript project, you can use either the ES6 import
syntax or the CommonJS require
syntax:
import LogForge from "logforge";
const LogForge = require("logforge");
const errorLogger = new LogForge();
You can pass custom file names and folder locations when creating a new instance.
const customErrorLogger = new LogForge({
errorLogFileName: 'errors.txt', // Custom log file name
logsFolderName: 'error_logs', // Custom folder for logs
});
Use the logErrorInfo
method to log error information. Simply pass an error object as a parameter.
// Import LogForge
import LogForge from "logforge.js";
// Initialize LogForge
const errorLogger = new LogForge();
try {
console.log(x); // Your code that might throw an error
} catch (error) {
// Log the error using LogForge
errorLogger.logErrorInfo(error);
}
Use the readErrors
method to retrieve logged error information.
errorLogger.readErrors();