├── .all-contributorsrc ├── .editorconfig ├── .eslintrc.json ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── question.md └── assets │ ├── ptkdev-logger-logo.png │ ├── screenshot │ ├── ptkdev-logger-palette.png │ └── ptkdev-logger-screen1.png │ ├── social_discord.png │ └── social_telegram.png ├── .gitignore ├── .gitmodules ├── .npmignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── examples ├── example-json.js └── example.js ├── jsconfig.json ├── modules ├── logger.d.ts ├── logger.js └── types.js ├── package-lock.json ├── package.json ├── translations ├── de.js ├── en.js ├── es.js ├── fr.js ├── it.js ├── pl.js ├── pt.js └── ru.js └── tsconfig.json /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "ptkdev-logger", 3 | "projectOwner": "ptkdev", 4 | "repoType": "github", 5 | "repoHost": "https://github.com", 6 | "files": [ 7 | "README.md" 8 | ], 9 | "imageSize": 100, 10 | "commit": true, 11 | "contributors": [ 12 | { 13 | "login": "ptkdev", 14 | "name": "Patryk Rzucidło", 15 | "avatar_url": "https://avatars1.githubusercontent.com/u/442844?v=4", 16 | "profile": "https://ptk.dev", 17 | "contributions": [ 18 | "code", 19 | "translation", 20 | "doc", 21 | "bug" 22 | ] 23 | }, 24 | { 25 | "login": "agoalofalife", 26 | "name": "Ilua Chubarov", 27 | "avatar_url": "https://avatars1.githubusercontent.com/u/15719824?v=4", 28 | "profile": "https://github.com/agoalofalife", 29 | "contributions": [ 30 | "code" 31 | ] 32 | }, 33 | { 34 | "login": "Bruck1701", 35 | "name": "Bruno Kümmel", 36 | "avatar_url": "https://avatars2.githubusercontent.com/u/17711277?v=4", 37 | "profile": "https://github.com/Bruck1701", 38 | "contributions": [ 39 | "code", 40 | "translation" 41 | ] 42 | }, 43 | { 44 | "login": "alinaosv", 45 | "name": "Alina Osv", 46 | "avatar_url": "https://avatars3.githubusercontent.com/u/60554247?v=4", 47 | "profile": "https://github.com/alinaosv", 48 | "contributions": [ 49 | "translation" 50 | ] 51 | }, 52 | { 53 | "login": "Syltech", 54 | "name": "Sylvain Téchené", 55 | "avatar_url": "https://avatars1.githubusercontent.com/u/3882925?v=4", 56 | "profile": "https://github.com/Syltech", 57 | "contributions": [ 58 | "translation" 59 | ] 60 | }, 61 | { 62 | "login": "GiovanniCardamone", 63 | "name": "Giovanni Cardamone", 64 | "profile": "https://github.com/giovannicardamone", 65 | "avatar_url": "https://avatars1.githubusercontent.com/u/5117748?v=4", 66 | "contributions": [ 67 | "code" 68 | ] 69 | } 70 | ], 71 | "contributorsPerLine": 6, 72 | "commitConvention": "none" 73 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = false 9 | trim_trailing_whitespace = true 10 | indent_style = tab 11 | indent_size = 4 12 | 13 | [*.py] 14 | indent_style = space 15 | indent_size = 4 -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true, 6 | "jest/globals": true 7 | }, 8 | "extends": "eslint:recommended", 9 | "parserOptions": { 10 | "sourceType": "module", 11 | "ecmaVersion": 2019 12 | }, 13 | "plugins": [ 14 | "jsdoc", 15 | "jest" 16 | ], 17 | "settings": { 18 | "jsdoc": { 19 | "tagNamePreference": { 20 | "returns": "return" 21 | } 22 | } 23 | }, 24 | "rules": { 25 | "no-multi-spaces": ["error", { "ignoreEOLComments": true, "exceptions": { "VariableDeclarator": true } }], 26 | "block-spacing": ["error", "always"], 27 | "array-bracket-spacing": ["error", "never"], 28 | "space-in-parens": ["error", "never"], 29 | "comma-spacing": ["error", { "before": false, "after": true }], 30 | "key-spacing": ["error", { "afterColon": true, "beforeColon": false }], 31 | "indent": ["error", "tab", { "SwitchCase": 1 }], 32 | "quotes": ["error","double", { "avoidEscape": true, "allowTemplateLiterals": true}], 33 | "semi": ["error", "always"], 34 | "no-console": ["warn"], 35 | "no-constant-condition": ["warn"], 36 | "curly": ["error", "all"], 37 | "brace-style": ["error", "1tbs", { "allowSingleLine": false }], 38 | "keyword-spacing": ["error", { "before": true, "after": true }], 39 | "object-curly-spacing": ["error", "never"], 40 | "no-mixed-spaces-and-tabs": ["error", "smart-tabs"], 41 | "spaced-comment": [2, "always"], 42 | "space-before-blocks": ["error", "always"], 43 | "space-before-function-paren": ["error", "never"], 44 | "prefer-template": "error", 45 | "no-useless-concat": "error", 46 | "prefer-arrow-callback": ["error", { "allowNamedFunctions": true }], 47 | "linebreak-style": ["error", "unix"], 48 | "template-curly-spacing": ["error", "never"], 49 | "no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }], 50 | "jest/no-disabled-tests": "warn", 51 | "jest/no-focused-tests": "error", 52 | "jest/no-identical-title": "error", 53 | "jest/prefer-to-have-length": "warn", 54 | "jest/valid-expect": "error", 55 | "jsdoc/require-param": 1, 56 | "jsdoc/require-param-description": 1, 57 | "jsdoc/require-param-name": 1, 58 | "jsdoc/require-param-type": 1, 59 | "jsdoc/require-returns": 1, 60 | "jsdoc/require-returns-description": 1, 61 | "jsdoc/require-returns-type": 1, 62 | "jsdoc/require-returns-check": 1, 63 | "jsdoc/require-hyphen-before-param-description": 1 64 | } 65 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ## AUTO-DETECT 2 | * text=auto 3 | 4 | ## SOURCE CODE 5 | *.bat text eol=crlf 6 | *.css text eol=lf 7 | *.html text diff=html eol=lf 8 | *.ini text eol=crlf 9 | *.js text eol=lf 10 | *.json text eol=lf 11 | *.php text diff=php eol=lf 12 | *.py text diff=python eol=lf 13 | *.rb text diff=ruby 14 | *.sass text eol=lf 15 | *.scss text eol=lf 16 | *.sh text eol=lf 17 | *.sql text eol=lf 18 | *.ts text eol=lf 19 | *.vue text eol=lf 20 | *.xml text eol=lf 21 | *.xhtml text diff=html eol=lf 22 | 23 | ## DOCKER 24 | *.dockerignore text eol=lf 25 | Dockerfile text eol=lf 26 | 27 | ## DOCUMENTATION 28 | *.md text eol=lf 29 | *.txt text eol=lf 30 | AUTHORS text eol=lf 31 | CHANGELOG text eol=lf 32 | CHANGES text eol=lf 33 | CONTRIBUTING text eol=lf 34 | COPYING text eol=lf 35 | INSTALL text eol=lf 36 | license text eol=lf 37 | LICENSE text eol=lf 38 | NEWS text eol=lf 39 | README text eol=lf 40 | TODO text eol=lf 41 | 42 | ## TEMPLATES 43 | *.dot text eol=lf 44 | *.tpl text eol=lf 45 | *.twig text eol=lf 46 | 47 | ## LINTERS 48 | .csslintrc text eol=lf 49 | .eslintrc text eol=lf 50 | .htmlhintrc text eol=lf 51 | .jscsrc text eol=lf 52 | .jshintrc text eol=lf 53 | .jshintignore text eol=lf 54 | .stylelintrc text eol=lf 55 | .npmignore text eol=lf 56 | 57 | ## CONFIGS 58 | *.bowerrc text eol=lf 59 | *.cnf text eol=lf 60 | *.conf text eol=lf 61 | *.config text eol=lf 62 | .babelrc text eol=lf 63 | .browserslistrc text eol=lf 64 | .editorconfig text eol=lf 65 | .env text eol=lf 66 | .gitattributes text eol=lf 67 | .gitconfig text eol=lf 68 | .htaccess text eol=lf 69 | *.lock text eol=lf 70 | *.npmignore text eol=lf 71 | *.yaml text eol=lf 72 | *.yml text eol=lf 73 | browserslist text eol=lf 74 | Makefile text eol=lf 75 | makefile text eol=lf 76 | 77 | ## GRAPHICS 78 | *.ai binary 79 | *.bmp binary 80 | *.eps binary 81 | *.gif binary 82 | *.ico binary 83 | *.jng binary 84 | *.jp2 binary 85 | *.jpg binary 86 | *.jpeg binary 87 | *.jpx binary 88 | *.jxr binary 89 | *.pdf binary 90 | *.png binary 91 | *.psb binary 92 | *.psd binary 93 | *.svg text 94 | *.svgz binary 95 | *.tif binary 96 | *.tiff binary 97 | *.wbmp binary 98 | *.webp binary 99 | 100 | ## AUDIO 101 | *.kar binary 102 | *.m4a binary 103 | *.mid binary 104 | *.midi binary 105 | *.mp3 binary 106 | *.ogg binary 107 | *.ra binary 108 | 109 | ## VIDEO 110 | *.3gpp binary 111 | *.3gp binary 112 | *.as binary 113 | *.asf binary 114 | *.asx binary 115 | *.fla binary 116 | *.flv binary 117 | *.m4v binary 118 | *.mng binary 119 | *.mov binary 120 | *.mp4 binary 121 | *.mpeg binary 122 | *.mpg binary 123 | *.ogv binary 124 | *.swc binary 125 | *.swf binary 126 | *.webm binary 127 | 128 | ## ARCHIVES 129 | *.7z binary 130 | *.gz binary 131 | *.jar binary 132 | *.rar binary 133 | *.tar binary 134 | *.zip binary 135 | 136 | ## FONTS 137 | *.ttf binary 138 | *.eot binary 139 | *.otf binary 140 | *.woff binary 141 | *.woff2 binary 142 | 143 | ## EXECUTABLES 144 | *.exe binary 145 | *.pyc binary -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [ptkdev] 2 | patreon: ptkdev 3 | ko_fi: ptkdev 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | 7 | 8 | ### Versions 9 | 10 | 11 | 12 | - **Logger Version:** v1.0.0 13 | - **Node Version:** v13.0.0 14 | - **Operating System:** Windows 10 15 | - **Terminal:** Windows Powershell 16 | 17 | ### Expected Behavior 18 | 19 | 20 | 21 | ### Actual Behavior 22 | 23 | 25 | 26 | ### Steps to Reproduce 27 | 28 | 30 | 31 | 1. ... 32 | 2. ... 33 | 3. ... 34 | 35 | ### Screenshots (Optional) 36 | 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 💫 Feature request 3 | about: Suggest an idea for this project 4 | --- 5 | 6 | 7 | 8 | ### Feature description 9 | 10 | 11 | 12 | ### Feature motivation 13 | 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🗨 Question 3 | about: Ask a question 4 | --- 5 | 6 | 7 | 8 | ### Question 9 | 10 | -------------------------------------------------------------------------------- /.github/assets/ptkdev-logger-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ptkdev/ptkdev-logger/684417b17ec0be51ea5810a1083a5387aafb404c/.github/assets/ptkdev-logger-logo.png -------------------------------------------------------------------------------- /.github/assets/screenshot/ptkdev-logger-palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ptkdev/ptkdev-logger/684417b17ec0be51ea5810a1083a5387aafb404c/.github/assets/screenshot/ptkdev-logger-palette.png -------------------------------------------------------------------------------- /.github/assets/screenshot/ptkdev-logger-screen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ptkdev/ptkdev-logger/684417b17ec0be51ea5810a1083a5387aafb404c/.github/assets/screenshot/ptkdev-logger-screen1.png -------------------------------------------------------------------------------- /.github/assets/social_discord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ptkdev/ptkdev-logger/684417b17ec0be51ea5810a1083a5387aafb404c/.github/assets/social_discord.png -------------------------------------------------------------------------------- /.github/assets/social_telegram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ptkdev/ptkdev-logger/684417b17ec0be51ea5810a1083a5387aafb404c/.github/assets/social_telegram.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ###################################################################################### 2 | # License: MIT - http://opensource.org/licenses/MIT # 3 | # Author: Patryk Rzucidło (@ptkdev) https://ptk.dev # 4 | # Original: octocat - https://github.com/octocat # 5 | # Latest version: https://github.com/ptkdev/dotfiles # 6 | ###################################################################################### 7 | 8 | # Compiled source # 9 | ################### 10 | *.com 11 | *.class 12 | *.dll 13 | *.exe 14 | *.o 15 | *.so 16 | 17 | # Packages # 18 | ############ 19 | *.7z 20 | *.dmg 21 | *.gz 22 | *.iso 23 | *.jar 24 | *.rar 25 | *.tar 26 | *.zip 27 | 28 | # Eclipse # 29 | ########### 30 | .classpath 31 | .project 32 | .settings 33 | .idea 34 | .idea/ 35 | .metadata 36 | *.iml 37 | *.ipr 38 | proguard/ 39 | 40 | # Logs and databases # 41 | ###################### 42 | logs/*.log 43 | logs/screenshots/*.png 44 | logs/screenshots/*.jpg 45 | examples/*.log 46 | examples/*.json 47 | databases/*.db 48 | databases/*.sql 49 | databases/*.json 50 | *.log 51 | *.sql 52 | *.sqlite 53 | *.lock 54 | *.vscode 55 | yarn-debug.log 56 | yarn-error.log 57 | 58 | # OS generated files # 59 | ###################### 60 | .DS_Store 61 | .DS_Store? 62 | ._* 63 | .Spotlight-V100 64 | .Trashes 65 | ehthumbs.db 66 | Thumbs.db 67 | 68 | # Python # 69 | ########## 70 | *.pyc 71 | *.pyo 72 | 73 | # KDE/Linux generated files # 74 | ############################# 75 | .directory 76 | 77 | # Backup generated files # 78 | ########################## 79 | *~ 80 | *.swp 81 | *.bak 82 | *# 83 | 84 | # Android # 85 | ########### 86 | *.apk 87 | *.ap_ 88 | *.dex 89 | bin/ 90 | gen/ 91 | .gradle/ 92 | build/ 93 | local.properties 94 | 95 | # Vagrant # 96 | ########### 97 | /.vagrant 98 | 99 | # PHP # 100 | ####### 101 | ./config.php 102 | phpunit.xml 103 | /vendor 104 | composer.phar 105 | /bower_components 106 | 107 | # Runtime data # 108 | ################ 109 | pids 110 | *.pid 111 | *.seed 112 | *.pid.lock 113 | *.eslintcache 114 | 115 | # NodeJS # 116 | ########## 117 | npm-debug.log 118 | /node_modules 119 | 120 | # App # 121 | ####### 122 | plugins/*/ 123 | config.js 124 | config/*.js 125 | configs/*.js 126 | loginpin.txt 127 | configs/loginpin.txt -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ptkdev/ptkdev-logger/684417b17ec0be51ea5810a1083a5387aafb404c/.gitmodules -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # App # 2 | ####### 3 | config/*.js 4 | configs/*.js 5 | configs/loginpin.txt 6 | .github 7 | databases/ 8 | tests/ 9 | docs/ 10 | logs/ 11 | examples/ 12 | docker/ 13 | Dockerfile 14 | Dockerfile.* 15 | loginpin.txt 16 | .gitmodules 17 | .jshintrc 18 | .gitattributes 19 | .eslintrc.json 20 | .editorconfig 21 | .pm2-process.json 22 | .all-contributorsrc 23 | .eslintcache 24 | jsconfig.js -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.8.0 (August 30, 2021) 2 | 3 | - Fix: lowdb esm 4 | 5 | [![](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) 6 | 7 | # v1.7.2 (August 19, 2020) 8 | 9 | - Fix: Typescript export module 10 | 11 | # v1.7.1 (August 19, 2020) 12 | 13 | - Fix: Typescript typization issues (#7) 14 | 15 | # v1.7.0 (August 05, 2020) 16 | 17 | - Feature: typescript typization (Thanks: Giovanni Cardamone) 18 | 19 | # v1.6.0 (May 24, 2020) 20 | 21 | - Fix: info color (default palette) changed from #2ECC71 to #4CAF50 22 | - Fix: docs url with custom pallette 23 | - Fix: stackoverflow url with custom pallette 24 | 25 | # v1.5.0 (May 20, 2020) 26 | 27 | - Feature: logrotate 28 | - Feature: palette: customize colors 29 | 30 | # v1.4.0 (May 11, 2020) 31 | 32 | - Translations: 🇫🇷 (Thanks: Sylvain Téchené) 33 | 34 | # v1.3.0 (May 07, 2020) 35 | 36 | - Translations: 🇷🇺 🇩🇪 (Thanks: Alina Osv) 37 | 38 | # v1.2.0 (May 06, 2020) 39 | 40 | - Fix: security patch 41 | - Translations: 🇪🇸 🇵🇹 (Thanks: Bruno Kummel) 42 | 43 | # v1.1.2 (March 28, 2020) 44 | 45 | - Fix: security patch 46 | 47 | # v1.1.1 (March 08, 2020) 48 | 49 | - Fix: default `option.type` value 50 | 51 | # v1.1.0 (March 08, 2020) 52 | 53 | - Fix: misprint of `errors` in options and docs, renamed to `error` 54 | - Fix: errors logs output moved to `stderr` 55 | - Feature: new formats of logs files, available log (text) or (json) 56 | - Compatibility: the JSON logs format is compatible with [pinojs](https://github.com/pinojs/pino) output 57 | 58 | # v1.0.0 (March 08, 2020) 59 | 60 | - First Release. 61 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ## MIT License 2 | 3 | > Code and Contributions 4 | 5 | Copyright (c) 2020 Patryk Rzucidło (PTKDev) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | ##### https://choosealicense.com/licenses/mit/ 26 | 27 | ## Creative Commons BY-NC 4.0 License 28 | 29 | > Images, assets and logos 30 | 31 | Copyleft (c) 2020 Patryk Rzucidło (PTKDev) 32 | 33 | #### You are free to: 34 | - Share — copy and redistribute the material in any medium or format 35 | - Adapt — remix, transform, and build upon the material 36 | 37 | The licensor cannot revoke these freedoms as long as you follow the license terms. 38 | 39 | #### Under the following terms: 40 | - Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that - suggests the licensor endorses you or your use. 41 | - NonCommercial — You may not use the material for commercial purposes. 42 | 43 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 44 | 45 | ##### https://creativecommons.org/licenses/by-nc/4.0/ 46 | 47 | ## Creative Commons BY 4.0 License 48 | 49 | > Documentation and Translations 50 | 51 | Copyleft (c) 2020 Patryk Rzucidło (PTKDev) 52 | 53 | #### You are free to: 54 | - Share — copy and redistribute the material in any medium or format 55 | - Adapt — remix, transform, and build upon the material for any purpose, even commercially. 56 | 57 | The licensor cannot revoke these freedoms as long as you follow the license terms. 58 | 59 | #### Under the following terms: 60 | - Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 61 | 62 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 63 | 64 | ##### https://creativecommons.org/licenses/by/4.0/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![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) 2 | 3 | # 🦒 Beautiful Logger for Node.js 4 | 5 | [![](https://img.shields.io/badge/version-v1.8.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) 6 | 7 | > The best alternative to the console.log statement 8 | 9 | ## 🎁 Support: Donate 10 | 11 | > This project is **free**, **open source** and I try to provide excellent **free support**. Why donate? I work on this project several hours in my spare time and try to keep it up to date and working. **THANK YOU!** 12 | 13 | [![](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) 14 | 15 | ![](https://img.shields.io/badge/bitcoin-35jQmZCy4nsxoMM3QPFrnZePDVhdKaHMRH-E38B29.svg?logo=bitcoin) ![](https://img.shields.io/badge/ethereum-0x8b8171661bEb032828e82baBb0B5B98Ba8fBEBFc-4E8EE9.svg?logo=ethereum) 16 | 17 | ## 📎 Menu 18 | 19 | - 💡 [Features](#-features) 20 | - 👔 [Screenshot](#-screenshot) 21 | - 🚀 [How to use](#-installation) 22 | - 📚 [Documentation](#-documentation) 23 | - - 🧰 [Options](#-options) 24 | - - 🔌 [Methods](#-methods) 25 | - - 🎨 [Palette](#-palette) 26 | - - 🤹‍♂️ [LogRotate](#-logrotate) 27 | - 👨‍💻 [Contributing](#-contributing) 28 | - 🐛 [Known Bugs](https://github.com/ptkdev/ptkdev-logger/issues?q=is%3Aopen+is%3Aissue+label%3Abug) 29 | - 🍻 Community: 30 | - [Discord](http://discord.ptkdev.io) ([🇬🇧 English Channel](https://discord.gg/tWtqt4B) | [🇮🇹 Italian Channel](https://discord.gg/q29uZnm) | [🇵🇱 Polish Channel](https://discord.gg/akjuWJX)) 31 | 32 | ## 💡 Features 33 | 34 | - [✔️] Easy to use 35 | - [✔️] MIT License 36 | - [✔️] Palette (🎨 Customize colors) 37 | - [✔️] Logrotate 🤹‍♂️ 38 | - [✔️] Typescript support 39 | - [✔️] The best alternative to the console.log statement 40 | - [✔️] Write stdout logs to file (supported format: text/log and json) 41 | - [✔️] The JSON logs format is compatible with [pinojs](https://github.com/pinojs/pino) 42 | - [✔️] Translations: 🇬🇧 🇮🇹 🇵🇱 🇪🇸 🇵🇹 🇷🇺 🇩🇪 🇫🇷 (Help me ❤️) 43 | 44 | ## 👔 Screenshot 45 | 46 | [![Beautiful Logger for Node.js](https://raw.githubusercontent.com/ptkdev/ptkdev-logger/nightly/.github/assets/screenshot/ptkdev-logger-screen1.png)](https://raw.githubusercontent.com/ptkdev/ptkdev-logger/nightly/.github/assets/screenshot/ptkdev-logger-screen1.png) 47 | 48 | ## 🚀 Installation 49 | 50 | 1. In your node project run: `npm install @ptkdev/logger --save` 51 | 2. Usage: 52 | 53 | ```javascript 54 | const Logger = require("@ptkdev/logger"); 55 | const logger = new Logger(); 56 | logger.info("message"); 57 | ``` 58 | 59 | You can set `options` to `new Logger(options);` example: 60 | 61 | ```javascript 62 | const Logger = require("@ptkdev/logger"); 63 | 64 | const options = { 65 | language: "en", 66 | colors: true, 67 | debug: true, 68 | info: true, 69 | warning: true, 70 | error: true, 71 | sponsor: true, 72 | write: true, 73 | type: "log", 74 | rotate: { 75 | size: "10M", 76 | encoding: "utf8", 77 | }, 78 | path: { 79 | // remember: add string *.log to .gitignore 80 | debug_log: "./debug.log", 81 | error_log: "./errors.log", 82 | }, 83 | }; 84 | 85 | const logger = new Logger(options); 86 | logger.info("message"); 87 | ``` 88 | 89 | See folder `examples`, run with `node example.js`. Below is available a description of `options` values. 90 | 91 | ## 🧰 Options 92 | 93 | | Parameter | Description | Values | Default value | Available since | 94 | | --------- | ------------------------------------------------------- | ------------------------------------- | ----------------------------------------------------------- | --------------- | 95 | | language | Set language of log type | en / it / pl / es / pt / de / ru / fr | en | **v1.0.0** | 96 | | colors | Enable colors in terminal | true / enabled / false / disabled | true | **v1.0.0** | 97 | | debug | Enable all logs with method debug | true / enabled / false / disabled | true | **v1.0.0** | 98 | | info | Enable all logs with method info | true / enabled / false / disabled | true | **v1.0.0** | 99 | | warning | Enable all logs with method warning | true / enabled / false / disabled | true | **v1.0.0** | 100 | | error | Enable all logs with method errors | true / enabled / false / disabled | true | **v1.0.0** | 101 | | sponsor | Enable all logs with method sponsor | true / enabled / false / disabled | true | **v1.0.0** | 102 | | write | Write the logs into a file, you need set path values | true / enabled / false / disabled | false | **v1.0.0** | 103 | | type | Format of logs in files | log / json | log | **v1.0.0** | 104 | | rotate | Rotates the log files when size exceeds this value | `10B` / `10K` / `10M` / `10G` | `"rotate": {"size": "10M"}` | **v1.5.0** | 105 | | palette | Change palette with hexcode colors | [Object](#-palette) | default palette | **v1.5.0** | 106 | | 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** | 107 | 108 | ## 🔌 Methods 109 | 110 | | Method | Description | Parameters | 111 | | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | 112 | | **debug**(`message`, `tag`) | `message`: Display debug log message
`tag`: prefix of message | `message`: string (mandatory)
`tag`: string (optional) | 113 | | **info**(`message`, `tag`) | `message`: Display info log message
`tag`: prefix of message | `message`: string (mandatory)
`tag`: string (optional) | 114 | | **warning**(`message`, `tag`) | `message`: Display warning log message
`tag`: prefix of message | `message`: string (mandatory)
`tag`: string (optional) | 115 | | **error**(`message`, `tag`) | `message`: Display errors log message
`tag`: prefix of message | `message`: string (mandatory)
`tag`: string (optional) | 116 | | **sponsor**(`message`, `tag`) | `message`: Display sponsor log message
`tag`: prefix of message | `message`: string (mandatory)
`tag`: string (optional) | 117 | | **stackoverflow**(`message`, `tag`, `error_string`) | `message`: Display stackoverflow log message
`tag`: prefix of message
`error_string`: query for stackoverflow, if empty we use message param | `message`: string (mandatory)
`tag`: string (optional)
`error_string`: string (optional) | 118 | | **docs**(`message`, `url`, `tag`) | `message`: Display docs log message
`url`: link of documentation
`tag`: prefix of message | `message`: string (mandatory)
`url`: string (optional)
`tag`: string (optional) | 119 | 120 | ## 🎨 Palette 121 | 122 | [![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) 123 | 124 | You can customize palette colors with Object `palette` and with hexcode values. 125 | 126 | - `label` is text on left (INFORMATION / ERROR / DOCS, etc..) 127 | - `text` is message of log on right 128 | - `background` is background color on left side 129 | 130 | ```javascript 131 | { 132 | ... 133 | "palette": { 134 | "info": { // method name 135 | "label": "#ffffff", // label on left 136 | "text": "#4CAF50", // log message 137 | "background": "#4CAF50" // background 138 | }, 139 | "warning": { 140 | "label": "#ffffff", 141 | "text": "#FF9800", 142 | "background": "#FF9800" 143 | }, 144 | "error": { 145 | "label": "#ffffff", 146 | "text": "#FF5252", 147 | "background": "#FF5252" 148 | }, 149 | "stackoverflow": { 150 | "label": "#ffffff", 151 | "text": "#9C27B0", 152 | "background": "#9C27B0" 153 | }, 154 | "docs": { 155 | "label": "#ffffff", 156 | "text": "#FF4081", 157 | "background": "#FF4081" 158 | }, 159 | "debug": { 160 | "label": "#ffffff", 161 | "text": "#1976D2", 162 | "background": "#1976D2" 163 | }, 164 | "sponsor": { 165 | "label": "#ffffff", 166 | "text": "#607D8B", 167 | "background": "#607D8B" 168 | }, 169 | "time": { 170 | "label": "#ffffff", 171 | "background": "#795548" 172 | } 173 | } 174 | ... 175 | } 176 | ``` 177 | 178 | See folder `examples`, run with `node example.js`. 179 | 180 | ## 🤹‍♂️ LogRotate 181 | 182 | Rotates the file when size exceeds 10 megabytes (optional, default 10M - values: 10B (byte) / 10K (kilobyte)/ 10M (megabyte)/ 10G (gigabyte)) 183 | 184 | ```javascript 185 | ... 186 | "rotate": { 187 | "size": "10M", 188 | "encoding": "utf8" 189 | }, 190 | ... 191 | ``` 192 | 193 | ## 📚 Documentation 194 | 195 | Run `npm run docs` 196 | 197 | ## 👑 Sponsors 198 | 199 | Support this project by becoming a sponsor. 🙏 Become a sponsor on [patreon](https://www.patreon.com/join/ptkdev) or become top3 sponsor on [ko-fi](https://ko-fi.com/ptkdev). Your logo will show up here with a link to your website. 200 | 201 | [![](https://api.ptkdev.io/backers/sponsor1.png)](https://api.ptkdev.io/backers/sponsor1.html) [![](https://api.ptkdev.io/backers/sponsor2.png)](https://api.ptkdev.io/backers/sponsor2.html) [![](https://api.ptkdev.io/backers/sponsor-kofi1.png)](https://api.ptkdev.io/backers/sponsor-kofi1.html) [![](https://api.ptkdev.io/backers/sponsor-kofi2.png)](https://api.ptkdev.io/backers/sponsor-kofi2.html) [![](https://api.ptkdev.io/backers/sponsor-kofi3.png)](https://api.ptkdev.io/backers/sponsor-kofi3.html) [![](https://api.ptkdev.io/backers/sponsor3.png)](https://api.ptkdev.io/backers/sponsor3.html) [![](https://api.ptkdev.io/backers/sponsor4.png)](https://api.ptkdev.io/backers/sponsor4.html) [![](https://api.ptkdev.io/backers/sponsor5.png)](https://api.ptkdev.io/backers/sponsor5.html) [![](https://api.ptkdev.io/backers/sponsor6.png)](https://api.ptkdev.io/backers/sponsor6.html) [![](https://api.ptkdev.io/backers/sponsor7.png)](https://api.ptkdev.io/backers/sponsor7.html) [![](https://api.ptkdev.io/backers/sponsor8.png)](https://api.ptkdev.io/backers/sponsor8.html) [![](https://api.ptkdev.io/backers/sponsor9.png)](https://api.ptkdev.io/backers/sponsor9.html) [![](https://api.ptkdev.io/backers/sponsor10.png)](https://api.ptkdev.io/backers/sponsor10.html) [![](https://api.ptkdev.io/backers/sponsor11.png)](https://api.ptkdev.io/backers/sponsor11.html) [![](https://api.ptkdev.io/backers/sponsor12.png)](https://api.ptkdev.io/backers/sponsor12.html) [![](https://api.ptkdev.io/backers/sponsor13.png)](https://api.ptkdev.io/backers/sponsor13.html) [![](https://api.ptkdev.io/backers/sponsor14.png)](https://api.ptkdev.io/backers/sponsor14.html) [![](https://api.ptkdev.io/backers/sponsor15.png)](https://api.ptkdev.io/backers/sponsor15.html) 202 | 203 | ## 🦄 Backers 204 | 205 | Thank you to all our backers! 🙏 Become a backer on [patreon](https://www.patreon.com/join/ptkdev). 206 | 207 | [![](https://api.ptkdev.io/backers/backer1.png)](https://api.ptkdev.io/backers/backer1.html) [![](https://api.ptkdev.io/backers/backer2.png)](https://api.ptkdev.io/backers/backer2.html) [![](https://api.ptkdev.io/backers/backer3.png)](https://api.ptkdev.io/backers/backer3.html) [![](https://api.ptkdev.io/backers/backer4.png)](https://api.ptkdev.io/backers/backer4.html) [![](https://api.ptkdev.io/backers/backer5.png)](https://api.ptkdev.io/backers/backer5.html) [![](https://api.ptkdev.io/backers/backer6.png)](https://api.ptkdev.io/backers/backer6.html) [![](https://api.ptkdev.io/backers/backer7.png)](https://api.ptkdev.io/backers/backer7.html) [![](https://api.ptkdev.io/backers/backer8.png)](https://api.ptkdev.io/backers/backer8.html) [![](https://api.ptkdev.io/backers/backer9.png)](https://api.ptkdev.io/backers/backer9.html) [![](https://api.ptkdev.io/backers/backer10.png)](https://api.ptkdev.io/backers/backer10.html) [![](https://api.ptkdev.io/backers/backer11.png)](https://api.ptkdev.io/backers/backer11.html) [![](https://api.ptkdev.io/backers/backer12.png)](https://api.ptkdev.io/backers/backer12.html) [![](https://api.ptkdev.io/backers/backer13.png)](https://api.ptkdev.io/backers/backer13.html) [![](https://api.ptkdev.io/backers/backer14.png)](https://api.ptkdev.io/backers/backer14.html) [![](https://api.ptkdev.io/backers/backer15.png)](https://api.ptkdev.io/backers/backer15.html) 208 | 209 | ## 👨‍💻 Contributing 210 | 211 | I ❤️ contributions! I will happily accept your pull request! Translations, grammatical corrections (GrammarNazi you are welcome! Yes my English is bad, sorry), etc... Do not be afraid, if the code is not perfect we will work together 👯 and remember to insert your name in `.all-contributorsrc` and `package.json` file. 212 | 213 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 |

Patryk Rzucidło

💻 🌍 📖 🐛

Ilua Chubarov

💻

Bruno Kümmel

💻 🌍

Alina Osv

🌍

Sylvain Téchené

🌍

Giovanni Cardamone

💻
228 | 229 | 230 | 231 | 232 | 233 | 234 | > 💰 In the future, if the donations allow it, I would like to share some of the success with those who helped me the most. For me open source is share of code, share development knowledges and share donations! 235 | 236 | ## 📲 Tools 237 | 238 | [![](https://img.shields.io/badge/portfolio-ptkdev-000000.svg)](https://ptk.dev/) 239 | [![](https://img.shields.io/badge/app-meingifs-E1215B.svg)](https://meingifs.pics/) 240 | [![](https://img.shields.io/badge/stickers-ptkdev-128C7E.svg)](https://stickers.ptkdev.io/) 241 | 242 | [![](https://img.shields.io/badge/app-social%20manager%20tools-ff7f19.svg)](http://logger.ptkdev.io/) 243 | [![](https://img.shields.io/badge/api-instagram%20bot-895a4d.svg)](https://github.com/ptkdev/ptkdev-logger) 244 | [![](https://img.shields.io/badge/api-twitter%20bot-21B7F4.svg)](https://github.com/social-manager-tools/socialmanagertools-twbot) 245 | [![](https://img.shields.io/badge/api-facebook%20bot-3b5998.svg)](https://github.com/social-manager-tools/socialmanagertools-fbbot) 246 | [![](https://img.shields.io/badge/telegram%20bot-feed%20rss%20for%20wordpress%20&%20medium-00AB6C.svg)](https://github.com/social-manager-tools/socialmanagertools-tgbot) 247 | 248 | ## 🐍 Sorry for snake_case 249 | 250 | I love snake_case syntax sorry for this 😭 don't hate me. 251 | 252 | ## 💫 License 253 | 254 | - Code and Contributions have **MIT License** 255 | - Images and logos have **CC BY-NC 4.0 License** ([Freepik](https://it.freepik.com/) Premium License) 256 | - Documentations and Translations have **CC BY 4.0 License** 257 | 258 | ###### Copyleft (c) 2020 [Patryk Rzucidło](https://ptk.dev) ([@PTKDev](https://twitter.com/ptkdev)) <[support@ptkdev.io](mailto:support@ptkdev.io)> 259 | -------------------------------------------------------------------------------- /examples/example-json.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Logger: example (json output) 3 | * ===================== 4 | * 5 | * @contributors: Patryk Rzucidło [@ptkdev] (https://ptk.dev) 6 | * 7 | * @license: MIT License 8 | * 9 | */ 10 | const Logger = require("./../modules/logger"); // in your project use: require("@ptkdev/logger"); 11 | 12 | const options = { 13 | "language": "en", // set language of log type, NOTE: please help with translations! (optional, default en - values: en|it|pl|es|pt|de|ru) 14 | "colors": true, // enable/disable colors in terminal (optional, default enabled - values: true|enabled or false|disabled) 15 | "debug": true, // enable/disable all logs with method debug (optional, default enabled - values: true|enabled or false|disabled) 16 | "info": true, // enable/disable all logs with method info (optional, default enabled - values: true|enabled or false|disabled) 17 | "warning": true, // enable/disable all logs with method warning (optional, default enabled - values: true|enabled or false|disabled) 18 | "error": true, // enable/disable all logs with method errors (optional, default enabled - values: true|enabled or false|disabled) 19 | "sponsor": true, // enable/disable all logs with method sponsor (optional, default enabled - values: true|enabled or false|disabled) 20 | "write": true, // write the logs into a file, you need set path values (optional, default disabled - values: true|enabled or false|disabled) 21 | "type": "json", // format of logs in files (optional, default log - values: log|json) 22 | "path": { // if write is true, the library writes the logs to a path 23 | "debug_log": "./debug.json", // all logs 24 | "error_log": "./errors.json", // only errors logs 25 | } 26 | }; 27 | 28 | const logger = new Logger(options); 29 | logger.info("your info message", "your tag"); 30 | logger.warning("your warning message", "your tag"); 31 | logger.error("your error message", "your tag"); 32 | logger.debug("your debug message", "your tag"); 33 | logger.sponsor("your sponsor message", "your tag"); 34 | logger.stackoverflow("your stackoverflow message", "your tag"); 35 | logger.docs("your docs message", "https://docs.yoursite.com", "your tag"); -------------------------------------------------------------------------------- /examples/example.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Logger: example 3 | * ===================== 4 | * 5 | * @contributors: Patryk Rzucidło [@ptkdev] (https://ptk.dev) 6 | * 7 | * @license: MIT License 8 | * 9 | */ 10 | const Logger = require("./../modules/logger"); // in your project use: require("@ptkdev/logger"); 11 | 12 | const options = { 13 | "language": "en", // set language of log type, NOTE: please help with translations! (optional, default en - values: en|it|pl|es|pt|de|ru) 14 | "colors": true, // enable/disable colors in terminal (optional, default enabled - values: true|enabled or false|disabled) 15 | "debug": true, // enable/disable all logs with method debug (optional, default enabled - values: true|enabled or false|disabled) 16 | "info": true, // enable/disable all logs with method info (optional, default enabled - values: true|enabled or false|disabled) 17 | "warning": true, // enable/disable all logs with method warning (optional, default enabled - values: true|enabled or false|disabled) 18 | "error": true, // enable/disable all logs with method errors (optional, default enabled - values: true|enabled or false|disabled) 19 | "sponsor": true, // enable/disable all logs with method sponsor (optional, default enabled - values: true|enabled or false|disabled) 20 | "write": true, // write the logs into a file, you need set path values (optional, default disabled - values: true|enabled or false|disabled) 21 | "type": "log", // format of logs in files (optional, default log - values: log|json) 22 | "rotate": { 23 | "size": "10M", // Rotates the file when size exceeds 10 megabytes (optional, default 10M - values: 10B (byte) / 10K (kilobyte)/ 10M (megabyte)/ 10G (gigabyte)) 24 | "encoding": "utf8" 25 | }, 26 | "path": { // if write is true, the library writes the logs to a path 27 | "debug_log": "./debug.log", // all logs 28 | "error_log": "./errors.log", // only errors logs 29 | }, 30 | "palette": { 31 | "info": { 32 | "label": "#ffffff", // label on left 33 | "text": "#2ECC71", // log message 34 | "background": "#2ECC71" // background 35 | }, 36 | "warning": { 37 | "label": "#ffffff", 38 | "text": "#FF9800", 39 | "background": "#FF9800" 40 | }, 41 | "error": { 42 | "label": "#ffffff", 43 | "text": "#FF5252", 44 | "background": "#FF5252" 45 | }, 46 | "stackoverflow": { 47 | "label": "#ffffff", 48 | "text": "#9C27B0", 49 | "background": "#9C27B0" 50 | }, 51 | "docs": { 52 | "label": "#ffffff", 53 | "text": "#FF4081", 54 | "background": "#FF4081" 55 | }, 56 | "debug": { 57 | "label": "#ffffff", 58 | "text": "#1976D2", 59 | "background": "#1976D2" 60 | }, 61 | "sponsor": { 62 | "label": "#ffffff", 63 | "text": "#607D8B", 64 | "background": "#607D8B" 65 | }, 66 | "time": { 67 | "label": "#ffffff", 68 | "background": "#795548" 69 | } 70 | } 71 | }; 72 | 73 | const logger = new Logger(options); 74 | logger.info("your info message", "your tag"); 75 | logger.warning("your warning message", "your tag"); 76 | logger.error("your error message", "your tag"); 77 | logger.debug("your debug message", "your tag"); 78 | logger.sponsor("your sponsor message", "your tag"); 79 | logger.stackoverflow("your stackoverflow message", "your tag"); 80 | logger.docs("your docs message", "https://docs.yoursite.com", "your tag"); -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "exclude": [ 3 | "node_modules" 4 | ], 5 | "include": [ 6 | "**/*.js" 7 | ] 8 | } -------------------------------------------------------------------------------- /modules/logger.d.ts: -------------------------------------------------------------------------------- 1 | declare module "@ptkdev/logger" { 2 | interface RotateType { 3 | size: "10B" | "10K" | "10M" | "10G"; 4 | encoding?: string; 5 | } 6 | 7 | interface PaletteElement { 8 | label: string; 9 | text: string; 10 | background: string; 11 | } 12 | 13 | interface PaletteType { 14 | info?: PaletteElement; 15 | warning?: PaletteElement; 16 | error?: PaletteElement; 17 | stackoverflow?: PaletteElement; 18 | docs?: PaletteElement; 19 | debug?: PaletteElement; 20 | sponsor?: PaletteElement; 21 | time?: Omit; 22 | } 23 | 24 | interface PathType { 25 | debug_log: string; 26 | error_log: string; 27 | } 28 | 29 | interface LoggerOptions { 30 | language?: "de" | "en" | "es" | "fr" | "it" | "pl" | "pt" | "ru"; 31 | colors?: boolean; 32 | debug?: boolean; 33 | info?: boolean; 34 | warning?: boolean; 35 | error?: boolean; 36 | sponsor?: boolean; 37 | write?: boolean; 38 | type?: "log" | "json"; 39 | rotate?: RotateType; 40 | palette?: PaletteType; 41 | path?: PathType; 42 | } 43 | 44 | export default class Logger { 45 | constructor(options?: LoggerOptions); 46 | 47 | /** 48 | * Logging of the debug message 49 | * ===================== 50 | * This method show message on terminal and/or write message on file/json 51 | * 52 | * @param {string} message - description of issue (mandatory) 53 | * @param {string} tag - func unique tag (optional) 54 | * 55 | */ 56 | debug(message: string, tag?: string): void; 57 | 58 | /** 59 | * Logging of the info message 60 | * ===================== 61 | * This method show message on terminal and/or write message on file/json 62 | * 63 | * @param {string} message - description of issue (mandatory) 64 | * @param {string} tag - func unique tag (optional) 65 | * 66 | */ 67 | info(message: string, tag?: string): void; 68 | 69 | /** 70 | * Logging of the warning message 71 | * ===================== 72 | * This method show message on terminal and/or write message on file/json 73 | * 74 | * @param {string} message - description of issue (mandatory) 75 | * @param {string} tag - func unique tag (optional) 76 | * 77 | */ 78 | warning(message: string, tag?: string): void; 79 | 80 | /** 81 | * Logging of the error message 82 | * ===================== 83 | * This method show message on terminal and/or write message on file/json 84 | * 85 | * @param {string} message - description of issue (mandatory) 86 | * @param {string} tag - func unique tag (optional) 87 | * 88 | */ 89 | error(message: string, tag?: string): void; 90 | 91 | /** 92 | * Logging of the sponsor message 93 | * ===================== 94 | * This method show message on terminal and/or write message on file/json 95 | * 96 | * @param {string} message - description of issue (mandatory) 97 | * @param {string} tag - func unique tag (optional) 98 | * 99 | */ 100 | sponsor(message: string, tag?: string): void; 101 | 102 | /** 103 | * Logging of the stackoverflow message 104 | * ===================== 105 | * This method show message on terminal and/or write message on file/json 106 | * 107 | * @param {string} message - description of issue (mandatory) 108 | * @param {string} tag - func unique tag (optional) 109 | * @param {string} error_message - error message to stackoverflow (optional) 110 | * 111 | */ 112 | stackoverflow( 113 | message: string, 114 | tag?: string, 115 | error_message?: string 116 | ): void; 117 | 118 | /** 119 | * Logging of the docs message 120 | * ===================== 121 | * This method show message on terminal and/or write message on file/json 122 | * 123 | * @param {string} message - description of issue (mandatory) 124 | * @param {string} url - url of documentation (optional) 125 | * @param {string} tag - func unique tag (optional) 126 | * 127 | * 128 | */ 129 | docs(message: string, url?: string, tag?: string): void; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /modules/logger.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Logger: write log 3 | * ===================== 4 | * 5 | * @contributors: Patryk Rzucidło [@ptkdev] (https://ptk.dev) 6 | * Ilya Chubarov [@agoalofalife] 7 | * 8 | * @license: MIT License 9 | * 10 | */ 11 | const path = require("path"); 12 | const fse = require("fs-extra"); 13 | const chalk = require("chalk"); 14 | const ansi = require("strip-ansi"); 15 | const rfs = require("rotating-file-stream"); 16 | const lowdb = require("lowdb"); 17 | const FileSync = require("lowdb/adapters/FileSync"); 18 | const languages = { 19 | de: require("../translations/de"), 20 | en: require("../translations/en"), 21 | es: require("../translations/es"), 22 | fr: require("../translations/fr"), 23 | it: require("../translations/it"), 24 | pl: require("../translations/pl"), 25 | pt: require("../translations/pt"), 26 | ru: require("../translations/ru") 27 | }; 28 | const logger = console; 29 | let Types = require("./types"); 30 | class Log { 31 | constructor(options = new Object) { 32 | if (typeof options.language === "undefined" || options.language === null) { 33 | options.language = "en"; 34 | } 35 | 36 | Types.INFO.label = languages[options.language]["INFO"]; 37 | Types.WARNING.label = languages[options.language]["WARNING"]; 38 | Types.ERROR.label = languages[options.language]["ERROR"]; 39 | Types.DEBUG.label = languages[options.language]["DEBUG"]; 40 | Types.DOCS.label = languages[options.language]["DOCS"]; 41 | Types.STACKOVERFLOW.label = languages[options.language]["STACKOVERFLOW"]; 42 | Types.SPONSOR.label = languages[options.language]["SPONSOR"]; 43 | 44 | if (typeof options.palette === "undefined" || options.palette === null) { 45 | options.palette = null; 46 | } else { 47 | if (typeof options.palette.info !== "undefined" && options.palette.info !== null) { 48 | Types.INFO.bgcolor = (typeof options.palette.info.background === "undefined" || options.palette.info.background === null) ? Types.INFO.bgcolor : chalk.bgHex(options.palette.info.background).hex(options.palette.info.label); 49 | Types.INFO.color = (typeof options.palette.info.text === "undefined" || options.palette.info.text === null) ? Types.INFO.color : chalk.hex(options.palette.info.text); 50 | } 51 | 52 | if (typeof options.palette.warning !== "undefined" && options.palette.warning !== null) { 53 | Types.WARNING.bgcolor = (typeof options.palette.warning.background === "undefined" || options.palette.warning.background === null) ? Types.WARNING.bgcolor : chalk.bgHex(options.palette.warning.background).hex(options.palette.warning.label); 54 | Types.WARNING.color = (typeof options.palette.warning.text === "undefined" || options.palette.warning.text === null) ? Types.WARNING.color : chalk.hex(options.palette.warning.text); 55 | } 56 | 57 | if (typeof options.palette.error !== "undefined" && options.palette.error !== null) { 58 | Types.ERROR.bgcolor = (typeof options.palette.error.background === "undefined" || options.palette.error.background === null) ? Types.ERROR.bgcolor : chalk.bgHex(options.palette.error.background).hex(options.palette.error.label); 59 | Types.ERROR.color = (typeof options.palette.error.text === "undefined" || options.palette.error.text === null) ? Types.ERROR.color : chalk.hex(options.palette.error.text); 60 | } 61 | 62 | if (typeof options.palette.debug !== "undefined" && options.palette.debug !== null) { 63 | Types.DEBUG.bgcolor = (typeof options.palette.debug.background === "undefined" || options.palette.debug.background === null) ? Types.DEBUG.bgcolor : chalk.bgHex(options.palette.debug.background).hex(options.palette.debug.label); 64 | Types.DEBUG.color = (typeof options.palette.debug.text === "undefined" || options.palette.debug.text === null) ? Types.DEBUG.color : chalk.hex(options.palette.debug.text); 65 | } 66 | 67 | if (typeof options.palette.docs !== "undefined" && options.palette.docs !== null) { 68 | Types.DOCS.bgcolor = (typeof options.palette.docs.background === "undefined" || options.palette.docs.background === null) ? Types.DOCS.bgcolor : chalk.bgHex(options.palette.docs.background).hex(options.palette.docs.label); 69 | Types.DOCS.color = (typeof options.palette.docs.text === "undefined" || options.palette.docs.text === null) ? Types.DOCS.color : chalk.hex(options.palette.docs.text); 70 | } 71 | 72 | if (typeof options.palette.stackoverflow !== "undefined" && options.palette.stackoverflow !== null) { 73 | Types.STACKOVERFLOW.bgcolor = (typeof options.palette.stackoverflow.background === "undefined" || options.palette.stackoverflow.background === null) ? Types.STACKOVERFLOW.bgcolor : chalk.bgHex(options.palette.stackoverflow.background).hex(options.palette.stackoverflow.label); 74 | Types.STACKOVERFLOW.color = (typeof options.palette.stackoverflow.text === "undefined" || options.palette.stackoverflow.text === null) ? Types.STACKOVERFLOW.color : chalk.hex(options.palette.stackoverflow.text); 75 | } 76 | 77 | if (typeof options.palette.sponsor !== "undefined" && options.palette.sponsor !== null) { 78 | Types.SPONSOR.bgcolor = (typeof options.palette.sponsor.background === "undefined" || options.palette.sponsor.background === null) ? Types.SPONSOR.bgcolor : chalk.bgHex(options.palette.sponsor.background).hex(options.palette.sponsor.label); 79 | Types.SPONSOR.color = (typeof options.palette.sponsor.text === "undefined" || options.palette.sponsor.text === null) ? Types.SPONSOR.color : chalk.hex(options.palette.sponsor.text); 80 | } 81 | 82 | if (typeof options.palette.time !== "undefined" && options.palette.time !== null) { 83 | Types.TIME.bgcolor = (typeof options.palette.time.background === "undefined" || options.palette.time.background === null) ? Types.TIME.bgcolor : chalk.bgHex(options.palette.time.background).hex(options.palette.time.label); 84 | Types.TIME.color = (typeof options.palette.time.text === "undefined" || options.palette.time.text === null) ? Types.TIME.color : chalk.hex(options.palette.time.text); 85 | } 86 | } 87 | 88 | if (typeof options.colors === "undefined" || options.colors === null) { 89 | options.colors = true; 90 | } 91 | 92 | if (typeof options.debug === "undefined" || options.debug === null) { 93 | options.debug = true; 94 | } 95 | 96 | if (typeof options.info === "undefined" || options.info === null) { 97 | options.info = true; 98 | } 99 | 100 | if (typeof options.warning === "undefined" || options.warning === null) { 101 | options.warning = true; 102 | } 103 | 104 | if (typeof options.error === "undefined" || options.error === null) { 105 | options.error = true; 106 | } 107 | 108 | if (typeof options.type === "undefined" || options.type === null) { 109 | options.type = "log"; 110 | } 111 | 112 | if (typeof options.write === "undefined" || options.write === null) { 113 | options.write = false; 114 | } else if (typeof options.path === "undefined" || options.path === null) { 115 | if (typeof options.debug_log === "undefined" || options.debug_log === null) { 116 | options.debug_log = "./debug.log"; 117 | } 118 | 119 | if (typeof options.error_log === "undefined" || options.error_log === null) { 120 | options.error_log = "./errors.log"; 121 | } 122 | } 123 | 124 | if (typeof options.rotate === "undefined" || options.rotate === null) { 125 | options.rotate = { 126 | size: "10M", 127 | encoding: "utf8" 128 | }; 129 | } 130 | 131 | this.config = options; 132 | 133 | if (this.config.write === "enabled" || this.config.write === true) { 134 | const pad = num => (num > 9 ? "" : "0") + num; 135 | rfs.createStream((time, index) => { 136 | if (!time) { 137 | return this.config.path.debug_log; 138 | } 139 | 140 | return `${path.parse(this.config.path.debug_log).base.split(".")[0]}.${time.getFullYear()}${pad(time.getMonth() + 1)}${pad(time.getDate())}-${index}.${path.parse(this.config.path.debug_log).base.split(".")[1]}`; 141 | }, this.config.rotate); 142 | 143 | rfs.createStream((time, index) => { 144 | if (!time) { 145 | return this.config.path.error_log; 146 | } 147 | 148 | return `${path.parse(this.config.path.error_log).base.split(".")[0]}.${time.getFullYear()}${pad(time.getMonth() + 1)}${pad(time.getDate())}-${index}.${path.parse(this.config.path.error_log).base.split(".")[1]}`; 149 | }, this.config.rotate); 150 | 151 | } 152 | this.TYPES_LOG = Types; 153 | } 154 | 155 | /** 156 | * Date now 157 | * ===================== 158 | * Current (now) date and time for prefix of logs. Timezone is supported. 159 | * 160 | * @param {string} format - format of date: json, timestamp or string (optional, deafult: string) 161 | 162 | * @return {string} time - current Date.now() 163 | * 164 | */ 165 | currentTime(format = "string") { 166 | let tz_offset = (new Date()).getTimezoneOffset() * 60000; 167 | 168 | if (format === "json") { 169 | return (new Date(Date.now() - tz_offset)).toISOString(); 170 | } 171 | 172 | if (format === "timestamp") { 173 | return (new Date(Date.now() - tz_offset)).getTime(); 174 | } 175 | 176 | return (new Date(Date.now() - tz_offset)).toISOString().slice(0, -5).replace("T", " "); 177 | 178 | } 179 | 180 | /** 181 | * Write the output of console.log() to file 182 | * ===================== 183 | * Write messages to debug.log and error.log in /logs folder 184 | * 185 | * @param {string} type - example: INFO/WARNING/ERROR/DEBUG or other valid type string (see ./types.js) (mandatory) 186 | * @param {string} message - description of issue (mandatory) 187 | * @param {string} tag - func unique tag (optional) 188 | * 189 | */ 190 | appendFile(type = "INFO", tag = "", message = "") { 191 | if (this.config.write === "enabled" || this.config.write === true) { 192 | if (this.config.type === "log") { 193 | if (tag !== "") { 194 | tag = `${tag}: `; 195 | } 196 | let log_text = `[${this.currentTime()}] [${type.id}] ${tag}${message}\n`; 197 | 198 | fse.appendFile(this.config.path.debug_log, ansi(log_text), (err) => { 199 | if (err) { 200 | logger.log(err); 201 | } 202 | }); 203 | 204 | if (type.id === "ERROR") { 205 | fse.appendFile(this.config.path.error_log, ansi(log_text), (err) => { 206 | if (err) { 207 | logger.err(err); 208 | } 209 | }); 210 | } 211 | } else { 212 | 213 | const debug_adapter = new FileSync(this.config.path.debug_log); 214 | const debug_db = lowdb(debug_adapter); 215 | const error_adapter = new FileSync(this.config.path.error_log); 216 | const error_db = lowdb(error_adapter); 217 | let level = 0; 218 | 219 | switch (type.id) { 220 | case "ERROR": 221 | level = 1; 222 | break; 223 | case "WARNING": 224 | level = 2; 225 | break; 226 | case "INFO": 227 | level = 3; 228 | break; 229 | case "DEBUG": 230 | level = 4; 231 | break; 232 | default: 233 | level = 5; 234 | break; 235 | } 236 | 237 | debug_db.defaults({logs: []}).write(); 238 | error_db.defaults({logs: []}).write(); 239 | 240 | debug_db.get("logs").push({level: level, time: this.currentTime("timestamp"), date: this.currentTime("json"), msg: ansi(message), tag: ansi(tag), v: 1}).write(); 241 | 242 | if (type.id === "ERROR") { 243 | error_db.get("logs").push({level: level, time: this.currentTime("timestamp"), date: this.currentTime("json"), msg: ansi(message), tag: ansi(tag), v: 1}).write(); 244 | } 245 | } 246 | } 247 | } 248 | 249 | /** 250 | * Write to stdout 251 | * ===================== 252 | * Stdout manager - don't use this directly. Use info() error() debug() warning() 253 | * 254 | * @param {string} type - example: INFO/WARNING/ERROR/DEBUG or other valid type string (see ./types.js) (mandatory) 255 | * @param {string} tag - func unique tag (optional) 256 | * @param {string} message - error, warning or info description (mandatory) 257 | * 258 | */ 259 | stdout(type = "INFO", tag = "", message = "") { 260 | let time = this.TYPES_LOG.TIME; 261 | if (tag !== "") { 262 | tag = ` ${tag}:`; 263 | } 264 | if (this.config.colors === "enabled" || this.config.colors === true) { 265 | logger.log(chalk`${type.bgcolor(type.label)}${time.bgcolor(` ${this.currentTime()} `)}${type.bgcolor(" ")}${type.color(tag)} ${type.color(message)}`); 266 | } else { 267 | logger.log(ansi(chalk`${type.bgcolor(type.label)}${time.bgcolor(` ${this.currentTime()} `)}${type.bgcolor(" ")}${type.color(tag)} ${type.color(message)}`)); 268 | } 269 | } 270 | 271 | /** 272 | * Write to stderr 273 | * ===================== 274 | * Stderr manager - don't use this directly. Use info() error() debug() warning() 275 | * 276 | * @param {string} type - example: INFO/WARNING/ERROR/DEBUG or other valid type string (see ./types.js) (mandatory) 277 | * @param {string} tag - func unique tag (optional) 278 | * @param {string} message - error, warning or info description (mandatory) 279 | * 280 | */ 281 | stderr(type = "ERROR", tag = "", message = "") { 282 | let time = this.TYPES_LOG.TIME; 283 | if (tag !== "") { 284 | tag = ` ${tag}:`; 285 | } 286 | if (this.config.colors === "enabled" || this.config.colors === true) { 287 | logger.error(chalk`${type.bgcolor(type.label)}${time.bgcolor(` ${this.currentTime()} `)}${type.bgcolor(" ")}${type.color(tag)} ${type.color(message)}`); 288 | } else { 289 | logger.error(ansi(chalk`${type.bgcolor(type.label)}${time.bgcolor(` ${this.currentTime()} `)}${type.bgcolor(" ")}${type.color(tag)} ${type.color(message)}`)); 290 | } 291 | } 292 | 293 | /** 294 | * Logging of the info message 295 | * ===================== 296 | * This method show message on terminal and/or write message on file/json 297 | * 298 | * @param {string} message - description of issue (mandatory) 299 | * @param {string} tag - func unique tag (optional) 300 | * 301 | */ 302 | info(message = "", tag = "") { 303 | if (this.config.info === "enabled" || this.config.info === true) { 304 | this.stdout(this.TYPES_LOG.INFO, tag, `${message}`); 305 | this.appendFile(this.TYPES_LOG.INFO, tag, message); 306 | } 307 | } 308 | 309 | /** 310 | * Logging of the warning message 311 | * ===================== 312 | * This method show message on terminal and/or write message on file/json 313 | * 314 | * @param {string} message - description of issue (mandatory) 315 | * @param {string} tag - func unique tag (optional) 316 | * 317 | */ 318 | warning(message = "", tag = "") { 319 | if (this.config.warning === "enabled" || this.config.warning === true) { 320 | this.stdout(this.TYPES_LOG.WARNING, tag, `${message}`); 321 | this.appendFile(this.TYPES_LOG.WARNING, tag, message); 322 | } 323 | } 324 | 325 | /** 326 | * Logging of the error message 327 | * ===================== 328 | * This method show message on terminal and/or write message on file/json 329 | * 330 | * @param {string} message - description of issue (mandatory) 331 | * @param {string} tag - func unique tag (optional) 332 | * 333 | */ 334 | error(message = "", tag = "") { 335 | if (this.config.error === "enabled" || this.config.error === true) { 336 | this.stderr(this.TYPES_LOG.ERROR, tag, `${message}`); 337 | this.appendFile(this.TYPES_LOG.ERROR, tag, message); 338 | } 339 | } 340 | 341 | /** 342 | * Logging of the debug message 343 | * ===================== 344 | * This method show message on terminal and/or write message on file/json 345 | * 346 | * @param {string} message - description of issue (mandatory) 347 | * @param {string} tag - func unique tag (optional) 348 | * 349 | */ 350 | debug(message = "", tag = "") { 351 | if (this.config.debug === "enabled" || this.config.debug === true) { 352 | this.stdout(this.TYPES_LOG.DEBUG, tag, `${message}`); 353 | this.appendFile(this.TYPES_LOG.DEBUG, tag, message); 354 | } 355 | } 356 | 357 | /** 358 | * Logging of the docs message 359 | * ===================== 360 | * This method show message on terminal and/or write message on file/json 361 | * 362 | * @param {string} message - description of issue (mandatory) 363 | * @param {string} url - url of documentation (optional) 364 | * @param {string} tag - func unique tag (optional) 365 | * 366 | */ 367 | docs(message = "", url = "", tag = "") { 368 | let docs = this.TYPES_LOG.DOCS; 369 | 370 | this.stdout(this.TYPES_LOG.DOCS, tag, `${message} - ${docs.color.underline.italic(url)}`); 371 | this.appendFile(this.TYPES_LOG.DOCS, tag, `${message} - ${docs.color.underline.italic(url)}`); 372 | } 373 | 374 | /** 375 | * Logging of the stackoverflow message 376 | * ===================== 377 | * This method show message on terminal and/or write message on file/json 378 | * 379 | * @param {string} message - description of issue (mandatory) 380 | * @param {string} tag - func unique tag (optional) 381 | * @param {string} error_message - error message to stackoverflow (optional) 382 | * 383 | */ 384 | stackoverflow(message = "", tag = "", error_message = null) { 385 | if (typeof error_message === "undefined" || error_message === null) { 386 | error_message = message; 387 | } 388 | 389 | let stackoverflow = this.TYPES_LOG.STACKOVERFLOW; 390 | 391 | let url = `https://stackoverflow.com/search?q=${encodeURI(error_message)}`; 392 | this.stdout(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${stackoverflow.color.underline.italic(url)}`); 393 | this.appendFile(this.TYPES_LOG.STACKOVERFLOW, tag, `${message} - ${stackoverflow.color.underline.italic(url)}`); 394 | } 395 | 396 | /** 397 | * Logging of the sponsor message 398 | * ===================== 399 | * This method show message on terminal and/or write message on file/json 400 | * 401 | * @param {string} message - description of issue (mandatory) 402 | * @param {string} tag - func unique tag (optional) 403 | * 404 | */ 405 | sponsor(message = "", tag = "") { 406 | this.stdout(this.TYPES_LOG.SPONSOR, tag, message); 407 | this.appendFile(this.TYPES_LOG.SPONSOR, tag, message); 408 | } 409 | } 410 | 411 | module.exports = Log; 412 | module.exports.default = Log; -------------------------------------------------------------------------------- /modules/types.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Types 3 | * ===================== 4 | * Color and tags of debug and log message 5 | * 6 | * @contributors: Patryk Rzucidło [@ptkdev] (https://ptk.dev) 7 | * Ilya Chubarov [@agoalofalife] 8 | * 9 | * @license: MIT License 10 | * 11 | */ 12 | const chalk = require("chalk"); 13 | 14 | module.exports = { 15 | DEBUG: { 16 | bgcolor: chalk.bgRgb(155, 89, 182).white.bold, 17 | color: chalk.rgb(155, 89, 182), 18 | id: "DEBUG", 19 | label: " | INFORMATION " 20 | }, 21 | DOCS: { 22 | bgcolor: chalk.bgRgb(236, 135, 191).white.bold, 23 | color: chalk.rgb(236, 135, 191), 24 | id: "DOCS", 25 | label: " | DOCUMENTATION " 26 | }, 27 | ERROR: { 28 | bgcolor: chalk.bgRgb(192, 57, 43).white.bold, 29 | color: chalk.rgb(192, 57, 43), 30 | id: "ERROR", 31 | label: " | ERROR " 32 | }, 33 | INFO: { 34 | bgcolor: chalk.bgRgb(76, 175, 80).white.bold, 35 | color: chalk.rgb(76, 175, 80), 36 | id: "INFO", 37 | label: " | INFORMATION " 38 | }, 39 | SPONSOR: { 40 | bgcolor: chalk.bgRgb(22, 160, 133).white.bold, 41 | color: chalk.rgb(22, 160, 133), 42 | id: "SPONSOR", 43 | label: " | SPONSOR " 44 | }, 45 | STACKOVERFLOW: { 46 | bgcolor: chalk.bgRgb(41, 128, 185).white.bold, 47 | color: chalk.rgb(41, 128, 185), 48 | id: "STACKOVERFLOW", 49 | label: " | STACKOVERFLOW " 50 | }, 51 | TIME: { 52 | bgcolor: chalk.bgRgb(44, 62, 80).white.bold, 53 | color: chalk.rgb(44, 62, 80), 54 | id: "TIME", 55 | label: " | TIME " 56 | }, 57 | WARNING: { 58 | bgcolor: chalk.bgRgb(243, 156, 18).white.bold, 59 | color: chalk.rgb(243, 156, 18), 60 | id: "WARNING", 61 | label: " | WARNING " 62 | } 63 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ptkdev/logger", 3 | "description": "Beautiful Logger for Node.js: the best alternative to the console.log statement", 4 | "version": "1.8.0", 5 | "main": "modules/logger.js", 6 | "author": "Patryk Rzucidło [@ptkdev] (https://ptk.dev)", 7 | "license": "MIT", 8 | "license-docs": "CC BY 4.0", 9 | "license-translations": "CC BY 4.0", 10 | "license-images": "CC BY-NC 4.0", 11 | "homepage": "https://logger.ptkdev.io", 12 | "docs": "https://docs.logger.ptkdev.io", 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/ptkdev/ptkdev-logger.git" 16 | }, 17 | "bugs": { 18 | "url": "https://github.com/ptkdev/ptkdev-logger/issues" 19 | }, 20 | "scripts": { 21 | "example": "cd examples && node examples/example.js", 22 | "clean": "rm -rf node_modules package-lock.json && npm install", 23 | "update": "rm -f package-lock.json && npm update", 24 | "lint": "eslint ./ --cache --ignore-pattern .gitignore", 25 | "lint-fix": "eslint ./ --cache --ignore-pattern .gitignore --fix", 26 | "git-set-upstream": "git remote add upstream git@github.com:ptkdev/ptkdev-logger.git && git fetch upstream", 27 | "git-pull-upstream": "git pull upstream master && git pull upstream beta && git pull upstream nightly", 28 | "git-pull": "git pull --recursive", 29 | "git-ignore-reset": "git rm -r --cached . && git add . && git commit -m \"[Fix] Removing all files in .gitignore\"", 30 | "npm-publish-master": "git checkout master && npm publish", 31 | "npm-publish-beta": "git checkout beta && npm publish --tag beta", 32 | "npm-publish-nightly": "git checkout nightly && npm publish --tag nightly", 33 | "docs": "git submodule update --recursive && markserv ./README.md", 34 | "test": "jest", 35 | "contributors-generate": "all-contributors generate", 36 | "pkg-upgrade": "npx npm-check-updates -u && npm install && husky install" 37 | }, 38 | "husky": { 39 | "hooks": { 40 | "pre-commit": "npm run lint && npm run contributors-generate" 41 | } 42 | }, 43 | "keywords": [ 44 | "ptkdev", 45 | "logger", 46 | "log", 47 | "logging", 48 | "console.log", 49 | "pinojs", 50 | "pino-logger", 51 | "pino", 52 | "typescript" 53 | ], 54 | "engines": { 55 | "node": ">=10.0.0" 56 | }, 57 | "dependencies": { 58 | "rotating-file-stream": "^2.1.5", 59 | "chalk": "^4.1.2", 60 | "lowdb": "^1.0.0", 61 | "fs-extra": "^10.0.0", 62 | "strip-ansi": "^6.0.0" 63 | }, 64 | "devDependencies": { 65 | "@ptkdev/all-shields-cli": "^2.0.2", 66 | "eslint": "^7.32.0", 67 | "eslint-plugin-jsdoc": "^36.0.8", 68 | "eslint-plugin-jest": "^24.4.0", 69 | "all-contributors-cli": "^6.20.0", 70 | "pm2": "^5.1.1", 71 | "json": "^11.0.0", 72 | "jest": "^27.1.0", 73 | "husky": "^7.0.2", 74 | "yargs": "^17.1.1", 75 | "markserv": "^1.17.4" 76 | }, 77 | "contributors": [ 78 | "Ilua Chubarov [@Ilya] (https://github.com/agoalofalife)", 79 | "Bruno Kummel [@Bruck1701] (https://github.com/Bruck1701)", 80 | "Alina Osv [@alinaosv] (https://github.com/alinaosv)", 81 | "Sylvain Téchené [@syltech] (https://github.com/Syltech)", 82 | "Giovanni Cardamone [@GiovanniCardamone] (https://github.com/GiovanniCardamone)" 83 | ] 84 | } 85 | -------------------------------------------------------------------------------- /translations/de.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: Portuguese 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {white.bold.bgRgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate white.bold.bgRgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"done"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Alina Osv [@alinaosv] (https://github.com/alinaosv) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | INFORMATION ", 20 | WARNING: " | WARNUNG ", 21 | ERROR: " | FEHLER ", 22 | DEBUG: " | DEBUG ", 23 | DOCS: " | DOKUMENTATION ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | SPONSOR " 26 | }; -------------------------------------------------------------------------------- /translations/en.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: English 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {italic.bold.rgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate italic.bold.rgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"i'm here"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Patryk Rzucidło [@ptkdev] (https://ptk.dev) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | INFORMATION ", 20 | WARNING: " | WARNING ", 21 | ERROR: " | ERROR ", 22 | DEBUG: " | DEBUG ", 23 | DOCS: " | DOCUMENTATION ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | SPONSOR " 26 | }; -------------------------------------------------------------------------------- /translations/es.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: Spanish 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {white.bold.bgRgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate white.bold.bgRgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"done"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Bruno Kummel [@Bruck1701] (https://github.com/Bruck1701) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | INFORMACIÓN ", 20 | WARNING: " | ADVERTENCIA ", 21 | ERROR: " | ERROR ", 22 | DEBUG: " | DEBUG ", 23 | DOCS: " | DOCUMENTACIÓN ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | SPONSOR " 26 | }; 27 | -------------------------------------------------------------------------------- /translations/fr.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: English 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {italic.bold.rgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate italic.bold.rgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"i'm here"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Sylvain Téchené [@Syltech] (https://github.com/Syltech) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | INFORMATION ", 20 | WARNING: " | ALERTE ", 21 | ERROR: " | ERREUR ", 22 | DEBUG: " | DEBUG ", 23 | DOCS: " | DOCUMENTATION ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | SPONSOR " 26 | }; -------------------------------------------------------------------------------- /translations/it.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: Italian 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {white.bold.bgRgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate white.bold.bgRgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"done"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Patryk Rzucidło [@ptkdev] (https://ptk.dev) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | INFORMAZIONI ", 20 | WARNING: " | ATTENZIONE ", 21 | ERROR: " | ERRORE ", 22 | DEBUG: " | DEBUG ", 23 | DOCS: " | DOCUMENTAZIONE ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | SPONSOR " 26 | }; -------------------------------------------------------------------------------- /translations/pl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: Polski 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {white.bold.bgRgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate white.bold.bgRgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"done"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Patryk Rzucidło [@ptkdev] (https://ptk.dev) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | INFORMACJA ", 20 | WARNING: " | UWAGA ", 21 | ERROR: " | BŁĄD ", 22 | DEBUG: " | DEBUG ", 23 | DOCS: " | DOKUMENTACJA ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | SPONSOR " 26 | }; -------------------------------------------------------------------------------- /translations/pt.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: Portuguese 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {white.bold.bgRgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate white.bold.bgRgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"done"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Bruno Kummel [@Bruck1701] (https://github.com/Bruck1701) / Joel Emanoel [@joelemanoel] (https://github.com/joelemanoel) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | INFORMAÇÃO ", 20 | WARNING: " | AVISO ", 21 | ERROR: " | ERRO ", 22 | DEBUG: " | DEBUG ", 23 | DOCS: " | DOCUMENTAÇÃO ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | PATROCINADOR " 26 | }; 27 | -------------------------------------------------------------------------------- /translations/ru.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation: Portuguese 3 | * ===================== 4 | * How translate: 5 | * Chalk: chalk is npm plugin to colorize text in terminal, example: {white.bold.bgRgb(46, 204, 113) TEXT_TEXT_TEXT } 6 | * don't translate white.bold.bgRgb but translate TEXT_TEXT_TEXT before of } 7 | * 8 | * Keys: don't translate keywords on left, example: {"done":"done"} 9 | * word on left side is keyword, ever in English. Translate only phrases on right side of two dots 10 | * 11 | * Param: don't translate words between ## ##, example: ##ciao## 12 | * 13 | * @contributors: Alina Osv [@alinaosv] (https://github.com/alinaosv) 14 | * 15 | * @license: CC BY 4.0 License 16 | * 17 | */ 18 | module.exports = { 19 | INFO: " | ИНФОРМАЦИЯ ", 20 | WARNING: " | ПРЕДУПРЕЖДЕНИЕ ", 21 | ERROR: " | ОШИБКА ", 22 | DEBUG: " | ОТЛАДКА ", 23 | DOCS: " | ДОКУМЕНТАЦИЯ ", 24 | STACKOVERFLOW: " | STACKOVERFLOW ", 25 | SPONSOR: " | СПОНСОР " 26 | }; 27 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "noImplicitAny": true, 6 | "noImplicitThis": true, 7 | "strictNullChecks": true, 8 | "strictFunctionTypes": true, 9 | "types": [], 10 | "noEmit": true, 11 | "forceConsistentCasingInFileNames": true 12 | }, 13 | "files": ["modules/logger.d.ts"] 14 | } 15 | --------------------------------------------------------------------------------