BeXCool Logger
A simple logging utility module
Note: Some options may have a different syntax to better match the language
Type: string
Default: "auto"
Any locale code (eg. en-GB, de-DE, en-US)
Use "auto" to set automatically from OS.
Type: string
Default: "auto"
Any timezone
Use "auto" to set automatically from OS.
Type: string
Default: "[]"
Which type of brackets to use.
Available options (Note: Any field is a valid option)
Shape | Name | Character |
---|---|---|
round | parentheses | ( ) |
square | box | [ ] |
braces | curly | { } |
angle | chevrons | < > |
Type: boolean
Default: false
Should the log be saved into a file?
Type: string
Default: "logs"
Where should the file be saved?
SaveToFile must be enabled for this to have effect.
Relative to the entry point (eg. index.js, app.exe, ...).
Type: boolean
Default: true
Changes whether the debug method displays anything.
Should be changed by the value of an environment variable (eg. environment == "release"
)
Install with npm:
npm install bxclog
Example code:
const { BXCLog } = require("bxclog");
/**
* This BXCLog instance should be stored in a file like "lib.js"
* in the exports object.
* You can save a lot of performance and resources by doing that,
* because creating new instances every time you need to log
* something will have a negative impact on performance
*/
const bxclogger = new BXCLog({
saveToFile: true,
brackets: "<>",
});
const service = "CatsService";
bxclogger.debug("process.argv", process.argv.join(", "));
bxclogger.info(service, "purr... meow, meow!", "we think the number", Math.random(), "is really cool... meow 😺");
bxclogger.warn(service,
"The cats are hungry", "\n", "You better go feed them right now \n",
"They also said that they need exactly this many kilos of food:", 68429796945127451n, "...it should be enough for about one and a half days 😼");
bxclogger.error(service, "The cats are really hungry and are starting to delete your programs 😠 Go feed them right now 🚔👮♂️");
Install with npm:
npm install bxclog
Example code:
import { BXCLog } from "bxclog";
/**
* You can copy the rest of the code from Javascript,
* The only difference is that instead of the "exports" object you use es6 export ("export const bxclogger = ...")
*/