Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptkdev committed May 19, 2020
2 parents d13ea7f + d569733 commit 205a951
Show file tree
Hide file tree
Showing 8 changed files with 638 additions and 1,191 deletions.
8 changes: 1 addition & 7 deletions .eslintrc.json
Expand Up @@ -11,7 +11,6 @@
"ecmaVersion": 2019
},
"plugins": [
"snakecasejs",
"jsdoc",
"jest"
],
Expand All @@ -20,11 +19,7 @@
"tagNamePreference": {
"returns": "return"
}
},
"html/html-extensions": [".html", ".twig", ".vue"],
"html/indent": "tab",
"snakecasejs/filter": ["ClassDeclaration", "NewExpression", "AssignmentExpression"],
"snakecasejs/whitelist": ["bgRgb", "appendFile", "FileSync"]
}
},
"rules": {
"no-multi-spaces": ["error", { "ignoreEOLComments": true, "exceptions": { "VariableDeclarator": true } }],
Expand Down Expand Up @@ -57,7 +52,6 @@
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"snakecasejs/snakecasejs": "error",
"jsdoc/require-param": 1,
"jsdoc/require-param-description": 1,
"jsdoc/require-param-name": 1,
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions CHANGELOG.md
@@ -1,9 +1,13 @@
# v1.4.0 (May 11, 2020)
* Translations: 🇫🇷 (Thanks: Sylvain Téchené)
# v1.5.0 (May 20, 2020)
* Feature: logrotate
* Feature: palette: customize colors

[![](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)
* Translations: 🇫🇷 (Thanks: Sylvain Téchené)

# v1.3.0 (May 07, 2020)
* Translations: 🇷🇺 🇩🇪 (Thanks: Alina Osv)

Expand Down
48 changes: 34 additions & 14 deletions README.md
Expand Up @@ -2,7 +2,7 @@

# 🦒 Beautiful Logger for Node.js

[![](https://img.shields.io/badge/version-v1.4.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.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)

> The best alternative to the console.log statement
Expand All @@ -20,6 +20,7 @@
- 📚 [Documentation](#-documentation)
- - 🧰 [Options](#-options)
- - 🔌 [Methods](#-methods)
- - 🎨 [Palette](#-palette)
- 👨‍💻 [Contributing](#-contributing)
- 🐛 [Known Bugs](https://github.com/ptkdev/ptkdev-logger/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
- 🍻 Community:
Expand All @@ -28,6 +29,8 @@
## 💡 Features
* [✔️] Easy to use
* [✔️] MIT License
* [✔️] Palette (🎨 Customize colors)
* [✔️] Logrotate
* [✔️] The best alternative to the console.log statement
* [✔️] Write stdout logs to file (supported format: text/log and json)
* [✔️] The JSON logs format is compatible with [pinojs](https://github.com/pinojs/pino)
Expand Down Expand Up @@ -59,6 +62,10 @@ const options = {
"sponsor": true,
"write": true,
"type": "log",
"rotate": {
"size": "10M",
"encoding": "utf8"
},
"path": { // remember: add logs folder or files to .gitignore
"debug_log": "./debug.log",
"error_log": "./errors.log",
Expand All @@ -69,22 +76,24 @@ const logger = new Logger(options);
logger.info("message");
```

See folder `examples`, run with `node example.js`. Below is available a description of `options` values and all logger methods.
See folder `examples`, run with `node example.js`. Below is available a description of `options` values.

## 🧰 Options

| Parameter | Description | Values | Default value |
| --- | --- | --- | --- |
| language | Set language of log type | en / it / pl / es / pt / de / ru / fr | en |
| colors | Enable colors in terminal | true / enabled / false / disabled | true |
| debug | Enable all logs with method debug | true / enabled / false / disabled | true |
| info | Enable all logs with method info | true / enabled / false / disabled | true |
| warning | Enable all logs with method warning | true / enabled / false / disabled | true |
| error | Enable all logs with method errors | true / enabled / false / disabled | true |
| sponsor | Enable all logs with method sponsor | true / enabled / false / disabled | true |
| write | Write the logs into a file, you need set path values | true / enabled / false / disabled | false |
| type | Format of logs in files | log / json | log |
| path | If write is true, the library writes the logs to a path | Object | `{"debug_log": "./debug.log", "error_log": "./errors.log"}` |
| Parameter | Description | Values | Default value | Available since |
| --- | --- | --- | --- | --- |
| language | Set language of log type | en / it / pl / es / pt / de / ru / fr | en | **v1.0.0** |
| colors | Enable colors in terminal | true / enabled / false / disabled | true | **v1.0.0** |
| debug | Enable all logs with method debug | true / enabled / false / disabled | true | **v1.0.0** |
| info | Enable all logs with method info | true / enabled / false / disabled | true | **v1.0.0** |
| warning | Enable all logs with method warning | true / enabled / false / disabled | true | **v1.0.0** |
| error | Enable all logs with method errors | true / enabled / false / disabled | true | **v1.0.0** |
| sponsor | Enable all logs with method sponsor | true / enabled / false / disabled | true | **v1.0.0** |
| write | Write the logs into a file, you need set path values | true / enabled / false / disabled | false | **v1.0.0** |
| type | Format of logs in files | log / json | log | **v1.0.0** |
| 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** |
| 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** |

## 🔌 Methods

Expand All @@ -98,6 +107,17 @@ See folder `examples`, run with `node example.js`. Below is available a descript
| **stackoverflow**(`message`, `tag`, `error_string`) | `message`: Display stackoverflow log message <br> `tag`: prefix of message <br> `error_string`: query for stackoverflow, if empty we use message param | `message`: string (mandatory) <br> `tag`: string (optional) <br> `error_string`: string (optional) |
| **docs**(`message`, `url`, `tag`) | `message`: Display docs log message <br> `url`: link of documentation <br> `tag`: prefix of message | `message`: string (mandatory) <br> `url`: string (optional) <br> `tag`: string (optional) |

## 🎨 Palette

[![Beautiful Logger for Node.js](https://raw.githubusercontent.com/ptkdev/ptkdev-logger/nightly/.github/assets/screenshot/ptkdev-logger-palette.png)](https://raw.githubusercontent.com/ptkdev/ptkdev-logger/nightly/.github/assets/screenshot/ptkdev-logger-palette.png)

You can customize palette colors with `options.palette` with hexcode values.
- `label` is text on left (INFORMATION / ERROR / DOCS, etc..)
- `text` is message of log on right
- `background` is background color on left side

See folder `examples`, run with `node example.js`.

## 📚 Documentation
Run `npm run docs`

Expand Down
45 changes: 45 additions & 0 deletions examples/example.js
Expand Up @@ -19,9 +19,54 @@ const options = {
"sponsor": true, // enable/disable all logs with method sponsor (optional, default enabled - values: true|enabled or false|disabled)
"write": true, // write the logs into a file, you need set path values (optional, default disabled - values: true|enabled or false|disabled)
"type": "log", // format of logs in files (optional, default log - values: log|json)
"rotate": {
"size": "10M", // Rotates the file when size exceeds 10 megabytes (optional, default 10M - values: 10B (byte) / 10K (kilobyte)/ 10M (megabyte)/ 10G (gigabyte))
"encoding": "utf8"
},
"path": { // if write is true, the library writes the logs to a path
"debug_log": "./debug.log", // all logs
"error_log": "./errors.log", // only errors logs
},
"palette": {
"info": {
"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"
}
}
};

Expand Down

0 comments on commit 205a951

Please sign in to comment.