@ptkdev/logger
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -0,1 +1,9 @@ | ||
# v1.6.0 (May 24, 2020) | ||
* Fix: info color (default palette) changed from #2ECC71 to #4CAF50 | ||
* Fix: docs url with custom pallette | ||
* Fix: stackoverflow url with custom pallette | ||
[![](https://img.shields.io/badge/donate-paypal-005EA6.svg?logo=paypal)](https://www.paypal.me/ptkdev) [![](https://img.shields.io/badge/donate-patreon-F87668.svg?logo=patreon)](https://www.patreon.com/ptkdev) [![](https://img.shields.io/badge/donate-sponsors-ea4aaa.svg?logo=github)](https://github.com/sponsors/ptkdev/) [![](https://img.shields.io/badge/donate-ko--fi-29abe0.svg?logo=ko-fi)](https://ko-fi.com/ptkdev) | ||
# v1.5.0 (May 20, 2020) | ||
@@ -5,5 +13,2 @@ * Feature: logrotate | ||
[![](https://img.shields.io/badge/donate-paypal-005EA6.svg?logo=paypal)](https://www.paypal.me/ptkdev) [![](https://img.shields.io/badge/donate-patreon-F87668.svg?logo=patreon)](https://www.patreon.com/ptkdev) [![](https://img.shields.io/badge/donate-sponsors-ea4aaa.svg?logo=github)](https://github.com/sponsors/ptkdev/) [![](https://img.shields.io/badge/donate-ko--fi-29abe0.svg?logo=ko-fi)](https://ko-fi.com/ptkdev) | ||
# v1.4.0 (May 11, 2020) | ||
@@ -10,0 +15,0 @@ * Translations: 🇫🇷 (Thanks: Sylvain Téchené) |
@@ -368,4 +368,6 @@ /** | ||
docs(message = "", url = "", tag = "") { | ||
this.log(this.TYPES_LOG.DOCS, tag, `${message} - ${chalk.rgb(236, 135, 191).underline.italic(url)}`); | ||
this.appendFile(this.TYPES_LOG.DOCS, tag, `${message} - ${chalk.rgb(236, 135, 191).underline.italic(url)}`); | ||
let docs = this.TYPES_LOG.DOCS; | ||
this.log(this.TYPES_LOG.DOCS, tag, `${message} - ${docs.color.underline.italic(url)}`); | ||
this.appendFile(this.TYPES_LOG.DOCS, tag, `${message} - ${docs.color.underline.italic(url)}`); | ||
} | ||
@@ -388,5 +390,7 @@ | ||
let stackoverflow = this.TYPES_LOG.STACKOVERFLOW; | ||
let url = `https://stackoverflow.com/search?q=${encodeURI(error_message)}`; | ||
this.log(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${chalk.rgb(41, 128, 185).underline.italic(url)}`); | ||
this.appendFile(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${chalk.rgb(41, 128, 185).underline.italic(url)}`); | ||
this.log(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${stackoverflow.color.underline.italic(url)}`); | ||
this.appendFile(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${stackoverflow.color.underline.italic(url)}`); | ||
} | ||
@@ -393,0 +397,0 @@ |
@@ -15,3 +15,3 @@ /** | ||
module.exports = { | ||
INFO: {id: "INFO", label: " | INFORMATION ", bgcolor: chalk.bgRgb(46, 204, 113).white.bold, color: chalk.rgb(46, 204, 113)}, | ||
INFO: {id: "INFO", label: " | INFORMATION ", bgcolor: chalk.bgRgb(76, 175, 80).white.bold, color: chalk.rgb(76, 175, 80)}, | ||
WARNING: {id: "WARNING", label: " | WARNING ", bgcolor: chalk.bgRgb(243, 156, 18).white.bold, color: chalk.rgb(243, 156, 18)}, | ||
@@ -18,0 +18,0 @@ ERROR: {id: "ERROR", label: " | ERROR ", bgcolor: chalk.bgRgb(192, 57, 43).white.bold, color: chalk.rgb(192, 57, 43)}, |
{ | ||
"name": "@ptkdev/logger", | ||
"description": "Beautiful Logger for Node.js: the best alternative to the console.log statement", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"main": "modules/logger.js", | ||
@@ -6,0 +6,0 @@ "author": "Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)", |
@@ -5,3 +5,3 @@ [![Beautiful Logger for Node.js: the best alternative to the console.log statement](https://raw.githubusercontent.com/ptkdev/ptkdev-logger/nightly/.github/assets/ptkdev-logger-logo.png)](https://www.npmjs.com/package/@ptkdev/logger) | ||
[![](https://img.shields.io/badge/version-v1.5.0-lightgrey.svg)](https://github.com/ptkdev/ptkdev-logger/releases) [![](https://img.shields.io/npm/v/@ptkdev/logger.svg)](https://www.npmjs.com/package/@ptkdev/logger) [![](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/ptkdev/ptkdev-logger/blob/master/LICENSE.md) [![](https://img.shields.io/badge/ES-9-F7DF1E.svg)](https://wikipedia.org/wiki/ECMAScript) [![](https://snyk.io/test/github/ptkdev/ptkdev-logger/badge.svg)](https://snyk.io/test/github/ptkdev/ptkdev-logger) [![](https://discordapp.com/api/guilds/383373985666301975/embed.png)](http://discord.ptkdev.io) | ||
[![](https://img.shields.io/badge/version-v1.6.0-lightgrey.svg)](https://github.com/ptkdev/ptkdev-logger/releases) [![](https://img.shields.io/npm/v/@ptkdev/logger.svg)](https://www.npmjs.com/package/@ptkdev/logger) [![](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/ptkdev/ptkdev-logger/blob/master/LICENSE.md) [![](https://img.shields.io/badge/ES-9-F7DF1E.svg)](https://wikipedia.org/wiki/ECMAScript) [![](https://snyk.io/test/github/ptkdev/ptkdev-logger/badge.svg)](https://snyk.io/test/github/ptkdev/ptkdev-logger) [![](https://discordapp.com/api/guilds/383373985666301975/embed.png)](http://discord.ptkdev.io) | ||
@@ -25,2 +25,3 @@ > The best alternative to the console.log statement | ||
- - 🎨 [Palette](#-palette) | ||
- - 🤹♂️ [LogRotate](#-logrotate) | ||
- 👨💻 [Contributing](#-contributing) | ||
@@ -35,3 +36,3 @@ - 🐛 [Known Bugs](https://github.com/ptkdev/ptkdev-logger/issues?q=is%3Aopen+is%3Aissue+label%3Abug) | ||
* [✔️] Palette (🎨 Customize colors) | ||
* [✔️] Logrotate | ||
* [✔️] Logrotate 🤹♂️ | ||
* [✔️] The best alternative to the console.log statement | ||
@@ -72,3 +73,3 @@ * [✔️] Write stdout logs to file (supported format: text/log and json) | ||
}, | ||
"path": { // remember: add logs folder or files to .gitignore | ||
"path": { // remember: add string *.log to .gitignore | ||
"debug_log": "./debug.log", | ||
@@ -99,3 +100,3 @@ "error_log": "./errors.log", | ||
| rotate | Rotates the log files when size exceeds this value | `10B` / `10K` / `10M` / `10G` | `"rotate": {"size": "10M"}` | **v1.5.0** | | ||
| palette | Change palette with hexcode colors | `{ "palette": { "info": { "label": "#ffffff", "text": "#4CAF50", "background": "#4CAF50" } }` | default palette | **v1.5.0** | | ||
| palette | Change palette with hexcode colors | [Object](#-palette) | default palette | **v1.5.0** | | ||
| path | If write is true, the library writes the logs to a path | Object | `{"debug_log": "./debug.log", "error_log": "./errors.log"}` | **v1.0.0** | | ||
@@ -119,3 +120,3 @@ | ||
You can customize palette colors with `options.palette` with hexcode values. | ||
You can customize palette colors with Object `palette` and with hexcode values. | ||
- `label` is text on left (INFORMATION / ERROR / DOCS, etc..) | ||
@@ -125,4 +126,65 @@ - `text` is message of log on right | ||
```json | ||
{ | ||
... | ||
"palette": { | ||
"info": { // method name | ||
"label": "#ffffff", // label on left | ||
"text": "#4CAF50", // log message | ||
"background": "#4CAF50" // background | ||
}, | ||
"warning": { | ||
"label": "#ffffff", | ||
"text": "#FF9800", | ||
"background": "#FF9800" | ||
}, | ||
"error": { | ||
"label": "#ffffff", | ||
"text": "#FF5252", | ||
"background": "#FF5252" | ||
}, | ||
"stackoverflow": { | ||
"label": "#ffffff", | ||
"text": "#9C27B0", | ||
"background": "#9C27B0" | ||
}, | ||
"docs": { | ||
"label": "#ffffff", | ||
"text": "#FF4081", | ||
"background": "#FF4081" | ||
}, | ||
"debug": { | ||
"label": "#ffffff", | ||
"text": "#1976D2", | ||
"background": "#1976D2" | ||
}, | ||
"sponsor": { | ||
"label": "#ffffff", | ||
"text": "#607D8B", | ||
"background": "#607D8B" | ||
}, | ||
"time": { | ||
"label": "#ffffff", | ||
"background": "#795548" | ||
} | ||
} | ||
... | ||
} | ||
``` | ||
See folder `examples`, run with `node example.js`. | ||
## 🤹♂️ LogRotate | ||
Rotates the file when size exceeds 10 megabytes (optional, default 10M - values: 10B (byte) / 10K (kilobyte)/ 10M (megabyte)/ 10G (gigabyte)) | ||
```json | ||
... | ||
"rotate": { | ||
"size": "10M", | ||
"encoding": "utf8" | ||
}, | ||
... | ||
``` | ||
## 📚 Documentation | ||
@@ -129,0 +191,0 @@ Run `npm run docs` |
239
47990
15
592