From ee695c7be3ebcedcc76c441f0ab4e14a3d77514b Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Sun, 7 Jan 2024 12:26:13 +0330 Subject: [PATCH] chore: remove logger --- demo/index.html | 1 - demo/logger/index.html | 18 -- demo/logger/index.ts | 38 --- demo/package.json | 2 +- demo/tsconfig.json | 1 - packages/crypto/package.json | 2 +- packages/crypto/tsconfig.json | 1 - packages/fetch/package.json | 2 +- packages/fetch/tsconfig.json | 1 - packages/logger/CHANGELOG.md | 414 -------------------------- packages/logger/README.md | 26 -- packages/logger/package.json | 37 --- packages/logger/src/define-package.ts | 37 --- packages/logger/src/global.ts | 21 -- packages/logger/src/index.ts | 4 - packages/logger/src/logger.ts | 122 -------- packages/logger/src/type.ts | 157 ---------- packages/logger/tsconfig.json | 13 - packages/math/package.json | 2 +- packages/math/tsconfig.json | 4 +- packages/nano-server/package.json | 2 +- packages/nano-server/tsconfig.json | 2 +- packages/util/package.json | 2 +- tsconfig.json | 1 - yarn.lock | 25 +- 25 files changed, 20 insertions(+), 915 deletions(-) delete mode 100644 demo/logger/index.html delete mode 100644 demo/logger/index.ts delete mode 100644 packages/logger/CHANGELOG.md delete mode 100644 packages/logger/README.md delete mode 100644 packages/logger/package.json delete mode 100644 packages/logger/src/define-package.ts delete mode 100644 packages/logger/src/global.ts delete mode 100644 packages/logger/src/index.ts delete mode 100644 packages/logger/src/logger.ts delete mode 100644 packages/logger/src/type.ts delete mode 100644 packages/logger/tsconfig.json diff --git a/demo/index.html b/demo/index.html index 5b1542ea..e36762ef 100644 --- a/demo/index.html +++ b/demo/index.html @@ -14,7 +14,6 @@
  1. ES Bench
  2. -
  3. Logger
  4. Fetch
  5. Math
  6. Validator
  7. diff --git a/demo/logger/index.html b/demo/logger/index.html deleted file mode 100644 index 46b7c8ca..00000000 --- a/demo/logger/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - @alwatr/logger - - - - - -

    Check the console

    - - diff --git a/demo/logger/index.ts b/demo/logger/index.ts deleted file mode 100644 index 7d9aa95b..00000000 --- a/demo/logger/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {createLogger} from '@alwatr/logger'; - -const logger1 = createLogger('logger/demo1'); -const logger2 = createLogger('logger/demo2'); - -console.debug('--- logger.logProperty ---'); -logger1.logProperty?.('name', 'ali'); -logger2.logProperty?.('options', {a: 1, b: 2}); - -console.debug('--- logger.logMethod ---'); -logger1.logMethod?.('myMethod1'); -logger2.logMethod?.('myMethod2'); - -console.debug('--- logger.logMethodArgs ---'); -logger1.logMethodArgs?.('myMethod1', {a: 1, b: 2}); -logger2.logMethodArgs?.('myMethod2', {a: 1, b: 2}); - -console.debug('--- logger.logMethodFull ---'); -logger1.logMethodFull?.('add', {a: 1, b: 2}, 3); - -console.debug('--- logger.incident ---'); -logger1.incident?.('myMethod', 'abort_signal', {url: '/test.json'}); - -console.debug('--- logger.accident ---'); -logger2.accident('myMethod', 'file_not_found', { - url: '/test.json', -}); - -console.debug('--- logger.logOther ---'); -logger1.logOther?.('foo:', 'bar', {a: 1}); - -console.debug('--- logger.error ---'); -try { - throw new Error('my_error_message'); -} -catch (err) { - logger1.error('myMethod', 'error_code', err, {a: 1, b: 2}); -} diff --git a/demo/package.json b/demo/package.json index fc91b5f3..29dfd027 100644 --- a/demo/package.json +++ b/demo/package.json @@ -8,7 +8,7 @@ "dependencies": { "@alwatr/crypto": "workspace:^", "@alwatr/fetch": "workspace:^", - "@alwatr/logger": "workspace:^", + "@alwatr/logger": "^2.4.1", "@alwatr/math": "workspace:^", "@alwatr/util": "workspace:^", "@alwatr/validator": "workspace:^" diff --git a/demo/tsconfig.json b/demo/tsconfig.json index f541652e..3e0035c6 100644 --- a/demo/tsconfig.json +++ b/demo/tsconfig.json @@ -14,7 +14,6 @@ "include": ["**/*.ts"], "exclude": ["*.d.ts", "node_modules"], "references": [ - {"path": "../packages/logger"}, {"path": "../packages/fetch"}, {"path": "../packages/type"}, {"path": "../packages/crypto"}, diff --git a/packages/crypto/package.json b/packages/crypto/package.json index d59193bb..ace7c647 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -40,7 +40,7 @@ "url": "https://github.com/Alwatr/alwatr-es-sdk/issues" }, "dependencies": { - "@alwatr/logger": "workspace:^", + "@alwatr/logger": "^2.4.1", "@alwatr/math": "workspace:^", "@alwatr/util": "workspace:^" }, diff --git a/packages/crypto/tsconfig.json b/packages/crypto/tsconfig.json index 1b4a2741..ae9f46f3 100644 --- a/packages/crypto/tsconfig.json +++ b/packages/crypto/tsconfig.json @@ -10,7 +10,6 @@ "include": ["src/**/*.ts"], "exclude": [], "references": [ - {"path": "../logger"}, {"path": "../math"}, ] } diff --git a/packages/fetch/package.json b/packages/fetch/package.json index 03ea4bfa..0367ea5f 100644 --- a/packages/fetch/package.json +++ b/packages/fetch/package.json @@ -34,7 +34,7 @@ "url": "https://github.com/Alwatr/alwatr-es-sdk/issues" }, "dependencies": { - "@alwatr/logger": "workspace:^", + "@alwatr/logger": "^2.4.1", "@alwatr/util": "workspace:^" }, "devDependencies": { diff --git a/packages/fetch/tsconfig.json b/packages/fetch/tsconfig.json index 8b72465a..aa33dfd1 100644 --- a/packages/fetch/tsconfig.json +++ b/packages/fetch/tsconfig.json @@ -10,7 +10,6 @@ "include": ["src/**/*.ts"], "exclude": [], "references": [ - {"path": "../logger"}, {"path": "../util"}, {"path": "../type"} ] diff --git a/packages/logger/CHANGELOG.md b/packages/logger/CHANGELOG.md deleted file mode 100644 index 91744e16..00000000 --- a/packages/logger/CHANGELOG.md +++ /dev/null @@ -1,414 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [2.4.1](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/logger@2.4.0...@alwatr/logger@2.4.1) (2023-12-19) - -### Bug Fixes - -* **logger:** define package scope ([b54c2ef](https://github.com/Alwatr/alwatr-es-sdk/commit/b54c2ef08a7b9e61068fd6a3faeccd3e4e7a6a09)) by @njfamirm - -# [2.4.0](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/logger@2.3.3...@alwatr/logger@2.4.0) (2023-12-19) - -### Bug Fixes - -* **logger:** duplicate package definition and throw error ([640ce6a](https://github.com/Alwatr/alwatr-es-sdk/commit/640ce6acff999205569d978e8c32c458834d85ed)) by @AliMD -* **logger:** styleScope.replace in createLogger function ([d209a9b](https://github.com/Alwatr/alwatr-es-sdk/commit/d209a9ba770a4e939726e80731c08a4bc00c6202)) by @AliMD - -### Features - -* use globalScope instead globalThis ([94342bb](https://github.com/Alwatr/alwatr-es-sdk/commit/94342bb7b467376173a65d8cdf6bb106338f425b)) by @njfamirm - -## [2.3.3](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/logger@2.3.2...@alwatr/logger@2.3.3) (2023-12-11) - -### Bug Fixes - -* **logger/define-package:** throw error if duplicate_package_defined ([c32be46](https://github.com/Alwatr/alwatr-es-sdk/commit/c32be4680bd8b8315c54f63d380634448a989bff)) by @njfamirm - -## [2.3.2](https://github.com/Alwatr/alwatr-es-sdk/compare/@alwatr/logger@2.3.1...@alwatr/logger@2.3.2) (2023-12-09) - -**Note:** Version bump only for package @alwatr/logger - -## [2.3.1](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.3.0...@alwatr/logger@2.3.1) (2023-11-29) - -**Note:** Version bump only for package @alwatr/logger - -# [2.3.0](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.2.0...@alwatr/logger@2.3.0) (2023-11-23) - -### Features - -* **logger/global:** globalScope ([8111c10](https://github.com/Alwatr/eslib/commit/8111c108edff13d433d5f2f50470d00058e761ba)) by @AliMD - -# [2.2.0](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.1.3...@alwatr/logger@2.2.0) (2023-11-14) - -### Bug Fixes - -* **logger:** logger.banner type ([1f2586d](https://github.com/Alwatr/eslib/commit/1f2586dab65608c4a54f20859f4ea2dda6028c7c)) by @ - -### Features - -* **yarn:** pnp ([b6a562c](https://github.com/Alwatr/eslib/commit/b6a562c909a35b3e626442e5c325da3fce448e1b)) by @AliMD - -## [2.1.3](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.1.2...@alwatr/logger@2.1.3) (2023-11-08) - -### Bug Fixes - -* move repo urls ([719aa3e](https://github.com/Alwatr/eslib/commit/719aa3e7462d3c9c6272958fc93f89fda6793fb1)) by @AliMD - -## [2.1.2](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.1.1...@alwatr/logger@2.1.2) (2023-11-01) - -### Bug Fixes - -* **logger:** show duplicate_old_package_defined error after all packages designed ([8bb3410](https://github.com/Alwatr/eslib/commit/8bb341033091d25d1128127e00fafdafc25d1827)) by @ - -## [2.1.1](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.1.0...@alwatr/logger@2.1.1) (2023-10-23) - -**Note:** Version bump only for package @alwatr/logger - -# [2.1.0](https://github.com/Alwatr/eslib/compare/@alwatr/logger@2.0.0...@alwatr/logger@2.1.0) (2023-10-23) - -### Features - -* **logger:** accident if old Alwatr.registeredList found ([d0ae735](https://github.com/Alwatr/eslib/commit/d0ae735b2b54cc75a380902d9fbe9dddaad650f4)) by @ - -# [2.0.0](https://github.com/Alwatr/eslib/compare/@alwatr/logger@1.2.0...@alwatr/logger@2.0.0) (2023-10-23) - -### Bug Fixes - -* **logger:** remove globalAlwatr ([e7a7236](https://github.com/Alwatr/eslib/commit/e7a72361715cbeb05c5dea4dbff7c2b583d2eab2)) by @AliMD - -### Features - -* **logger:** define logger package ([5beaaf4](https://github.com/Alwatr/eslib/commit/5beaaf4f6f2f74d4976f9d0d58927526f283d5f9)) by @AliMD -* **logger:** definePackage, the new api for global alwatr ([e3635e2](https://github.com/Alwatr/eslib/commit/e3635e2012e5ab5a79622693c5bf7c4639840258)) by @AliMD -* **logger:** remove desc from incident & accident ([fa38b68](https://github.com/Alwatr/eslib/commit/fa38b68ce63524f1b53f3ad135450289eff66ae8)) by @AliMD - -### BREAKING CHANGES - -* **logger:** remove desc from incident & accident -* **logger:** global Alwatr.registeredList not exist anymore - -# [1.2.0](https://github.com/Alwatr/eslib/compare/@alwatr/logger@1.1.5...@alwatr/logger@1.2.0) (2023-10-23) - -### Features - -* **logger:** banner method ([3e3af6d](https://github.com/Alwatr/eslib/commit/3e3af6d71ccecaaf14ca9d63a8a14c7239afe697)) by @ - -## [1.1.5](https://github.com/Alwatr/eslib/compare/@alwatr/logger@1.1.4...@alwatr/logger@1.1.5) (2023-09-19) - -### Bug Fixes - -- package repo urls ([466cbe9](https://github.com/Alwatr/eslib/commit/466cbe9188f24e1a1bc36d879a95b52538a58f16)) by @AliMD - -## [1.1.4](https://github.com/Alwatr/eslib/compare/@alwatr/logger@1.1.3...@alwatr/logger@1.1.4) (2023-09-19) - -**Note:** Version bump only for package @alwatr/logger - -## [1.1.3](https://github.com/Alwatr/eslib/compare/@alwatr/logger@1.1.2...@alwatr/logger@1.1.3) (2023-09-19) - -**Note:** Version bump only for package @alwatr/logger - -## [1.1.2](https://github.com/Alwatr/eslib/compare/@alwatr/logger@1.1.1...@alwatr/logger@1.1.2) (2023-09-12) - -### Bug Fixes - -- **logger:** change localStorage debug key to `alwatrDebug` ([66542ea](https://github.com/Alwatr/eslib/commit/66542ea22a9a515db4a15dc966624b3029f517ed)) by @AliMD - -## [1.1.1](https://github.com/Alwatr/eslib/compare/@alwatr/logger@1.1.0...@alwatr/logger@1.1.1) (2023-09-12) - -**Note:** Version bump only for package @alwatr/logger - -# 1.1.0 (2023-09-12) - -### Features - -- **logger:** add logModule ([2e37bef](https://github.com/Alwatr/eslib/commit/2e37befd5f66094c5a521424e2a9d60796384f88)) - -# 1.0.0 (2023-06-14) - -# 0.32.0 (2023-05-27) - -# 0.31.0 (2023-05-08) - -### Bug Fixes - -- **logger:** logMethod args type ([66338b7](https://github.com/Alwatr/eslib/commit/66338b7ba1d4b15af78f9f604f7be0a7e483413d)) -- **logger:** logMethod args type ([1983b3d](https://github.com/Alwatr/eslib/commit/1983b3d2fe260226ca2660e33b9bd924facdf776)) -- new logger api ([9d83a7d](https://github.com/Alwatr/eslib/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) - -### Features - -- **logger:** add `duration time` to logger time label ([ef188c4](https://github.com/Alwatr/eslib/commit/ef188c41a02789e1b35ab424bab24a393a03a3b0)) -- **logger:** add `time` & `timeEnd` ([0bd4ec5](https://github.com/Alwatr/eslib/commit/0bd4ec5dbd185b17cfb8656a84a782e848ade138)) -- **logger:** optional devMode per package ([cc1eb87](https://github.com/Alwatr/eslib/commit/cc1eb879832807d55ad4cf268a54b2d5e4346fff)) - -# 0.30.0 (2023-03-06) - -### Features - -- **logger:** export isBrowser ([5b5be8b](https://github.com/Alwatr/eslib/commit/5b5be8b2312ca67f186d1614506423f1fdb90877)) - -# 0.29.0 (2023-02-10) - -# 0.28.0 (2023-01-20) - -### Bug Fixes - -- **logger:** _ALWATR_VERSION_ ([9cf8f20](https://github.com/Alwatr/eslib/commit/9cf8f208e8adbfa2e2c622a8465453d5554cbd37)) - -# 0.27.0 (2022-12-29) - -### Bug Fixes - -- **logger:** version ([2295fee](https://github.com/Alwatr/eslib/commit/2295fee74e8eebd9db399129de31f2b0d6d6b168)) - -### Features - -- **type:** define alwatrRegistredList ([25406c2](https://github.com/Alwatr/eslib/commit/25406c268f39cf3e055ea05c9fc7b50bd3dd0a17)) - -# 0.26.0 (2022-12-22) - -### Bug Fixes - -- set correct path ([d01ce6f](https://github.com/Alwatr/eslib/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) -- tsconfig ([e96dcd3](https://github.com/Alwatr/eslib/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) - -### Features - -- improve error debugging ([1fba504](https://github.com/Alwatr/eslib/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) -- **logger:** add root version ([2ac01c1](https://github.com/Alwatr/eslib/commit/2ac01c1d12323a6c8591b3dd4826d08a55647dc1)) -- **logger:** move incident to deployment mode ([4ee8dac](https://github.com/Alwatr/eslib/commit/4ee8dac5c54ce8a897382d3d4fb5bb852d24cf24)) - -# [1.0.0](https://github.com/Alwatr/eslib/compare/v0.32.0...v1.0.0) (2023-06-14) - -**Note:** Version bump only for package @alwatr/logger - -# [0.32.0](https://github.com/Alwatr/eslib/compare/v0.31.0...v0.32.0) (2023-05-27) - -**Note:** Version bump only for package @alwatr/logger - -# [0.31.0](https://github.com/Alwatr/eslib/compare/v0.30.0...v0.31.0) (2023-05-08) - -### Bug Fixes - -- **logger:** logMethod args type ([66338b7](https://github.com/Alwatr/eslib/commit/66338b7ba1d4b15af78f9f604f7be0a7e483413d)) -- **logger:** logMethod args type ([1983b3d](https://github.com/Alwatr/eslib/commit/1983b3d2fe260226ca2660e33b9bd924facdf776)) -- new logger api ([9d83a7d](https://github.com/Alwatr/eslib/commit/9d83a7dc5c103bc3bb4282dacfd85fa998915300)) - -### Features - -- **logger:** add `duration time` to logger time label ([ef188c4](https://github.com/Alwatr/eslib/commit/ef188c41a02789e1b35ab424bab24a393a03a3b0)) -- **logger:** add `time` & `timeEnd` ([0bd4ec5](https://github.com/Alwatr/eslib/commit/0bd4ec5dbd185b17cfb8656a84a782e848ade138)) -- **logger:** optional devMode per package ([cc1eb87](https://github.com/Alwatr/eslib/commit/cc1eb879832807d55ad4cf268a54b2d5e4346fff)) - -# [0.30.0](https://github.com/Alwatr/eslib/compare/v0.29.0...v0.30.0) (2023-03-06) - -### Features - -- **logger:** export isBrowser ([5b5be8b](https://github.com/Alwatr/eslib/commit/5b5be8b2312ca67f186d1614506423f1fdb90877)) - -# [0.29.0](https://github.com/Alwatr/eslib/compare/v0.28.0...v0.29.0) (2023-02-10) - -**Note:** Version bump only for package @alwatr/logger - -# [0.28.0](https://github.com/Alwatr/eslib/compare/v0.27.0...v0.28.0) (2023-01-20) - -### Bug Fixes - -- **logger:** _ALWATR_VERSION_ ([9cf8f20](https://github.com/Alwatr/eslib/commit/9cf8f208e8adbfa2e2c622a8465453d5554cbd37)) - -### Features - -- **type:** define alwatrRegistredList ([25406c2](https://github.com/Alwatr/eslib/commit/25406c268f39cf3e055ea05c9fc7b50bd3dd0a17)) - -# [0.27.0](https://github.com/Alwatr/eslib/compare/v0.26.0...v0.27.0) (2022-12-29) - -### Bug Fixes - -- **logger:** version ([2295fee](https://github.com/Alwatr/eslib/commit/2295fee74e8eebd9db399129de31f2b0d6d6b168)) - -# [0.26.0](https://github.com/Alwatr/eslib/compare/v0.25.0...v0.26.0) (2022-12-22) - -### Bug Fixes - -- set correct path ([d01ce6f](https://github.com/Alwatr/eslib/commit/d01ce6ffa749a5e3e0e11e35b4ed61d75d61fec9)) -- tsconfig ([e96dcd3](https://github.com/Alwatr/eslib/commit/e96dcd30774a9f06f7d051e0504192cbbe019e35)) - -### Features - -- improve error debugging ([1fba504](https://github.com/Alwatr/eslib/commit/1fba50400a1e8ececc10bbe8ea11cc8dcea2289c)) -- **logger:** add root version ([2ac01c1](https://github.com/Alwatr/eslib/commit/2ac01c1d12323a6c8591b3dd4826d08a55647dc1)) -- **logger:** move incident to deployment mode ([4ee8dac](https://github.com/Alwatr/eslib/commit/4ee8dac5c54ce8a897382d3d4fb5bb852d24cf24)) - -# [0.25.0](https://github.com/Alwatr/eslib/compare/v0.24.1...v0.25.0) (2022-12-07) - -### Features - -- **logger:** log incident in production mode ([c9b6c56](https://github.com/Alwatr/eslib/commit/c9b6c56182750444b1cced3343b02eea6a9f24c5)) - -## [0.24.1](https://github.com/Alwatr/eslib/compare/v0.24.0...v0.24.1) (2022-12-01) - -### Bug Fixes - -- **logger:** optimize for browserify builds ([7afdc1c](https://github.com/Alwatr/eslib/commit/7afdc1cb5baf9b66dedcdc251595c02a79a163b2)) - -# [0.24.0](https://github.com/Alwatr/eslib/compare/v0.23.0...v0.24.0) (2022-11-28) - -### Bug Fixes - -- use ~ for package version ([4e027ff](https://github.com/Alwatr/eslib/commit/4e027ff63875e03b088ebcdc1bdf2495f4494eec)) - -# [0.23.0](https://github.com/Alwatr/eslib/compare/v0.22.1...v0.23.0) (2022-11-23) - -**Note:** Version bump only for package @alwatr/logger - -# [0.22.0](https://github.com/Alwatr/eslib/compare/v0.21.0...v0.22.0) (2022-11-20) - -### Bug Fixes - -- **logger:** message format in node ([0ab9153](https://github.com/Alwatr/eslib/commit/0ab9153e407cafd07af8b77b63e25c8d21b474c0)) - -### Features - -- **logger:** better log in browser and node ([1a35ac4](https://github.com/Alwatr/eslib/commit/1a35ac4bbb9aae4280ea99b8383459cf44de0baa)) - -# [0.21.0](https://github.com/Alwatr/eslib/compare/v0.20.0...v0.21.0) (2022-11-13) - -**Note:** Version bump only for package @alwatr/logger - -# [0.20.0](https://github.com/Alwatr/eslib/compare/v0.19.0...v0.20.0) (2022-11-05) - -**Note:** Version bump only for package @alwatr/logger - -# [0.19.0](https://github.com/Alwatr/eslib/compare/v0.18.0...v0.19.0) (2022-11-01) - -### Bug Fixes - -- Import error in webpack ([1a52f67](https://github.com/Alwatr/eslib/commit/1a52f67ff2788c51abd13126f34353c26aa669c3)) - -# [0.18.0](https://github.com/Alwatr/eslib/compare/v0.17.0...v0.18.0) (2022-10-22) - -**Note:** Version bump only for package @alwatr/logger - -# [0.17.0](https://github.com/Alwatr/eslib/compare/v0.16.1...v0.17.0) (2022-10-21) - -### Bug Fixes - -- **`logger`:** `accident` sould `console.warn` ([c210c9f](https://github.com/Alwatr/eslib/commit/c210c9f6a864692848ea0c89d6ffbdb19167732a)) - -# [0.16.0](https://github.com/Alwatr/eslib/compare/v0.15.0...v0.16.0) (2022-09-08) - -**Note:** Version bump only for package @alwatr/logger - -# [0.15.0](https://github.com/Alwatr/eslib/compare/v0.14.0...v0.15.0) (2022-09-01) - -**Note:** Version bump only for package @alwatr/logger - -# [0.14.0](https://github.com/Alwatr/eslib/compare/v0.13.0...v0.14.0) (2022-08-19) - -**Note:** Version bump only for package @alwatr/logger - -# [0.13.0](https://github.com/Alwatr/eslib/compare/v0.12.0...v0.13.0) (2022-08-06) - -**Note:** Version bump only for package @alwatr/logger - -# [0.12.0](https://github.com/Alwatr/eslib/compare/v0.11.0...v0.12.0) (2022-07-22) - -### Bug Fixes - -- **logger:** refactor behavior of force ([7d9307b](https://github.com/Alwatr/eslib/commit/7d9307bb78523f3dae17b3bd80fa2fb47c90975f)) - -### Features - -- **logger:** compatible with node.js ([7ee8b6d](https://github.com/Alwatr/eslib/commit/7ee8b6de3143e39c300345dec6864c9c56a4aae7)) -- **logger:** node coloring support ([2b4aab6](https://github.com/Alwatr/eslib/commit/2b4aab655bc0707761587a7439de98bbd4ad0e08)) - -# [0.11.0](https://github.com/Alwatr/eslib/compare/v0.10.1...v0.11.0) (2022-04-16) - -**Note:** Version bump only for package @alwatr/logger - -# [0.10.0](https://github.com/Alwatr/eslib/compare/v0.9.0...v0.10.0) (2022-04-02) - -**Note:** Version bump only for package @alwatr/logger - -# [0.9.0](https://github.com/Alwatr/eslib/compare/v0.8.0...v0.9.0) (2022-03-22) - -**Note:** Version bump only for package @alwatr/logger - -# [0.8.0](https://github.com/Alwatr/eslib/compare/v0.7.2...v0.8.0) (2022-03-14) - -**Note:** Version bump only for package @alwatr/logger - -## [0.7.2](https://github.com/Alwatr/eslib/compare/v0.7.1...v0.7.2) (2022-03-12) - -### Features - -- **logger:** add debug and improve documents ([8f83d29](https://github.com/Alwatr/eslib/commit/8f83d2956e521f016fe530322f657c343f1a0b80)) - -# [0.7.0](https://github.com/Alwatr/eslib/compare/v0.6.1...v0.7.0) (2022-03-12) - -**Note:** Version bump only for package @alwatr/logger - -# [0.6.0](https://github.com/Alwatr/eslib/compare/v0.5.0...v0.6.0) (2022-03-11) - -### Bug Fixes - -- alalwatr ([898aa6e](https://github.com/Alwatr/eslib/commit/898aa6ed0888eab9265c83b96a50f1b8c216d143)) -- **packages:** duplicate alwatr keyword ([77d4aa2](https://github.com/Alwatr/eslib/commit/77d4aa2105ad47515c3eee251fd6b8c281d0d1fc)) - -# [0.5.0](https://github.com/Alwatr/eslib/compare/v0.4.0...v0.5.0) (2022-03-11) - -### Performance Improvements - -- **logger:** refactor making logger object ([bc38018](https://github.com/Alwatr/eslib/commit/bc38018758540130df2f46c44521aea0a867bbe8)) - -# [0.4.0](https://github.com/Alwatr/eslib/compare/v0.3.0...v0.4.0) (2022-03-11) - -### Bug Fixes - -- **logger:** types missing ([712363d](https://github.com/Alwatr/eslib/commit/712363d3cf77a712f8c801c4dc9d06d256dfc0e6)) - -### Features - -- **logger:** add logProperty, logMethodFull ([8b0317d](https://github.com/Alwatr/eslib/commit/8b0317db88ed73604a27935a3a30cd5c31cb0804)) -- **logger:** complete refactor the logger with new API and fix show correct line number ([7efe8cf](https://github.com/Alwatr/eslib/commit/7efe8cf0f566e148406f38fdd60fa3d747c9bc51)) - -# [0.3.0](https://github.com/Alwatr/eslib/compare/v0.2.1...v0.3.0) (2022-03-06) - -**Note:** Version bump only for package @alwatr/logger - -## [0.2.1](https://github.com/Alwatr/eslib/compare/v0.2.0...v0.2.1) (2022-03-05) - -### Bug Fixes - -- **logger:** alwatrRegisteredList name ([ff59133](https://github.com/Alwatr/eslib/commit/ff5913321c4eafa1ce53fdacebf8fb4f23bfe430)) - -# [0.2.0](https://github.com/Alwatr/eslib/compare/v0.1.2...v0.2.0) (2022-03-05) - -**Note:** Version bump only for package @alwatr/logger - -## [0.1.2](https://github.com/Alwatr/eslib/compare/v0.1.1...v0.1.2) (2022-03-03) - -**Note:** Version bump only for package @alwatr/logger - -## [0.1.1](https://github.com/Alwatr/eslib/compare/v0.1.0...v0.1.1) (2022-03-03) - -### Bug Fixes - -- **packages:** add publish config to public ([9cb3710](https://github.com/Alwatr/eslib/commit/9cb37106b5a35d24d5195ff54232e5769ccc034e)) - -# 0.1.0 (2022-03-02) - -### Bug Fixes - -- **logger:** fix debug scope ([be62f14](https://github.com/Alwatr/eslib/commit/be62f142cbe3fe4d328e3fd9941ea7c2d640a23f)) -- **logger:** fix logger debug scope ([e734d21](https://github.com/Alwatr/eslib/commit/e734d218db888ecec33a03dc805b98dd75543efd)) -- tsconfig issues ([159adeb](https://github.com/Alwatr/eslib/commit/159adeb72de4626dc16f6657765605b0a2ddccb1)) - -### Features - -- **logger:** debug scope ([6e4190d](https://github.com/Alwatr/eslib/commit/6e4190dc9dafc28e3a7a481aa43622a23527993c)) -- **logger:** debug scope logger package ([1a4baeb](https://github.com/Alwatr/eslib/commit/1a4baeb7a253ba66563dbcf06079242dabb9f246)) -- **logger:** alwatr logger package ([711268e](https://github.com/Alwatr/eslib/commit/711268e17dea8ada9c901ef1e9d605b3212abd97)) -- **logger:** alwatr meta structure ([feade73](https://github.com/Alwatr/eslib/commit/feade735a6f141db77b81d7791d8872d45c8bf7e)) diff --git a/packages/logger/README.md b/packages/logger/README.md deleted file mode 100644 index 934aaaf0..00000000 --- a/packages/logger/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Alwatr Logger - `@alwatr/logger` - -Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module. - -## Example usage - -```ts -import {createLogger} from 'https://esm.run/@alwatr/logger'; - -const logger = createLogger('demo'); - -function sayHello(name: string) { - logger.logMethodArgs?.('sayHello', {name}); -} -``` - -### Debug/Develope Mode (DEV_MODE) - -Many of the methods in the logger are no-ops when the debug mode is off in the browser. -Please remember to **reload** the window after changing the debug mode. - -```ts -window.localStorage?.setItem('alwatrDebug', '1'); -``` - -> Make sure the [log level](https://developer.chrome.com/docs/devtools/console/log/#browser) in set correctly. diff --git a/packages/logger/package.json b/packages/logger/package.json deleted file mode 100644 index a25b0723..00000000 --- a/packages/logger/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "@alwatr/logger", - "version": "2.4.1", - "description": "Fancy colorful console debugger with custom scope written in tiny TypeScript, ES module.", - "keywords": [ - "log", - "logger", - "console", - "debug", - "typescript", - "esm", - "alwatr" - ], - "main": "index.js", - "type": "module", - "types": "index.d.ts", - "author": "S. Ali Mihandoost (https://ali.mihandoost.com)", - "license": "MIT", - "files": [ - "**/*.{d.ts.map,d.ts,js.map,js,html,md}" - ], - "publishConfig": { - "access": "public" - }, - "repository": { - "type": "git", - "url": "https://github.com/Alwatr/alwatr-es-sdk", - "directory": "packages/logger" - }, - "homepage": "https://github.com/Alwatr/alwatr-es-sdk/tree/next/packages/logger#readme", - "bugs": { - "url": "https://github.com/Alwatr/alwatr-es-sdk/issues" - }, - "devDependencies": { - "@types/node": "^20.10.5" - } -} diff --git a/packages/logger/src/define-package.ts b/packages/logger/src/define-package.ts deleted file mode 100644 index 1ccee698..00000000 --- a/packages/logger/src/define-package.ts +++ /dev/null @@ -1,37 +0,0 @@ -import './global.js'; -import {createLogger} from './logger.js'; - -Alwatr.packages ??= {}; - -const logger = createLogger('logger'); - -setTimeout(() => { - if ('registeredList' in Alwatr) { - logger.accident?.('define-package', 'duplicate_old_package_defined', Alwatr.registeredList); - throw new Error('duplicate_old_package_defined'); - } -}, 2000); - -export const definePackage = (packageName: string, version: string) => { - logger.logMethodArgs?.('define-package', {packageName, version}); - - if (packageName in Alwatr.packages) { - logger.accident('define-package', 'duplicate_package_defined', { - packageName, - new: version, - old: Alwatr.packages[packageName], - }); - throw new Error('duplicate_package_defined'); - } - - if (packageName.indexOf('@alwatr') !== -1) { - logger.accident('define-package', 'package_name_starts_with_alwatr_scope', { - packageName, - }); - throw new Error('package_name_starts_with_alwatr_scope'); - } - - Alwatr.packages[packageName] = version; -}; - -definePackage('logger', '2.x'); diff --git a/packages/logger/src/global.ts b/packages/logger/src/global.ts deleted file mode 100644 index 77b8a412..00000000 --- a/packages/logger/src/global.ts +++ /dev/null @@ -1,21 +0,0 @@ -export interface GlobalAlwatr { - packages: Record; -} - -declare global { - // eslint-disable-next-line no-var - var Alwatr: GlobalAlwatr; -} - -export const globalScope = - (typeof globalThis === 'object' && globalThis) || - ('object' === typeof window && window) || - ('object' === typeof global && global) || - self; - -globalScope.Alwatr ??= {packages: {}}; - -export const NODE_MODE = typeof process !== 'undefined'; -export const DEV_MODE = NODE_MODE - ? process.env.ALWATR_DEBUG === '1' - : globalScope.localStorage?.getItem('alwatrDebug') === '1'; diff --git a/packages/logger/src/index.ts b/packages/logger/src/index.ts deleted file mode 100644 index 81943781..00000000 --- a/packages/logger/src/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './global.js'; -export * from './logger.js'; -export * from './define-package.js'; -export type * from './type.js'; diff --git a/packages/logger/src/logger.ts b/packages/logger/src/logger.ts deleted file mode 100644 index bc22ebae..00000000 --- a/packages/logger/src/logger.ts +++ /dev/null @@ -1,122 +0,0 @@ -import {DEV_MODE, NODE_MODE} from './global.js'; - -import type {AlwatrLogger} from './type.js'; - -/** - * Color list storage for logger. - */ -const colorList = NODE_MODE - ? ['0;36', '0;35', '0;34', '0;33', '0;32'] // red and white omitted - : [ - '#35b997', - '#f05561', - '#ee224a', - '#91c13e', - '#22af4b', - '#f0e995', - '#0fe995', - '#0f89ca', - '#08b9a5', - '#fee851', - '#ee573d', - '#f9df30', - '#1da2dc', - '#f05123', - '#ee2524', - ]; - -let _colorIndex = 0; -const _getNextColor = (): string => { - const color = colorList[_colorIndex]; - _colorIndex++; - if (_colorIndex >= colorList.length) { - _colorIndex = 0; - } - return color; -}; - -const _style = { - scope: NODE_MODE ? '\x1b[{{color}}m' : 'color: {{color}};', - reset: NODE_MODE ? '\x1b[0m' : 'color: inherit;', -}; - -const _keySection = NODE_MODE ? '%s%s%s' : '%c%s%c'; - -const _sanitizeDomain = (domain: string): string => { - domain = domain.trim(); - const first = domain.charAt(0); - if (first !== '[' && first !== '{' && first !== '<') { - domain = '[' + domain + ']'; - } - return domain; -}; - -/** - * Create a logger function for fancy console debug with custom scope. - * - * - **color** is optional and automatically select from internal fancy color list. - * - **debug** is optional and automatically detect from localStorage `ALWATR_DEBUG` item or `process.env.ALWATR_DEBUG` - * - * Example: - * - * ```ts - * import {createLogger} from 'https://esm.run/@alwatr/logger'; - * const logger = createLogger('logger/demo'); - * ``` - */ -export const createLogger = (domain: string, devMode = DEV_MODE): AlwatrLogger => { - const color = _getNextColor(); - const styleScope = _style.scope.replace('{{color}}', color); - domain = _sanitizeDomain(domain); - - /** - * Required logger object, accident, error always reported even when the devMode is false. - */ - const requiredItems: AlwatrLogger = { - devMode, - domain, - - banner: NODE_MODE - ? console.log.bind(console, `\x1b[1;37;45m\n\n %s${_style.reset}`) - : console.log.bind( - console, - '%c%s', - 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;', - ), - - accident: NODE_MODE - ? console.warn.bind(console, `${styleScope}⚠️\n%s\x1b[33m.%s() Accident \`%s\`!${_style.reset}`, domain) - : console.warn.bind(console, '%c%s%c.%s() Accident `%s`!', styleScope, domain, _style.reset), - - error: NODE_MODE - ? console.error.bind(console, `${styleScope}❌\n%s\x1b[31m.%s() Error \`%s\`${_style.reset}\n`, domain) - : console.error.bind(console, '%c%s%c.%s() Error `%s`\n', styleScope, domain, _style.reset), - }; - - if (!devMode) { - return requiredItems; - } - // else - return { - ...requiredItems, - - logProperty: console.debug.bind(console, _keySection + '.%s = %o;', styleScope, domain, _style.reset), - - logMethod: console.debug.bind(console, _keySection + '.%s();', styleScope, domain, _style.reset), - - logModule: console.debug.bind(console, _keySection + '/%s.js;', styleScope, domain, _style.reset), - - logMethodArgs: console.debug.bind(console, _keySection + '.%s(%o);', styleScope, domain, _style.reset), - - logMethodFull: console.debug.bind(console, _keySection + '.%s(%o) => %o', styleScope, domain, _style.reset), - - logOther: console.debug.bind(console, _keySection, styleScope, domain, _style.reset), - - incident: NODE_MODE - ? console.log.bind(console, `${styleScope}🚸\n%s${_style.reset}.%s() Incident \`%s\`!${_style.reset}`, domain) - : console.log.bind(console, '%c%s%c.%s() Incident `%s`!', styleScope, domain, 'color: orange;'), - - time: (label: string) => console.time(domain + '.' + label + ' duration time'), - timeEnd: (label: string) => console.timeEnd(domain + '.' + label + ' duration time'), - } as const; -}; diff --git a/packages/logger/src/type.ts b/packages/logger/src/type.ts deleted file mode 100644 index 060d536a..00000000 --- a/packages/logger/src/type.ts +++ /dev/null @@ -1,157 +0,0 @@ -export interface AlwatrLogger { - /** - * Debug state for current scope base on localStorage `ALWATR_LOG` pattern. - */ - readonly devMode: boolean; - - /** - * Domain scope defined for this logger. - */ - readonly domain: string; - - /** - * `console.debug` property change. - * - * Example: - * - * ```ts - * logger.logProperty?.('name', 'ali'); - * ``` - */ - logProperty?(property: string, value: unknown): void; - - /** - * `console.debug` module name. - * - * Example: - * - * ```ts - * logger.logModule?.('app'); - * ``` - */ - logModule?(name: string): void; - - /** - * `console.debug` function or method calls. - * - * Example: - * - * ```ts - * function myMethod () { - * logger.logMethod?.('myMethod'); - * } - * ``` - */ - logMethod?(method: string): void; - - /** - * `console.debug` function or method calls with arguments. - * - * Example: - * - * ```ts - * function myMethod (a: number, b: number) { - * logger.logMethodArgs?.('myMethod', {a, b}); - * } - * ``` - */ - logMethodArgs?(method: string, args: unknown): void; - - /** - * `console.debug` function or method calls with arguments. - * - * Example: - * - * ```ts - * function add (a: number, b: number): number { - * const result = a + b; - * logger.logMethodFull?.('add', {a, b}, result); - * return result; - * } - * ``` - */ - logMethodFull?(method: string, args: unknown, result: unknown): void; - - /** - * `console.log` an event or expected accident. - * not warn or error just important information. - * - * Example: - * - * ```ts - * logger.incident?.('fetch', 'abort_signal', {url: '/test.json'}); - * ``` - */ - incident?(method: string, code: string, ...args: unknown[]): void; - - /** - * `console.warn` an unexpected accident or error that you handled like warning. - * - * Example: - * - * ```ts - * logger.accident('fetch', 'file_not_found', {url: '/test.json'}); - * ``` - */ - accident(method: string, code: string, ...args: unknown[]): void; - - /** - * `console.error` an unexpected error. - * - * Example: - * - * ```ts - * try { - * ... - * } - * catch (err) { - * logger.error('myMethod', 'error_code', err, {a: 1, b: 2}); - * } - * ``` - */ - error(method: string, code: string, ...args: unknown[]): void; - - /** - * Simple `console.debug` with styled scope. - * - * Example: - * - * ```ts - * logger.logOther?.('foo:', 'bar', {a: 1}); - * ``` - */ - logOther?(...args: unknown[]): void; - - /** - * Simple `console.time` with scope. - * - * Example: - * - * ```ts - * logger.time?.('foo'); - * ``` - */ - time?(label: string): void; - - /** - * Simple `console.timeEnd` with scope. - * - * Example: - * - * ```ts - * logger.timeEnd?.('foo'); - * ``` - */ - timeEnd?(label: string): void; - - /** - * log big banner - * - * Example: - * - * ```ts - * logger.banner('Alwatr PWA v2'); - * ``` - */ - banner(message: string): void; -} diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json deleted file mode 100644 index 51646795..00000000 --- a/packages/logger/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.base", - "compilerOptions": { - "composite": true, - "tsBuildInfoFile": ".tsbuildinfo", - "rootDir": "src", - "outDir": "." - }, - - "include": ["src/**/*.ts"], - "exclude": [], - "references": [] -} diff --git a/packages/math/package.json b/packages/math/package.json index ef82ecf1..6e78e3f4 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -30,7 +30,7 @@ "url": "https://github.com/Alwatr/alwatr-es-sdk/issues" }, "dependencies": { - "@alwatr/logger": "workspace:^" + "@alwatr/logger": "^2.4.1" }, "devDependencies": { "@types/node": "^20.10.5" diff --git a/packages/math/tsconfig.json b/packages/math/tsconfig.json index 1f9b9b7c..51646795 100644 --- a/packages/math/tsconfig.json +++ b/packages/math/tsconfig.json @@ -9,7 +9,5 @@ "include": ["src/**/*.ts"], "exclude": [], - "references": [ - {"path": "../logger"} - ] + "references": [] } diff --git a/packages/nano-server/package.json b/packages/nano-server/package.json index ba653d81..da206101 100644 --- a/packages/nano-server/package.json +++ b/packages/nano-server/package.json @@ -31,7 +31,7 @@ "url": "https://github.com/Alwatr/alwatr-es-sdk/issues" }, "dependencies": { - "@alwatr/logger": "workspace:^", + "@alwatr/logger": "^2.4.1", "@alwatr/math": "workspace:^", "@alwatr/util": "workspace:^" }, diff --git a/packages/nano-server/tsconfig.json b/packages/nano-server/tsconfig.json index 86baa770..fcfbe198 100644 --- a/packages/nano-server/tsconfig.json +++ b/packages/nano-server/tsconfig.json @@ -9,5 +9,5 @@ "include": ["src/**/*.ts"], "exclude": [], - "references": [{"path": "../logger"}, {"path": "../math"}, {"path": "../type"}] + "references": [ {"path": "../math"}, {"path": "../type"}] } diff --git a/packages/util/package.json b/packages/util/package.json index c611efb3..e88c0278 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -40,7 +40,7 @@ } }, "dependencies": { - "@alwatr/logger": "workspace:^", + "@alwatr/logger": "^2.4.1", "@alwatr/math": "workspace:^", "@alwatr/type": "workspace:^" }, diff --git a/tsconfig.json b/tsconfig.json index 5e5c826d..182cffd2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,6 @@ "exclude": [], "references": [ // packages - {"path": "./packages/logger"}, {"path": "./packages/fetch"}, {"path": "./packages/math"}, {"path": "./packages/crypto"}, diff --git a/yarn.lock b/yarn.lock index 92295c3a..a0724cb7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -26,7 +26,7 @@ __metadata: version: 0.0.0-use.local resolution: "@alwatr/crypto@workspace:packages/crypto" dependencies: - "@alwatr/logger": "workspace:^" + "@alwatr/logger": "npm:^2.4.1" "@alwatr/math": "workspace:^" "@alwatr/util": "workspace:^" "@types/node": "npm:^20.10.5" @@ -39,7 +39,7 @@ __metadata: dependencies: "@alwatr/crypto": "workspace:^" "@alwatr/fetch": "workspace:^" - "@alwatr/logger": "workspace:^" + "@alwatr/logger": "npm:^2.4.1" "@alwatr/math": "workspace:^" "@alwatr/type": "workspace:^" "@alwatr/util": "workspace:^" @@ -52,26 +52,25 @@ __metadata: version: 0.0.0-use.local resolution: "@alwatr/fetch@workspace:packages/fetch" dependencies: - "@alwatr/logger": "workspace:^" + "@alwatr/logger": "npm:^2.4.1" "@alwatr/type": "workspace:^" "@alwatr/util": "workspace:^" "@types/node": "npm:^20.10.5" languageName: unknown linkType: soft -"@alwatr/logger@workspace:^, @alwatr/logger@workspace:packages/logger": - version: 0.0.0-use.local - resolution: "@alwatr/logger@workspace:packages/logger" - dependencies: - "@types/node": "npm:^20.10.5" - languageName: unknown - linkType: soft +"@alwatr/logger@npm:^2.4.1": + version: 2.4.1 + resolution: "@alwatr/logger@npm:2.4.1" + checksum: 6fef967cab9a2e734d2c1f7bdc66fb3fd1b515830a9734ca5e035973011b7708863005b49181e5fa19313ea71bfd02974c602511eba00bd632ef6cdfcfd5460a + languageName: node + linkType: hard "@alwatr/math@workspace:^, @alwatr/math@workspace:packages/math": version: 0.0.0-use.local resolution: "@alwatr/math@workspace:packages/math" dependencies: - "@alwatr/logger": "workspace:^" + "@alwatr/logger": "npm:^2.4.1" "@types/node": "npm:^20.10.5" languageName: unknown linkType: soft @@ -80,7 +79,7 @@ __metadata: version: 0.0.0-use.local resolution: "@alwatr/nano-server@workspace:packages/nano-server" dependencies: - "@alwatr/logger": "workspace:^" + "@alwatr/logger": "npm:^2.4.1" "@alwatr/math": "workspace:^" "@alwatr/type": "workspace:^" "@alwatr/util": "workspace:^" @@ -100,7 +99,7 @@ __metadata: version: 0.0.0-use.local resolution: "@alwatr/util@workspace:packages/util" dependencies: - "@alwatr/logger": "workspace:^" + "@alwatr/logger": "npm:^2.4.1" "@alwatr/math": "workspace:^" "@alwatr/type": "workspace:^" "@types/node": "npm:^20.10.5"