sussy-logger
v1.2.0
Published
A customization logger for JavaScript/TypeScript
Downloads
11
Maintainers
Readme
Setup:
const { Logger, Levels, FileHandler } = require("sussy-logger");
const logger = new Logger({
closeOnExit?: true/false, // default: true
hideConsole?: true/false // default: false
});
logger.log(/* level */, /* data */);
logger.formatFile((level, message, timestamp) => {
/* format hier for file return formatted string */
});
logger.formatConsole((level, message, timestamp) => {
/* format hier for file return formatted string */
});
logger.format((level, message, timestamp) => {
/* format hier for both return formatted string */
});
logger.attachFileHandler(new FileHandler("path/to/file", {
level: 1-5,
only?: true/false, // default: false
maxFileSize: number, // default: Infinity
}));
Example:
Code:
const { Logger, Levels } = require("sussy-logger");
const logger = new Logger({
closeOnExit: true,
hideConsole: false,
});
logger.log(Levels.info, "This is a very simple example.");
Output:
Console:
[INFO] This is a very simple example.