@ptkdev/logger
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -0,1 +1,7 @@ | ||
# v1.7.0 (August 05, 2020) | ||
* Feature: typescript typization (Thanks: Giovanni Cardamone) | ||
[![](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.6.0 (May 24, 2020) | ||
@@ -6,5 +12,2 @@ * Fix: info color (default palette) changed from #2ECC71 to #4CAF50 | ||
[![](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) | ||
@@ -11,0 +14,0 @@ * Feature: logrotate |
@@ -19,10 +19,10 @@ /** | ||
const languages = { | ||
de: require("../translations/de"), | ||
en: require("../translations/en"), | ||
es: require("../translations/es"), | ||
fr: require("../translations/fr"), | ||
it: require("../translations/it"), | ||
pl: require("../translations/pl"), | ||
pt: require("../translations/pt"), | ||
es: require("../translations/es"), | ||
de: require("../translations/de"), | ||
ru: require("../translations/ru"), | ||
fr: require("../translations/fr") | ||
ru: require("../translations/ru") | ||
}; | ||
@@ -163,3 +163,3 @@ const logger = console; | ||
* @param {string} format - format of date: json, timestamp or string (optional, deafult: string) | ||
* | ||
* @return {string} time - current Date.now() | ||
@@ -184,5 +184,5 @@ * | ||
/** | ||
* Output of console log to file | ||
* Write the output of console.log() to file | ||
* ===================== | ||
* Write in debug.log and error.log in /logs folder | ||
* Write messages to debug.log and error.log in /logs folder | ||
* | ||
@@ -192,2 +192,3 @@ * @param {string} type - example: INFO/WARNING/ERROR/DEBUG or other valid type string (see ./types.js) (mandatory) | ||
* @param {string} tag - func unique tag (optional) | ||
* | ||
*/ | ||
@@ -256,3 +257,3 @@ appendFile(type = "INFO", tag = "", message = "") { | ||
* ===================== | ||
* Log manager - don't use this directly. Use info() error() debug() warning() | ||
* Stdout manager - don't use this directly. Use info() error() debug() warning() | ||
* | ||
@@ -264,3 +265,3 @@ * @param {string} type - example: INFO/WARNING/ERROR/DEBUG or other valid type string (see ./types.js) (mandatory) | ||
*/ | ||
log(type = "INFO", tag = "", message = "") { | ||
stdout(type = "INFO", tag = "", message = "") { | ||
let time = this.TYPES_LOG.TIME; | ||
@@ -280,3 +281,3 @@ if (tag !== "") { | ||
* ===================== | ||
* Log manager - don't use this directly. Use info() error() debug() warning() | ||
* Stderr manager - don't use this directly. Use info() error() debug() warning() | ||
* | ||
@@ -288,3 +289,3 @@ * @param {string} type - example: INFO/WARNING/ERROR/DEBUG or other valid type string (see ./types.js) (mandatory) | ||
*/ | ||
err(type = "ERROR", tag = "", message = "") { | ||
stderr(type = "ERROR", tag = "", message = "") { | ||
let time = this.TYPES_LOG.TIME; | ||
@@ -302,5 +303,5 @@ if (tag !== "") { | ||
/** | ||
* Output of console log: type info | ||
* Logging of the info message | ||
* ===================== | ||
* Write log on console and file | ||
* This method show message on terminal and/or write message on file/json | ||
* | ||
@@ -313,3 +314,3 @@ * @param {string} message - description of issue (mandatory) | ||
if (this.config.info === "enabled" || this.config.info === true) { | ||
this.log(this.TYPES_LOG.INFO, tag, `${message}`); | ||
this.stdout(this.TYPES_LOG.INFO, tag, `${message}`); | ||
this.appendFile(this.TYPES_LOG.INFO, tag, message); | ||
@@ -320,5 +321,5 @@ } | ||
/** | ||
* Output of console log: type warning | ||
* Logging of the warning message | ||
* ===================== | ||
* Write log on console and file | ||
* This method show message on terminal and/or write message on file/json | ||
* | ||
@@ -331,3 +332,3 @@ * @param {string} message - description of issue (mandatory) | ||
if (this.config.warning === "enabled" || this.config.warning === true) { | ||
this.log(this.TYPES_LOG.WARNING, tag, `${message}`); | ||
this.stdout(this.TYPES_LOG.WARNING, tag, `${message}`); | ||
this.appendFile(this.TYPES_LOG.WARNING, tag, message); | ||
@@ -338,5 +339,5 @@ } | ||
/** | ||
* Output of console log: type error | ||
* Logging of the error message | ||
* ===================== | ||
* Write log on console and file | ||
* This method show message on terminal and/or write message on file/json | ||
* | ||
@@ -349,3 +350,3 @@ * @param {string} message - description of issue (mandatory) | ||
if (this.config.error === "enabled" || this.config.error === true) { | ||
this.err(this.TYPES_LOG.ERROR, tag, `${message}`); | ||
this.stderr(this.TYPES_LOG.ERROR, tag, `${message}`); | ||
this.appendFile(this.TYPES_LOG.ERROR, tag, message); | ||
@@ -356,5 +357,5 @@ } | ||
/** | ||
* Output of console log: type debug | ||
* Logging of the debug message | ||
* ===================== | ||
* Write log on console and file | ||
* This method show message on terminal and/or write message on file/json | ||
* | ||
@@ -367,3 +368,3 @@ * @param {string} message - description of issue (mandatory) | ||
if (this.config.debug === "enabled" || this.config.debug === true) { | ||
this.log(this.TYPES_LOG.DEBUG, tag, `${message}`); | ||
this.stdout(this.TYPES_LOG.DEBUG, tag, `${message}`); | ||
this.appendFile(this.TYPES_LOG.DEBUG, tag, message); | ||
@@ -374,5 +375,5 @@ } | ||
/** | ||
* Output of console log: type docs | ||
* Logging of the docs message | ||
* ===================== | ||
* Write log on console and file | ||
* This method show message on terminal and/or write message on file/json | ||
* | ||
@@ -387,3 +388,3 @@ * @param {string} message - description of issue (mandatory) | ||
this.log(this.TYPES_LOG.DOCS, tag, `${message} - ${docs.color.underline.italic(url)}`); | ||
this.stdout(this.TYPES_LOG.DOCS, tag, `${message} - ${docs.color.underline.italic(url)}`); | ||
this.appendFile(this.TYPES_LOG.DOCS, tag, `${message} - ${docs.color.underline.italic(url)}`); | ||
@@ -393,5 +394,5 @@ } | ||
/** | ||
* Output of console log: type stackoverflow | ||
* Logging of the stackoverflow message | ||
* ===================== | ||
* Write log on console and file | ||
* This method show message on terminal and/or write message on file/json | ||
* | ||
@@ -411,3 +412,3 @@ * @param {string} message - description of issue (mandatory) | ||
let url = `https://stackoverflow.com/search?q=${encodeURI(error_message)}`; | ||
this.log(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${stackoverflow.color.underline.italic(url)}`); | ||
this.stdout(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${stackoverflow.color.underline.italic(url)}`); | ||
this.appendFile(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${stackoverflow.color.underline.italic(url)}`); | ||
@@ -417,5 +418,5 @@ } | ||
/** | ||
* Output of console log: type sponsor | ||
* Logging of the sponsor message | ||
* ===================== | ||
* Write log on console and file | ||
* This method show message on terminal and/or write message on file/json | ||
* | ||
@@ -427,3 +428,3 @@ * @param {string} message - description of issue (mandatory) | ||
sponsor(message = "", tag = "") { | ||
this.log(this.TYPES_LOG.SPONSOR, tag, message); | ||
this.stdout(this.TYPES_LOG.SPONSOR, tag, message); | ||
this.appendFile(this.TYPES_LOG.SPONSOR, tag, message); | ||
@@ -430,0 +431,0 @@ } |
@@ -15,10 +15,50 @@ /** | ||
module.exports = { | ||
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)}, | ||
ERROR: {id: "ERROR", label: " | ERROR ", bgcolor: chalk.bgRgb(192, 57, 43).white.bold, color: chalk.rgb(192, 57, 43)}, | ||
DEBUG: {id: "DEBUG", label: " | DEBUG ", bgcolor: chalk.bgRgb(155, 89, 182).white.bold, color: chalk.rgb(155, 89, 182)}, | ||
DOCS: {id: "DOCS", label: " | DOCUMENTATION ", bgcolor: chalk.bgRgb(236, 135, 191).white.bold, color: chalk.rgb(236, 135, 191)}, | ||
STACKOVERFLOW: {id: "STACKOVERFLOW", label: " | STACKOVERFLOW ", bgcolor: chalk.bgRgb(41, 128, 185).white.bold, color: chalk.rgb(41, 128, 185)}, | ||
SPONSOR: {id: "SPONSOR", label: " | SPONSOR ", bgcolor: chalk.bgRgb(22, 160, 133).white.bold, color: chalk.rgb(22, 160, 133)}, | ||
TIME: {id: "TIME", label: " | TIME ", bgcolor: chalk.bgRgb(44, 62, 80).white.bold, color: chalk.rgb(44, 62, 80)} | ||
DEBUG: { | ||
bgcolor: chalk.bgRgb(155, 89, 182).white.bold, | ||
color: chalk.rgb(155, 89, 182), | ||
id: "DEBUG", | ||
label: " | DEBUG " | ||
}, | ||
DOCS: { | ||
bgcolor: chalk.bgRgb(236, 135, 191).white.bold, | ||
color: chalk.rgb(236, 135, 191), | ||
id: "DOCS", | ||
label: " | DOCUMENTATION " | ||
}, | ||
ERROR: { | ||
bgcolor: chalk.bgRgb(192, 57, 43).white.bold, | ||
color: chalk.rgb(192, 57, 43), | ||
id: "ERROR", | ||
label: " | ERROR " | ||
}, | ||
INFO: { | ||
bgcolor: chalk.bgRgb(76, 175, 80).white.bold, | ||
color: chalk.rgb(76, 175, 80), | ||
id: "INFO", | ||
label: " | INFORMATION " | ||
}, | ||
SPONSOR: { | ||
bgcolor: chalk.bgRgb(22, 160, 133).white.bold, | ||
color: chalk.rgb(22, 160, 133), | ||
id: "SPONSOR", | ||
label: " | SPONSOR " | ||
}, | ||
STACKOVERFLOW: { | ||
bgcolor: chalk.bgRgb(41, 128, 185).white.bold, | ||
color: chalk.rgb(41, 128, 185), | ||
id: "STACKOVERFLOW", | ||
label: " | STACKOVERFLOW " | ||
}, | ||
TIME: { | ||
bgcolor: chalk.bgRgb(44, 62, 80).white.bold, | ||
color: chalk.rgb(44, 62, 80), | ||
id: "TIME", | ||
label: " | TIME " | ||
}, | ||
WARNING: { | ||
bgcolor: chalk.bgRgb(243, 156, 18).white.bold, | ||
color: chalk.rgb(243, 156, 18), | ||
id: "WARNING", | ||
label: " | WARNING " | ||
} | ||
}; |
{ | ||
"name": "@ptkdev/logger", | ||
"description": "Beautiful Logger for Node.js: the best alternative to the console.log statement", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"main": "modules/logger.js", | ||
@@ -79,4 +79,5 @@ "author": "Patryk Rzucidło [@ptkdev] <support@ptkdev.io> (https://ptk.dev)", | ||
"Alina Osv [@alinaosv] <hixid@ya.ru> (https://github.com/alinaosv)", | ||
"Sylvain Téchené [@syltech] <contact@syltech.fr> (https://github.com/Syltech)" | ||
"Sylvain Téchené [@syltech] <contact@syltech.fr> (https://github.com/Syltech)", | ||
"Giovanni Cardamone [@GiovanniCardamone] <g.cardamone2@gmail.com> (https://github.com/GiovanniCardamone)" | ||
] | ||
} | ||
} |
@@ -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.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) | ||
[![](https://img.shields.io/badge/version-v1.7.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) | ||
@@ -121,3 +121,3 @@ > The best alternative to the console.log statement | ||
```json | ||
```javascript | ||
{ | ||
@@ -176,3 +176,3 @@ ... | ||
```json | ||
```javascript | ||
... | ||
@@ -209,7 +209,8 @@ "rotate": { | ||
<tr> | ||
<td align="center"><a href="https://ptk.dev"><img src="https://avatars1.githubusercontent.com/u/442844?v=4" width="100px;" alt=""/><br /><sub><b>Patryk Rzucidło</b></sub></a><br /><a href="https://github.com/ptkdev/ptkdev-logger/commits?author=ptkdev" title="Code">💻</a> <a href="#translation-ptkdev" title="Translation">🌍</a> <a href="https://github.com/ptkdev/ptkdev-logger/commits?author=ptkdev" title="Documentation">📖</a> <a href="https://github.com/ptkdev/ptkdev-logger/issues?q=author%3Aptkdev" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/agoalofalife"><img src="https://avatars1.githubusercontent.com/u/15719824?v=4" width="100px;" alt=""/><br /><sub><b>Ilua Chubarov</b></sub></a><br /><a href="https://github.com/ptkdev/ptkdev-logger/commits?author=agoalofalife" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/Bruck1701"><img src="https://avatars2.githubusercontent.com/u/17711277?v=4" width="100px;" alt=""/><br /><sub><b>Bruno Kümmel</b></sub></a><br /><a href="https://github.com/ptkdev/ptkdev-logger/commits?author=Bruck1701" title="Code">💻</a> <a href="#translation-Bruck1701" title="Translation">🌍</a></td> | ||
<td align="center"><a href="https://github.com/alinaosv"><img src="https://avatars3.githubusercontent.com/u/60554247?v=4" width="100px;" alt=""/><br /><sub><b>Alina Osv</b></sub></a><br /><a href="#translation-alinaosv" title="Translation">🌍</a></td> | ||
<td align="center"><a href="https://github.com/Syltech"><img src="https://avatars1.githubusercontent.com/u/3882925?v=4" width="100px;" alt=""/><br /><sub><b>Sylvain Téchené</b></sub></a><br /><a href="#translation-Syltech" title="Translation">🌍</a></td> | ||
<td align="center"><a href="https://ptk.dev"><img src="https://avatars1.githubusercontent.com/u/442844?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patryk Rzucidło</b></sub></a><br /><a href="https://github.com/ptkdev/ptkdev-logger/commits?author=ptkdev" title="Code">💻</a> <a href="#translation-ptkdev" title="Translation">🌍</a> <a href="https://github.com/ptkdev/ptkdev-logger/commits?author=ptkdev" title="Documentation">📖</a> <a href="https://github.com/ptkdev/ptkdev-logger/issues?q=author%3Aptkdev" title="Bug reports">🐛</a></td> | ||
<td align="center"><a href="https://github.com/agoalofalife"><img src="https://avatars1.githubusercontent.com/u/15719824?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ilua Chubarov</b></sub></a><br /><a href="https://github.com/ptkdev/ptkdev-logger/commits?author=agoalofalife" title="Code">💻</a></td> | ||
<td align="center"><a href="https://github.com/Bruck1701"><img src="https://avatars2.githubusercontent.com/u/17711277?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bruno Kümmel</b></sub></a><br /><a href="https://github.com/ptkdev/ptkdev-logger/commits?author=Bruck1701" title="Code">💻</a> <a href="#translation-Bruck1701" title="Translation">🌍</a></td> | ||
<td align="center"><a href="https://github.com/alinaosv"><img src="https://avatars3.githubusercontent.com/u/60554247?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alina Osv</b></sub></a><br /><a href="#translation-alinaosv" title="Translation">🌍</a></td> | ||
<td align="center"><a href="https://github.com/Syltech"><img src="https://avatars1.githubusercontent.com/u/3882925?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sylvain Téchené</b></sub></a><br /><a href="#translation-Syltech" title="Translation">🌍</a></td> | ||
<td align="center"><img src="https://avatars.githubusercontent.com/giovannicardamone?s=100" width="100px;" alt=""/><br /><sub><b>Giovanni Cardamone</b></sub><br /><a href="https://github.com/ptkdev/ptkdev-logger/commits?author=GiovanniCardamone" title="Code">💻</a></td> | ||
</tr> | ||
@@ -243,2 +244,2 @@ </table> | ||
###### Copyleft (c) 2020 [Patryk Rzucidło](https://ptk.dev) ([@PTKDev](https://twitter.com/ptkdev)) <[support@ptkdev.io](mailto:support@ptkdev.io)> | ||
###### Copyleft (c) 2020 [Patryk Rzucidło](https://ptk.dev) ([@PTKDev](https://twitter.com/ptkdev)) <[support@ptkdev.io](mailto:support@ptkdev.io)> |
51764
19
699
241