https://github.com/bexcool/bxclog
BeXCool Logger Utility
https://github.com/bexcool/bxclog
brackets javascript logging typescript
Last synced: 8 months ago
JSON representation
BeXCool Logger Utility
- Host: GitHub
- URL: https://github.com/bexcool/bxclog
- Owner: bexcool
- License: mit
- Created: 2020-12-09T12:31:04.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-27T17:06:58.000Z (about 2 years ago)
- Last Synced: 2025-07-01T18:15:49.432Z (8 months ago)
- Topics: brackets, javascript, logging, typescript
- Language: JavaScript
- Size: 89.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BXCLog
BeXCool Logger
A simple logging utility module
## How to use
- [Javascript](#javascript)
- [Typescript](#typescript)
## Options
Note: Some options may have a different syntax to better match the language
### locale
Type: `string`
Default: `"auto"`
Any locale code (eg. en-GB, de-DE, en-US)
Use "auto" to set automatically from OS.
### timeZone
Type: `string`
Default: `"auto"`
Any [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
Use "auto" to set automatically from OS.
### brackets
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 | < > |
### saveToFile
Type: `boolean`
Default: `false`
Should the log be saved into a file?
### saveFilePath
Type: `string`
Default: `"logs"`
Where should the file be saved?
[SaveToFile](#saveToFile) must be enabled for this to have effect.
Relative to the entry point (eg. index.js, app.exe, ...).
### showDebug
Type: `boolean`
Default: `true`
Changes whether the debug method displays anything.
Should be changed by the value of an environment variable (eg. `environment == "release"`)
## Javascript
Install with npm:
`npm install bxclog`
Example code:
```js
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 🚔👮♂️");
```
## Typescript
Install with npm:
`npm install bxclog`
Example code:
```ts
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 = ...")
*/
```