An open API service indexing awesome lists of open source software.

https://github.com/damartripamungkas/logging-pretty

๐Ÿ–ฅ๏ธ Logging your message with pretty color in node.js
https://github.com/damartripamungkas/logging-pretty

console-log debugging javascript logger logging logging-library logging-pretty nodejs npm-package

Last synced: 24 days ago
JSON representation

๐Ÿ–ฅ๏ธ Logging your message with pretty color in node.js

Awesome Lists containing this project

README

          


LOGGING-PRETTY


GitHub top language


Made by


Repository size


GitHub last commit



### ๐Ÿ’ป Step to install :

```
npm i logging-pretty
```

### โœ๏ธ Example :

```typescript
import { LoggingPretty } from "logging-pretty"

/**
*
* @param force [optional] force mode, if "pathFile" is set but this is set to "console" it will not write to the log file.
* @param pathFile [optional] set path file for store log.
* @param formatTime [optional] set format date time like YYYY-MM-DD HH:mm:ss.
* @returns object
*/
const log = new LoggingPretty({
force: `all`,
pathFile: `./test/store.log`,
formatTime: `YYYY-MM-DD HH:mm:ss`
})

log._renderLogToConsole = ({ strTime, strTag, strStyleTag, strStyleMsg }) => {
// override render log
if (strTag == `INFO`) console.log(`[${strTime}] ${strStyleTag}: -> -> ${strStyleMsg}`)
if (strTag == `FAIL`) console.log(`[${strTime}] ${strStyleTag}: x x ${strStyleMsg}`)
}

log.info(`info task`) // [2024-07-14 17:46:32] INFO: -> -> info task
log.fail(`fail task`) // [2024-07-14 17:46:32] FAIL: x x fail task
```

### ๐Ÿงพ Pre-Requisistes :

```
- node.js / bun.js / deno.js
- (optional) typescript
- (optional) commonJS
- (optional) ESM
```

### ๐Ÿ“ License :

Licensed see [here](./LICENSE)