To get started with calling the logger, make sure to choose the correct file type. If you need to import the file, eg import Logger from "logger.js"
then use Logger.import.js
. If you need to require the file, eg const Logger = require("logger.js")
then use Logger.require.js
.
Once you have uploaded these files to your project, you can now start to call the logger class!
To call the class, make sure to import the file using either
import Logger from "./{file}/{dir}/Logger.import.js
or
const Logger = require("./${file/${dir}/Logger.require.js
Once you have imported or required the logger file, you can easily log something by putting
new Logger({
message: "This is a normal message"
})
There is more styles, for such things as logging stuff based on important and overall just keeping the console tidy, the different styles are: info, success, warning, error.
new Logger({
info: true,
message: "This is an info message"
})
new Logger({
success: true,
message: "This is a success message"
})
new Logger({
warning: true,
message: "This is a warning message"
})
new Logger({
error: true,
message: "This is an error message"
})
To get started, first go to the top of the file, you should see
let FileName = `./src/development.logs`;
let WriteToFile = true;
In these variables, you can edit to if you want to write logs to a file, and where you want to write the logs too.
If you want to disable this feature, simply set WriteToFile
to false using:
let WriteToFile = false;
If you want to enable it, leave it as it is.
To set the location of the log file, simply edit FileName
to where you wish to store the log file. Example:
let FileName = `./logs/ErrorAndWarning.log`
And that's it! I created this for a project I was working on and thought it was pretty handy to have as a GitHub repo. With a little help from google and some brainpower I made this inside about 10 minutes so "no errors will occur at all"!
Made by Caallum for public usage