SB-6.1-PRE

This commit is contained in:
ItzEmerald committed 2021-02-02 13:50:53 +00:00
1 parent 690169a409
commit 358a25f522
3760 files changed
+300059 -36

No files matched your search

+685
View File
@@ -0,0 +1,685 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## [2.15.0](https://github.com/nuxt/consola/compare/v2.14.0...v2.15.0) (2020-08-05)
### Features
* **types:** use union type for `ConsolaLogObject.type` ([#100](https://github.com/nuxt/consola/issues/100)) ([a6eba53](https://github.com/nuxt/consola/commit/a6eba532381bcec9c84ac5600ac668aca87c8487))
* support `formatOptions.date` to optionally hide date ([#101](https://github.com/nuxt/consola/issues/101)) ([6bf733f](https://github.com/nuxt/consola/commit/6bf733f2b9a5320584bdd0de7de08f4341c74335))
## [2.14.0](https://github.com/nuxt/consola/compare/v2.13.0...v2.14.0) (2020-06-26)
### Features
* improve spam throttle ([5314eee](https://github.com/nuxt/consola/commit/5314eeebb4b564408a4ab14cb457bdbd426f6124))
## [2.13.0](https://github.com/nuxt/consola/compare/v2.12.2...v2.13.0) (2020-06-12)
### Features
* remove level boundary check ([8972d47](https://github.com/nuxt/consola/commit/8972d478c93690fafb909f49d9d0edbcb67bddae))
### Bug Fixes
* **types:** fix silent/verbose levels ([7ab0a65](https://github.com/nuxt/consola/commit/7ab0a65f383d9dd1b68a18ee439bf19468a57885))
### [2.12.2](https://github.com/nuxt/consola/compare/v2.12.1...v2.12.2) (2020-05-26)
### Bug Fixes
* silent log level does not work ([#98](https://github.com/nuxt/consola/issues/98)) ([6a4a79c](https://github.com/nuxt/consola/commit/6a4a79c24b8db902b078ad92a6ee7a33880ed26c))
### [2.12.1](https://github.com/nuxt/consola/compare/v2.12.0...v2.12.1) (2020-05-07)
### Bug Fixes
* new LogLevel enum is not exported properly [#95](https://github.com/nuxt/consola/issues/95) ([#96](https://github.com/nuxt/consola/issues/96)) ([fafbec2](https://github.com/nuxt/consola/commit/fafbec2b1bc75912eea5d0618a27b982738d6cda))
## [2.12.0](https://github.com/nuxt/consola/compare/v2.11.3...v2.12.0) (2020-05-07)
### Features
* **types:** add missing typescript definitions for reporters ([#94](https://github.com/nuxt/consola/issues/94)) ([4a08ef0](https://github.com/nuxt/consola/commit/4a08ef02bc48ddc887f2b91713520eda50793a27))
### [2.11.3](https://github.com/nuxt/consola/compare/v2.11.2...v2.11.3) (2019-12-31)
### Bug Fixes
* **typescript:** remove cjs export (fixes [#88](https://github.com/nuxt/consola/issues/88)) ([0d9ab1b](https://github.com/nuxt/consola/commit/0d9ab1bba8645853c721069c57527764ed708869))
### [2.11.2](https://github.com/nuxt/consola/compare/v2.11.1...v2.11.2) (2019-12-27)
### Bug Fixes
* **types:** `const consola = require('consola')` type is wrong ([#80](https://github.com/nuxt/consola/issues/80)) ([5c22d8c](https://github.com/nuxt/consola/commit/5c22d8cd4624e3bbd7294b9eba09f131ed786332))
* throttle expiration ([#81](https://github.com/nuxt/consola/issues/81)) ([940474d](https://github.com/nuxt/consola/commit/940474d3b64a4969acdec04290734e700920c19f)), closes [#68](https://github.com/nuxt/consola/issues/68)
### [2.11.1](https://github.com/nuxt/consola/compare/v2.11.0...v2.11.1) (2019-12-17)
### Bug Fixes
* **consola:** use `options.stderr` ([#77](https://github.com/nuxt/consola/issues/77)) ([774c673](https://github.com/nuxt/consola/commit/774c6739e794665bc5e2c40aa84921b7f2a26387))
## [2.11.0](https://github.com/nuxt/consola/compare/v2.10.0...v2.11.0) (2019-11-10)
### Features
* **browser:** add support of formatted strings ([#66](https://github.com/nuxt/consola/issues/66)) ([920f313](https://github.com/nuxt/consola/commit/920f313dba322c34ccd1b2f08afba59122c3b8e7))
### Bug Fixes
* typecheck type and tag before normalize ([1984deb](https://github.com/nuxt/consola/commit/1984deb0a5214a3aa82dab972ec76af20ba14d1b))
* **types:** reporter in remove methods are optional ([#70](https://github.com/nuxt/consola/issues/70)) ([a17cdb1](https://github.com/nuxt/consola/commit/a17cdb1a423e41076c58692130955d5a9f5e36ba))
### [2.10.1](https://github.com/nuxt/consola/compare/v2.10.0...v2.10.1) (2019-08-05)
## [2.10.0](https://github.com/nuxt/consola/compare/v2.9.0...v2.10.0) (2019-08-05)
### Bug Fixes
* add missing typescript declaration for level, stdout and stderr ([#58](https://github.com/nuxt/consola/issues/58)) ([a149dbb](https://github.com/nuxt/consola/commit/a149dbb))
### Features
* improve typescript type definitions ([#57](https://github.com/nuxt/consola/issues/57)) ([80eefd8](https://github.com/nuxt/consola/commit/80eefd8))
## [2.9.0](https://github.com/nuxt/consola/compare/v2.8.0...v2.9.0) (2019-06-18)
### Features
* count spam log ([197a6b3](https://github.com/nuxt/consola/commit/197a6b3))
## [2.8.0](https://github.com/nuxt/consola/compare/v2.7.1...v2.8.0) (2019-06-18)
### Features
* spam preventation ([7da806b](https://github.com/nuxt/consola/commit/7da806b))
### [2.7.1](https://github.com/nuxt/consola/compare/v2.7.0...v2.7.1) (2019-05-26)
### Bug Fixes
* **browser:** hide `:` with tag and normal log ([8250d5a](https://github.com/nuxt/consola/commit/8250d5a))
## [2.7.0](https://github.com/nuxt/consola/compare/v2.6.2...v2.7.0) (2019-05-26)
### Bug Fixes
* correctly calculate line width when using grave accent ([bad52bd](https://github.com/nuxt/consola/commit/bad52bd))
### Features
* always hide right side on width < 80 ([07d8246](https://github.com/nuxt/consola/commit/07d8246))
* improve basic logs ([ea6ce59](https://github.com/nuxt/consola/commit/ea6ce59))
* **browser:** fancier logs ([b64f337](https://github.com/nuxt/consola/commit/b64f337))
* hide time from basic logger as it is commonly used in CI environments ([68c3bae](https://github.com/nuxt/consola/commit/68c3bae))
* smart hide time and tag when there is no space ([00a375f](https://github.com/nuxt/consola/commit/00a375f))
### [2.6.2](https://github.com/nuxt/consola/compare/v2.6.1...v2.6.2) (2019-05-15)
### Bug Fixes
* transpile browser dist to ES5 ([1f81eea](https://github.com/nuxt/consola/commit/1f81eea)), closes [nuxt/nuxt.js#5743](https://github.com/nuxt/consola/issues/5743)
### [2.6.1](https://github.com/nuxt/consola/compare/v2.6.0...v2.6.1) (2019-05-08)
### Bug Fixes
* **browser:** use `console.warn` when possible ([#49](https://github.com/nuxt/consola/issues/49)) ([e386ede](https://github.com/nuxt/consola/commit/e386ede))
# [2.6.0](https://github.com/nuxt/consola/compare/v2.5.8...v2.6.0) (2019-04-12)
### Features
* expose constructor and reporters ([3a8f662](https://github.com/nuxt/consola/commit/3a8f662))
## [2.5.8](https://github.com/nuxt/consola/compare/v2.5.7...v2.5.8) (2019-03-29)
### Bug Fixes
* **types:** allow passing extra arguments ([#46](https://github.com/nuxt/consola/issues/46)) ([d29fc46](https://github.com/nuxt/consola/commit/d29fc46))
## [2.5.7](https://github.com/nuxt/consola/compare/v2.5.6...v2.5.7) (2019-03-19)
### Bug Fixes
* **formatting:** fix formatting when multiple back-quotes ([#44](https://github.com/nuxt/consola/issues/44)) ([669a12e](https://github.com/nuxt/consola/commit/669a12e))
## [2.5.6](https://github.com/nuxt/consola/compare/v2.5.5...v2.5.6) (2019-02-25)
### Bug Fixes
* **ts:** revert export consola ts declarations ([#43](https://github.com/nuxt/consola/issues/43)) ([6bd4f85](https://github.com/nuxt/consola/commit/6bd4f85))
<a name="2.4.1"></a>
## [2.4.1](https://github.com/nuxt/consola/compare/v2.4.0...v2.4.1) (2019-02-12)
### Bug Fixes
* **ts:** set type "any" ([#40](https://github.com/nuxt/consola/issues/40)) ([ea9d551](https://github.com/nuxt/consola/commit/ea9d551))
<a name="2.4.0"></a>
# [2.4.0](https://github.com/nuxt/consola/compare/v2.3.2...v2.4.0) (2019-02-05)
### Bug Fixes
* **esm:** fix esm compatibility ([8ddecc3](https://github.com/nuxt/consola/commit/8ddecc3))
* **consola:** return `this` in setReporters ([544a887](https://github.com/nuxt/consola/commit/544a887))
* **types:** set message type to "any" ([#39](https://github.com/nuxt/consola/issues/39)) ([ff97b09](https://github.com/nuxt/consola/commit/ff97b09)), closes [#38](https://github.com/nuxt/consola/issues/38)
### Features
* **types:** update types ([d0d7455](https://github.com/nuxt/consola/commit/d0d7455))
<a name="2.3.2"></a>
## [2.3.2](https://github.com/nuxt/consola/compare/v2.3.1...v2.3.2) (2019-01-06)
### Bug Fixes
* **types:** add some of the missing types ([#35](https://github.com/nuxt/consola/issues/35)) ([5e3e69b](https://github.com/nuxt/consola/commit/5e3e69b))
* ignore winston dep in webpack ([#37](https://github.com/nuxt/consola/issues/37)) ([e534a28](https://github.com/nuxt/consola/commit/e534a28))
<a name="2.3.1"></a>
## [2.3.1](https://github.com/nuxt/consola/compare/v2.3.0...v2.3.1) (2019-01-02)
### Bug Fixes
* bypass webpack for lazy required version of winston ([500b509](https://github.com/nuxt/consola/commit/500b509))
<a name="2.3.0"></a>
# [2.3.0](https://github.com/nuxt/consola/compare/v2.2.6...v2.3.0) (2018-11-19)
### Bug Fixes
* **isLogObj:** handle non-standard error objects ([8748c81](https://github.com/nuxt/consola/commit/8748c81))
### Features
* browser reporter improvements ([591d0b4](https://github.com/nuxt/consola/commit/591d0b4)), closes [#31](https://github.com/nuxt/consola/issues/31)
* **fancy:** look like jest traces ([ecae238](https://github.com/nuxt/consola/commit/ecae238))
<a name="2.2.6"></a>
## [2.2.6](https://github.com/nuxt/consola/compare/v2.2.5...v2.2.6) (2018-11-14)
### Bug Fixes
* **json-reporter:** add a default value to the constructor ([#33](https://github.com/nuxt/consola/issues/33)) ([c59db36](https://github.com/nuxt/consola/commit/c59db36))
<a name="2.2.5"></a>
## [2.2.5](https://github.com/nuxt/consola/compare/v2.2.4...v2.2.5) (2018-11-14)
### Bug Fixes
* expose typescript typings ([f0398ed](https://github.com/nuxt/consola/commit/f0398ed))
<a name="2.2.4"></a>
## [2.2.4](https://github.com/nuxt/consola/compare/v2.2.3...v2.2.4) (2018-11-08)
### Bug Fixes
* use basic reporter only for ci and test environments ([33220e4](https://github.com/nuxt/consola/commit/33220e4))
<a name="2.2.3"></a>
## [2.2.3](https://github.com/nuxt/consola/compare/v2.2.2...v2.2.3) (2018-11-07)
### Bug Fixes
* **fancy:** honor logObj.icon ([d56fa38](https://github.com/nuxt/consola/commit/d56fa38))
<a name="2.2.2"></a>
## [2.2.2](https://github.com/nuxt/consola/compare/v2.2.1...v2.2.2) (2018-11-04)
### Bug Fixes
* update std-env to 2.1.1 ([32a9c67](https://github.com/nuxt/consola/commit/32a9c67))
<a name="2.2.1"></a>
## [2.2.1](https://github.com/nuxt/consola/compare/v2.2.0...v2.2.1) (2018-11-04)
### Bug Fixes
* remove file:// from error stack traces ([ff24b69](https://github.com/nuxt/consola/commit/ff24b69))
<a name="2.2.0"></a>
# [2.2.0](https://github.com/nuxt/consola/compare/v2.1.1...v2.2.0) (2018-11-04)
### Bug Fixes
* correctly handle falsy values ([367fb19](https://github.com/nuxt/consola/commit/367fb19))
### Features
* support formatOptions. resolves [#29](https://github.com/nuxt/consola/issues/29). ([7ed640f](https://github.com/nuxt/consola/commit/7ed640f))
<a name="2.1.1"></a>
## [2.1.1](https://github.com/nuxt/consola/compare/v2.1.0...v2.1.1) (2018-11-03)
### Bug Fixes
* add legacy ready and start levels for more backward compatibility ([f54b5c2](https://github.com/nuxt/consola/commit/f54b5c2))
<a name="2.1.0"></a>
# [2.1.0](https://github.com/nuxt/consola/compare/v2.0.9...v2.1.0) (2018-11-03)
### Features
* add aliases ([cbea7bd](https://github.com/nuxt/consola/commit/cbea7bd))
* mockTypes for easy mocking ([a332890](https://github.com/nuxt/consola/commit/a332890))
<a name="2.0.9"></a>
## [2.0.9](https://github.com/nuxt/consola/compare/v2.0.8...v2.0.9) (2018-11-03)
<a name="2.0.8"></a>
## [2.0.8](https://github.com/nuxt/consola/compare/v2.0.7...v2.0.8) (2018-11-03)
<a name="2.0.7"></a>
## [2.0.7](https://github.com/nuxt/consola/compare/v2.0.6...v2.0.7) (2018-11-02)
### Bug Fixes
* always use computed values for stdout/stderr ([f91abc0](https://github.com/nuxt/consola/commit/f91abc0))
<a name="2.0.6"></a>
## [2.0.6](https://github.com/nuxt/consola/compare/v2.0.5...v2.0.6) (2018-11-02)
<a name="2.0.5"></a>
## [2.0.5](https://github.com/nuxt/consola/compare/v2.0.4...v2.0.5) (2018-11-02)
<a name="2.0.4"></a>
## [2.0.4](https://github.com/nuxt/consola/compare/v2.0.3...v2.0.4) (2018-11-02)
### Bug Fixes
* **fancy:** remove extra icons ([b66fde0](https://github.com/nuxt/consola/commit/b66fde0))
<a name="2.0.3"></a>
## [2.0.3](https://github.com/nuxt/consola/compare/v2.0.2...v2.0.3) (2018-11-02)
### Bug Fixes
* **pkg:** exclude src from package ([4b1fb7d](https://github.com/nuxt/consola/commit/4b1fb7d))
* use live console._stdout bindings for default stream ([d9573c3](https://github.com/nuxt/consola/commit/d9573c3))
<a name="2.0.2"></a>
## [2.0.2](https://github.com/nuxt/consola/compare/v2.0.1...v2.0.2) (2018-11-02)
### Bug Fixes
* **error:** always strip first line from stack ([3afa9aa](https://github.com/nuxt/consola/commit/3afa9aa))
<a name="2.0.1"></a>
## [2.0.1](https://github.com/nuxt/consola/compare/v2.0.0...v2.0.1) (2018-11-02)
### Bug Fixes
* **fancy:** use proper color for log paths ([7c75283](https://github.com/nuxt/consola/commit/7c75283))
<a name="2.0.0"></a>
# [2.0.0](https://github.com/nuxt/consola/compare/v2.0.0-2...v2.0.0) (2018-11-02)
<a name="2.0.0-2"></a>
# [2.0.0-2](https://github.com/nuxt/consola/compare/v2.0.0-1...v2.0.0-2) (2018-11-02)
### Bug Fixes
* add methods for legacy support ([4bdd034](https://github.com/nuxt/consola/commit/4bdd034))
* preserve additional new lines ([340a001](https://github.com/nuxt/consola/commit/340a001))
* update std-env to 2.1.0 ([2dc2a50](https://github.com/nuxt/consola/commit/2dc2a50))
### Features
* support badge with fancy ([38600fe](https://github.com/nuxt/consola/commit/38600fe))
<a name="2.0.0-1"></a>
# [2.0.0-1](https://github.com/nuxt/consola/compare/v2.0.0-0...v2.0.0-1) (2018-10-31)
<a name="2.0.0-0"></a>
# [2.0.0-0](https://github.com/nuxt/consola/compare/v1.4.4...v2.0.0-0) (2018-10-31)
### Bug Fixes
* add schmance.js ([2929648](https://github.com/nuxt/consola/commit/2929648))
* **docs:** update readme ([#22](https://github.com/nuxt/consola/issues/22)) ([e75f2a0](https://github.com/nuxt/consola/commit/e75f2a0))
* add default/undefined color for browser ([39584d2](https://github.com/nuxt/consola/commit/39584d2))
* add missing parseStack import ([da53dee](https://github.com/nuxt/consola/commit/da53dee))
* also copy symbols in assignGlobalReference ([b0eefb5](https://github.com/nuxt/consola/commit/b0eefb5))
* don't return this when calling log functions ([f07e056](https://github.com/nuxt/consola/commit/f07e056))
* fix badge display ([e036eed](https://github.com/nuxt/consola/commit/e036eed))
* fix main field ([4b56e48](https://github.com/nuxt/consola/commit/4b56e48))
* fix typos ([45e2f99](https://github.com/nuxt/consola/commit/45e2f99))
* handle null value of obj for assignToLogObj ([d2402af](https://github.com/nuxt/consola/commit/d2402af))
* improve browser packaging ([4d8c8d0](https://github.com/nuxt/consola/commit/4d8c8d0))
* lint ([f909761](https://github.com/nuxt/consola/commit/f909761))
* lint ([d976620](https://github.com/nuxt/consola/commit/d976620))
* only one color ending parameter is enough ([d213634](https://github.com/nuxt/consola/commit/d213634))
* readme: icon string length is digit ([31f1894](https://github.com/nuxt/consola/commit/31f1894))
* remove name assignment ([8d59075](https://github.com/nuxt/consola/commit/8d59075))
* remove pushes for better readability ([418d84a](https://github.com/nuxt/consola/commit/418d84a))
* rename private fields ([244fe5c](https://github.com/nuxt/consola/commit/244fe5c))
* rename require test file ([cfc8f9e](https://github.com/nuxt/consola/commit/cfc8f9e))
* return earlier on not displaying levels ([cfdcf04](https://github.com/nuxt/consola/commit/cfdcf04))
* support Error as logObject ([134ff54](https://github.com/nuxt/consola/commit/134ff54))
* text color comment ([9336fbc](https://github.com/nuxt/consola/commit/9336fbc))
* update demo ([3842e0e](https://github.com/nuxt/consola/commit/3842e0e))
* use symbols for private property access ([8e6343c](https://github.com/nuxt/consola/commit/8e6343c))
### Code Refactoring
* additionalStyle ~> additionalColor ([3f808e9](https://github.com/nuxt/consola/commit/3f808e9))
### Features
* add __VERSION__ to consola prototype ([982c8ca](https://github.com/nuxt/consola/commit/982c8ca))
* add assignGlobalConsola helper ([1af28f7](https://github.com/nuxt/consola/commit/1af28f7))
* add getter/setter for level ([7af5ed5](https://github.com/nuxt/consola/commit/7af5ed5))
* add global.consola ([4da784d](https://github.com/nuxt/consola/commit/4da784d))
* add shmancy reporter ([dc6121a](https://github.com/nuxt/consola/commit/dc6121a))
* add symbols to browser ([30cd4f0](https://github.com/nuxt/consola/commit/30cd4f0))
* add sync/async write ([8525525](https://github.com/nuxt/consola/commit/8525525))
* add typescript typings ([#24](https://github.com/nuxt/consola/issues/24)) ([0853a6f](https://github.com/nuxt/consola/commit/0853a6f))
* align basic and fancy reporter tags ([38a4729](https://github.com/nuxt/consola/commit/38a4729))
* better stack formater ([f5acb3c](https://github.com/nuxt/consola/commit/f5acb3c))
* detect version changes and throw a warning ([73bdd1a](https://github.com/nuxt/consola/commit/73bdd1a))
* improve packaging and exports ([90da862](https://github.com/nuxt/consola/commit/90da862))
* improve packaging for browser support ([47af1df](https://github.com/nuxt/consola/commit/47af1df))
* initial works for v2.0.0 ([455b6f9](https://github.com/nuxt/consola/commit/455b6f9))
* log formatting using printf ([2afb025](https://github.com/nuxt/consola/commit/2afb025))
* no more side effects ([c015c31](https://github.com/nuxt/consola/commit/c015c31))
* pause/resume ([f217cc1](https://github.com/nuxt/consola/commit/f217cc1))
* return new consola instance with consola.create ([4ae3614](https://github.com/nuxt/consola/commit/4ae3614))
* rework _createLogFn with better argument handling ([2d4af39](https://github.com/nuxt/consola/commit/2d4af39))
* scope inheritance support ([#23](https://github.com/nuxt/consola/issues/23)) ([0070c54](https://github.com/nuxt/consola/commit/0070c54))
* **fancy/basic:** support logObj.stack field ([aa2216f](https://github.com/nuxt/consola/commit/aa2216f))
* setReporters, withDefaults and withTag ([912446f](https://github.com/nuxt/consola/commit/912446f))
* showType option ([ed294e4](https://github.com/nuxt/consola/commit/ed294e4))
* style browser reporter ([d39684d](https://github.com/nuxt/consola/commit/d39684d))
* support all chalk colors ([2cec678](https://github.com/nuxt/consola/commit/2cec678)), closes [#20](https://github.com/nuxt/consola/issues/20)
* wrapConsole ([3962a1f](https://github.com/nuxt/consola/commit/3962a1f))
* wrapStd ([f8bfbeb](https://github.com/nuxt/consola/commit/f8bfbeb))
* write error and warns to process.stderr by default ([6565254](https://github.com/nuxt/consola/commit/6565254))
### Performance Improvements
* **basic:** refactor getWriteMethod ([c52db69](https://github.com/nuxt/consola/commit/c52db69))
* remove all DEPRECATED helpers for less bundle size ([fe39d37](https://github.com/nuxt/consola/commit/fe39d37))
### BREAKING CHANGES
* Use new additionalColor prop
* lot's of internals had been changed.
* Behavior may be changed in some conditions
<a name="1.4.4"></a>
## [1.4.4](https://github.com/nuxt/consola/compare/v1.4.3...v1.4.4) (2018-10-13)
### Bug Fixes
* add global.consola ([558cae5](https://github.com/nuxt/consola/commit/558cae5))
<a name="1.4.3"></a>
## [1.4.3](https://github.com/nuxt/consola/compare/v1.4.2...v1.4.3) (2018-08-18)
### Bug Fixes
* use more compatible string to clear the console ([82ce410](https://github.com/nuxt/consola/commit/82ce410))
<a name="1.4.2"></a>
## [1.4.2](https://github.com/nuxt/consola/compare/v1.4.1...v1.4.2) (2018-08-12)
### Bug Fixes
* cannot set level as 0 in options ([4c1ecce](https://github.com/nuxt/consola/commit/4c1ecce))
<a name="1.4.1"></a>
## [1.4.1](https://github.com/nuxt/consola/compare/v1.4.0...v1.4.1) (2018-05-27)
### Bug Fixes
* **fancy:** logObj.type ([418be28](https://github.com/nuxt/consola/commit/418be28))
<a name="1.4.0"></a>
# [1.4.0](https://github.com/nuxt/consola/compare/v1.3.0...v1.4.0) (2018-05-27)
### Features
* support custom additional style ([#18](https://github.com/nuxt/consola/issues/18)) ([7a750bf](https://github.com/nuxt/consola/commit/7a750bf))
* **fancy:** support icon field ([0123bed](https://github.com/nuxt/consola/commit/0123bed))
<a name="1.3.0"></a>
# [1.3.0](https://github.com/nuxt/consola/compare/v1.2.0...v1.3.0) (2018-04-15)
### Bug Fixes
* **reporters/fancy:** extra space for additional ([efeab44](https://github.com/nuxt/consola/commit/efeab44))
* prevent duplicate consola instances when different versions used by packages ([0bce262](https://github.com/nuxt/consola/commit/0bce262))
### Features
* support extra log arguments ([8b6d3d2](https://github.com/nuxt/consola/commit/8b6d3d2))
<a name="1.2.0"></a>
# [1.2.0](https://github.com/nuxt/consola/compare/v1.1.4...v1.2.0) (2018-04-02)
### Features
* **basic:** support additional field ([b50cad8](https://github.com/nuxt/consola/commit/b50cad8))
* improve packaging ([158e8ef](https://github.com/nuxt/consola/commit/158e8ef))
### Performance Improvements
* require needed lodash methods only ([91065e4](https://github.com/nuxt/consola/commit/91065e4))
<a name="1.1.4"></a>
## [1.1.4](https://github.com/nuxt/consola/compare/v1.1.3...v1.1.4) (2018-03-31)
### Bug Fixes
* **package:** add chalk to dependencies ([3f738e9](https://github.com/nuxt/consola/commit/3f738e9))
<a name="1.1.3"></a>
## [1.1.3](https://github.com/nuxt/consola/compare/v1.1.2...v1.1.3) (2018-03-31)
### Bug Fixes
* only include dist and src in package ([8b477ec](https://github.com/nuxt/consola/commit/8b477ec))
<a name="1.1.2"></a>
## [1.1.2](https://github.com/nuxt/consola/compare/v1.1.1...v1.1.2) (2018-03-31)
### Bug Fixes
* handle null and undefined calls ([1f98bb1](https://github.com/nuxt/consola/commit/1f98bb1))
<a name="1.1.1"></a>
## [1.1.1](https://github.com/nuxt/consola/compare/v1.1.0...v1.1.1) (2018-03-31)
### Bug Fixes
* add prepublish script ([8dd8700](https://github.com/nuxt/consola/commit/8dd8700))
<a name="1.1.0"></a>
# [1.1.0](https://github.com/nuxt/consola/compare/v1.0.0...v1.1.0) (2018-03-31)
### Features
* rewrite FancyReporter without ora ([73c1ddc](https://github.com/nuxt/consola/commit/73c1ddc))
<a name="1.0.0"></a>
# [1.0.0](https://github.com/nuxt/consola/compare/v0.1.0...v1.0.0) (2018-03-31)
<a name="0.1.0"></a>
# 0.1.0 (2018-03-31)
### Features
* add log type for console compability ([96a8162](https://github.com/nuxt/consola/commit/96a8162))
+287
View File
@@ -0,0 +1,287 @@
<p align="center">
<h1>🐨 Consola</h1>
<span>Elegant Console Logger for Node.js and Browser</span>
</p>
[![Standard JS][standard-js-src]][standard-js-href]
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![package phobia][package-phobia-src]][package-phobia-href]
[![bundle phobia][bundle-phobia-src]][bundle-phobia-href]
## Why Consola?
- Easy to use
- Fancy output with fallback for minimal environments
- Pluggable reporters
- Consistent command line interface (CLI) experience
- Tag support
- Redirect `console` and `stdout/stderr` to the consola and easily restore redirect.
- Browser support
- Pause/Resume support
- Mocking support
- Spam prevention by throttling logs
## Installation
Using yarn:
```bash
yarn add consola
```
Using npm:
```bash
npm i consola
```
## Getting Started
```js
const consola = require('consola')
// See types section for all available types
consola.success('Built!')
consola.info('Reporter: Some info')
consola.error(new Error('Foo'))
```
Will display in the terminal:
![Screenshot 2020-01-28 at 14 15 15](https://user-images.githubusercontent.com/904724/73267133-af6b2f00-41d8-11ea-9f16-4a8243d19c43.png)
**NOTE:** Alternatively, you can import consola from source. But don't forget to whitelist it for transpilation:
```js
import consola from 'consola/src/node'
import consola from 'consola/src/browser'
```
## Methods
#### `<type>(logObject)` `<type>(args...)`
Log to all reporters.
Example: `consola.info('Message')`
A list of available types can be found [here](./src/types.js).
#### `addReporter(reporter)`
- Aliases: `add`
Register a custom reporter instance.
#### `removeReporter(reporter?)`
- Aliases: `remove`, `clear`
Remove a registered reporter.
If no arguments are passed all reporters will be removed.
#### `setReporters(reporter|reporter[])`
Replace all reporters.
#### `create(options)`
Create a new `Consola` instance and inherit all parent options for defaults.
#### `withDefaults(defaults)`
Create a new `Consola` instance with provided defaults
#### `withTag(tag)`
- Aliases: `withScope`
Create a new `Consola` instance with that tag.
#### `wrapConsole()` `restoreConsole()`
Globally redirect all `console.log`, etc calls to consola handlers.
#### `wrapStd()` `restoreStd()`
Globally redirect all stdout/stderr outputs to consola.
#### `wrapAll()` `restoreAll()`
Wrap both, std and console.
console uses std in the underlying so calling `wrapStd` redirects console too.
Benefit of this function is that things like `console.info` will be correctly redirected to the corresponding type.
#### `pauseLogs()` `resumeLogs()`
- Aliases: `pause`/`resume`
**Globally** pause and resume logs.
Consola will enqueue all logs when paused and then sends them to the reported when resumed.
#### `mockTypes`
- Aliases: `mock`
Mock all types. Useful for using with tests.
The first argument passed to `mockTypes` should be a callback function accepting `(typeName, type)` and returning the mocked value:
```js
consola.mockTypes((typeName, type) => jest.fn())
```
Please note that with the example above, everything is mocked independently for each type. If you need one mocked fn create it outside:
```js
const fn = jest.fn()
consola.mockTypes(() => fn)
```
If callback function returns a _falsy_ value, that type won't be mocked.
For example if you just need to mock `consola.fatal`:
```js
consola.mockTypes((typeName) => typeName === 'fatal' && jest.fn())
```
**NOTE:** Any instance of consola that inherits the mocked instance, will apply provided callback again.
This way, mocking works for `withTag` scoped loggers without need to extra efforts.
## Fields
#### `reporters`
An array of active reporters.
#### `level`
The level to display logs. Any logs at or above this level will be displayed.
List of available levels [here](./src/types.js).
You can set log level using `CONSOLA_LEVEL` environment variable.
## `logObject`
The `logObject` is a free-to-extend object which will be passed to reporters.
Standard fields:
- `message`
- `additional`
- `args`
- `date`
- `tag`
Extra fields:
- `badge`
## Reporters
Choose between one of the built-in reporters or bring in your own one.
By default `FancyReporter` is registered for modern terminals or `BasicReporter` will be used if running in limited environments such as CIs.
Available reporters:
- [BasicReporter](./src/reporters/basic.js)
- [FancyReporter](./src/reporters/fancy.js)
- [JSONReporter](./src/reporters/json.js)
- [WinstonReporter](./src/reporters/winston.js)
### Creating your own reporter
A reporter (class or object) exposes `log(logObj)` method.
To get more info about how to write your own reporter, take a look into the linked implementations above.
## Types
Types are used to actually log messages to the reporters.
Each type is attached to a _logging level_.
A list of all available default types is [here](./src/types.js).
## Creating a new instance
Consola has a global instance and is recommended to use everywhere.
In case more control is needed, create a new instance.
```js
import consola from 'consola'
const logger = consola.create({
// level: 4,
reporters: [
new consola.JSONReporter()
],
defaults: {
additionalColor: 'white'
}
})
```
## Integrations
### With jest
```js
describe('your-consola-mock-test', () => {
beforeAll(() => {
// Redirect std and console to consola too
// Calling this once is sufficient
consola.wrapAll()
})
beforeEach(() => {
// Re-mock consola before each test call to remove
// calls from before
consola.mockTypes(() => jest.fn())
})
test('your test', async () => {
// Some code here
// Let's retrieve all messages of `consola.log`
// Get the mock and map all calls to their first argument
const consolaMessages = consola.log.mock.calls.map(c => c[0])
expect(consolaMessages).toContain('your message')
})
})
```
### With jsdom
```js
{
virtualConsole: new jsdom.VirtualConsole().sendTo(consola)
}
```
## License
MIT - Made with 💖 By Nuxt.js team!
<!-- Refs -->
[standard-js-src]: https://flat.badgen.net/badge/code%20style/standard/green
[standard-js-href]: https://standardjs.com
[npm-version-src]: https://flat.badgen.net/npm/v/consola/latest
[npm-version-href]: https://npmjs.com/package/consola
[npm-downloads-src]: https://flat.badgen.net/npm/dt/consola
[npm-downloads-href]: https://npmjs.com/package/consola
[package-phobia-src]: https://flat.badgen.net/packagephobia/install/consola
[package-phobia-href]: https://packagephobia.now.sh/result?p=consola
[bundle-phobia-src]: https://flat.badgen.net/bundlephobia/minzip/consola
[bundle-phobia-href]: https://bundlephobia.com/result?p=consola
+1
View File
@@ -0,0 +1 @@
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).consola=e()}(this,(function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function r(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}function o(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,o)}return r}function s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function i(t){return function(t){if(Array.isArray(t))return l(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||a(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,e){if(t){if("string"==typeof t)return l(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}function u(t){if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=a(t))){var e=0,r=function(){};return{s:r,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,n,s=!0,i=!1;return{s:function(){o=t[Symbol.iterator]()},n:function(){var t=o.next();return s=t.done,t},e:function(t){i=!0,n=t},f:function(){try{s||null==o.return||o.return()}finally{if(i)throw n}}}}var c={};c[c.Fatal=0]="Fatal",c[c.Error=0]="Error",c[c.Warn=1]="Warn",c[c.Log=2]="Log",c[c.Info=3]="Info",c[c.Success=3]="Success",c[c.Debug=4]="Debug",c[c.Trace=5]="Trace",c[c.Silent=-1/0]="Silent",c[c.Verbose=1/0]="Verbose";var f={silent:{level:-1},fatal:{level:c.Fatal},error:{level:c.Error},warn:{level:c.Warn},log:{level:c.Log},info:{level:c.Info},success:{level:c.Success},debug:{level:c.Debug},trace:{level:c.Trace},verbose:{level:c.Trace},ready:{level:c.Info},start:{level:c.Info}};function p(t){return e=t,"[object Object]"===Object.prototype.toString.call(e)&&(!(!t.message&&!t.args)&&!t.stack);var e}var h=!1,y=[],d=function(){function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var o in t(this,e),this._reporters=r.reporters||[],this._types=r.types||f,this.level=void 0!==r.level?r.level:3,this._defaults=r.defaults||{},this._async=void 0!==r.async?r.async:void 0,this._stdout=r.stdout,this._stderr=r.stderr,this._mockFn=r.mockFn,this._throttle=r.throttle||1e3,this._throttleMin=r.throttleMin||5,this._types)this[o]=this._wrapLogFn(Object.assign({type:o},this._types[o],this._defaults));this._mockFn&&this.mockTypes(),this._lastLogSerialized=void 0,this._lastLog=void 0,this._lastLogTime=void 0,this._lastLogCount=0,this._throttleTimeout=void 0}return r(e,[{key:"create",value:function(t){return new e(Object.assign({reporters:this._reporters,level:this.level,types:this._types,defaults:this._defaults,stdout:this._stdout,stderr:this._stderr,mockFn:this._mockFn},t))}},{key:"withDefaults",value:function(t){return this.create({defaults:Object.assign({},this._defaults,t)})}},{key:"withTag",value:function(t){return this.withDefaults({tag:this._defaults.tag?this._defaults.tag+":"+t:t})}},{key:"addReporter",value:function(t){return this._reporters.push(t),this}},{key:"removeReporter",value:function(t){if(t){var e=this._reporters.indexOf(t);if(e>=0)return this._reporters.splice(e,1)}else this._reporters.splice(0);return this}},{key:"setReporters",value:function(t){return this._reporters=Array.isArray(t)?t:[t],this}},{key:"wrapAll",value:function(){this.wrapConsole(),this.wrapStd()}},{key:"restoreAll",value:function(){this.restoreConsole(),this.restoreStd()}},{key:"wrapConsole",value:function(){for(var t in this._types)console["__"+t]||(console["__"+t]=console[t]),console[t]=this[t]}},{key:"restoreConsole",value:function(){for(var t in this._types)console["__"+t]&&(console[t]=console["__"+t],delete console["__"+t])}},Line truncated
+1
View File
@@ -0,0 +1 @@
"use strict";function u(u){return u&&"object"==typeof u&&"default"in u?u.default:u}var D=u(require("util")),e=require("path"),t=require("fs"),r=u(require("os")),n=u(require("tty"));"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function s(u,D){return u(D={exports:{}},D.exports),D.exports}var o,i=(o=Object.freeze({__proto__:null,default:[{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Shippable",constant:"SHIPPABLE",env:"SHIPPABLE",pr:{IS_PULL_REQUEST:"true"}},{name:"Solano CI",constant:"SOLANO",env:"TDDIUM",pr:"TDDIUM_PR_ID"},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"Solano CI",constant:"TDDIUM",env:"TDDIUM",pr:"TDDIUM_PR_ID",deprecated:!0},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Team Foundation Server",constant:"TFS",env:"TF_BUILD"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}}]}))&&o.default||o,a=s((function(u,D){var e=process.env;function t(u){return"string"==typeof u?!!e[u]:Object.keys(u).every((function(D){return e[D]===u[D]}))}Object.defineProperty(D,"_vendors",{value:i.map((function(u){return u.constant}))}),D.name=null,D.isPR=null,i.forEach((function(u){var r=(Array.isArray(u.env)?u.env:[u.env]).every((function(u){return t(u)}));if(D[u.constant]=r,r)switch(D.name=u.name,typeof u.pr){case"string":D.isPR=!!e[u.pr];break;case"object":"env"in u.pr?D.isPR=u.pr.env in e&&e[u.pr.env]!==u.pr.ne:"any"in u.pr?D.isPR=u.pr.any.some((function(u){return!!e[u]})):D.isPR=t(u.pr);break;default:D.isPR=null}})),D.isCI=!!(e.CI||e.CONTINUOUS_INTEGRATION||e.BUILD_NUMBER||e.RUN_ID||D.name)})),l=(a.name,a.isPR,a.isCI,!1),c=!1,h=!1,F="development",C="undefined"!=typeof window,f="",E=!1;function d(u){return!(!u||"false"===u)}"undefined"!=typeof process&&(process.platform&&(f=String(process.platform)),process.stdout&&(h=d(process.stdout.isTTY)),l=Boolean(a.isCI),process.env&&(process.env.NODE_ENV&&(F=process.env.NODE_ENV),c=d(process.env.DEBUG),E=d(process.env.MINIMAL)));var g={browser:C,test:"test"===F,dev:"development"===F||"dev"===F,production:"production"===F,debug:c,ci:l,tty:h,minimal:void 0,minimalCLI:void 0,windows:/^win/i.test(f),darwin:/^darwin/i.test(f),linux:/^linux/i.test(f)};g.minimal=E||g.ci||g.test||!g.tty,g.minimalCLI=g.minimal;var p=Object.freeze(g);const m={};m[m.Fatal=0]="Fatal",m[m.Error=0]="Error",m[m.Warn=1]="Warn",m[m.Log=2]="Log",m[m.Info=3]="Info",m[m.Success=3]="Success",m[m.Debug=4]="Debug",m[m.Trace=5]="Trace",m[m.Silent=-1/0]="Silent",m[m.Verbose=1/0]="Verbose";var b={silent:{level:-1},fatal:{level:m.Fatal},error:{level:m.Error},warn:{level:m.Warn},log:{level:m.Log},info:{level:m.Info},success:{level:m.Success},debug:{level:m.Debug},trace:{level:m.Trace},verbose:{level:m.Trace},ready:{level:m.Info},start:{level:m.Info}};function y(u){return D=u,"[object Object]"===Object.prototype.toString.call(D)&&(!(!u.message&&!u.args)&&!u.stack);var D}let B=!1;const v=[];class _{constructor(u={}){this._reporters=u.reporters||[],this._types=u.types||b,this.level=void 0!==u.level?u.level:3,this._defaults=u.defaults||{},this._async=void 0!==u.async?u.async:void 0,this._stdout=u.stdout,this._stderr=u.stderr,this._mockFn=u.mockFn,this._throttle=u.throttle||1e3,this._throttleMin=u.throttleMin||5;for(const u in this._types)this[u]=this._wrapLogFn(Object.assign({type:u},this._types[u],this._defaults));this._mockFn&&this.mockTypes(),this._lastLogSerialized=void 0,this._lastLog=void 0,this._lastLogTime=void 0,this._lastLogCount=0,this._throttleTimeout=void 0}get stdout(){retLine truncated
+119
View File
@@ -0,0 +1,119 @@
{
"_args": [
[
"consola@2.15.0",
"/Users/oliverbarr/Documents/Discord Bots/SupportBot"
]
],
"_from": "consola@2.15.0",
"_id": "consola@2.15.0",
"_inBundle": false,
"_integrity": "sha512-vlcSGgdYS26mPf7qNi+dCisbhiyDnrN1zaRbw3CSuc2wGOMEGGPsp46PdRG5gqXwgtJfjxDkxRNAgRPr1B77vQ==",
"_location": "/consola",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "consola@2.15.0",
"name": "consola",
"escapedName": "consola",
"rawSpec": "2.15.0",
"saveSpec": null,
"fetchSpec": "2.15.0"
},
"_requiredBy": [
"/@nuxtjs/opencollective"
],
"_resolved": "https://registry.npmjs.org/consola/-/consola-2.15.0.tgz",
"_spec": "2.15.0",
"_where": "/Users/oliverbarr/Documents/Discord Bots/SupportBot",
"browser": "dist/consola.browser.js",
"bugs": {
"url": "https://github.com/nuxt/consola/issues"
},
"contributors": [
{
"name": "Pooya Parsa",
"email": "pooya@pi0.ir"
},
{
"name": "Clark Du",
"url": "@clarkdo"
},
{
"name": "@pimlie",
"email": "pimlie@hotmail.com"
},
{
"name": "Sébastien Chopin",
"email": "@Atinux"
}
],
"description": "Elegant Console Logger for Node.js and Browser",
"devDependencies": {
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"benchmark": "^2.1.4",
"bili": "^4.10.0",
"chalk": "^4.0.0",
"dayjs": "^1.8.26",
"eslint": "^7.1.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^23.9.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"esm": "^3.2.25",
"figures": "^3.2.0",
"jest": "^26.0.1",
"lodash": "^4.17.15",
"sentencer": "^0.2.1",
"serve": "^11.3.0",
"standard-version": "^8.0.0",
"std-env": "^2.2.1",
"string-width": "^4.2.0",
"ts-node": "^8.10.1",
"typescript": "^3.8.3",
"winston": "^3.2.1"
},
"files": [
"src",
"dist",
"types"
],
"homepage": "https://github.com/nuxt/consola#readme",
"keywords": [
"console",
"logger",
"reporter",
"elegant",
"cli",
"universal",
"unified",
"winston"
],
"license": "MIT",
"main": "dist/consola.js",
"name": "consola",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt/consola.git"
},
"scripts": {
"browser": "serve",
"build": "rm -rf dist && yarn build:node && yarn build:browser",
"build:browser": "NODE_ENV=browser bili src/browser.js --file-name consola.browser.js --format umd --module-name consola --bundle-node-modules --minify --no-map",
"build:node": "NODE_ENV=node bili src/node.js --file-name consola.js --format cjs --bundle-node-modules --minify --no-map",
"demo": "node demo",
"lint": "eslint .",
"prepublish": "yarn build",
"release": "standard-version && yarn build && git push --follow-tags && npm publish",
"test": "yarn lint && yarn test:types && yarn build && jest test",
"test:types": "tsc -p test/types"
},
"typings": "types/consola.d.ts",
"version": "2.15.0"
}
+20
View File
@@ -0,0 +1,20 @@
import Consola from './consola.js'
import BrowserReporter from './reporters/browser.js'
import { LogLevel } from './logLevels'
function createConsola () {
const consola = new Consola({
reporters: [
new BrowserReporter()
]
})
// Expose constructors
consola.Consola = Consola
consola.LogLevel = LogLevel
consola.BrowserReporter = BrowserReporter
return consola
}
export default (typeof window !== 'undefined' && window.consola) || createConsola()
+326
View File
@@ -0,0 +1,326 @@
import Types from './types.js'
import { isLogObj } from './utils/index.js'
let paused = false
const queue = []
class Consola {
constructor (options = {}) {
this._reporters = options.reporters || []
this._types = options.types || Types
this.level = options.level !== undefined ? options.level : 3
this._defaults = options.defaults || {}
this._async = options.async !== undefined ? options.async : undefined
this._stdout = options.stdout
this._stderr = options.stderr
this._mockFn = options.mockFn
this._throttle = options.throttle || 1000
this._throttleMin = options.throttleMin || 5
// Create logger functions for current instance
for (const type in this._types) {
this[type] = this._wrapLogFn(Object.assign(
{ type },
this._types[type],
this._defaults
))
}
// Use _mockFn if is set
if (this._mockFn) {
this.mockTypes()
}
// Keep serialized version of last log
this._lastLogSerialized = undefined
this._lastLog = undefined
this._lastLogTime = undefined
this._lastLogCount = 0
this._throttleTimeout = undefined
}
get stdout () {
return this._stdout || console._stdout // eslint-disable-line no-console
}
get stderr () {
return this._stderr || console._stderr // eslint-disable-line no-console
}
create (options) {
return new Consola(Object.assign({
reporters: this._reporters,
level: this.level,
types: this._types,
defaults: this._defaults,
stdout: this._stdout,
stderr: this._stderr,
mockFn: this._mockFn
}, options))
}
withDefaults (defaults) {
return this.create({
defaults: Object.assign({}, this._defaults, defaults)
})
}
withTag (tag) {
return this.withDefaults({
tag: this._defaults.tag ? (this._defaults.tag + ':' + tag) : tag
})
}
addReporter (reporter) {
this._reporters.push(reporter)
return this
}
removeReporter (reporter) {
if (reporter) {
const i = this._reporters.indexOf(reporter)
if (i >= 0) {
return this._reporters.splice(i, 1)
}
} else {
this._reporters.splice(0)
}
return this
}
setReporters (reporters) {
this._reporters = Array.isArray(reporters)
? reporters
: [reporters]
return this
}
wrapAll () {
this.wrapConsole()
this.wrapStd()
}
restoreAll () {
this.restoreConsole()
this.restoreStd()
}
wrapConsole () {
for (const type in this._types) {
// Backup original value
if (!console['__' + type]) { // eslint-disable-line no-console
console['__' + type] = console[type] // eslint-disable-line no-console
}
// Override
console[type] = this[type] // eslint-disable-line no-console
}
}
restoreConsole () {
for (const type in this._types) {
// Restore if backup is available
if (console['__' + type]) { // eslint-disable-line no-console
console[type] = console['__' + type] // eslint-disable-line no-console
delete console['__' + type] // eslint-disable-line no-console
}
}
}
wrapStd () {
this._wrapStream(this.stdout, 'log')
this._wrapStream(this.stderr, 'log')
}
_wrapStream (stream, type) {
if (!stream) {
return
}
// Backup original value
if (!stream.__write) {
stream.__write = stream.write
}
// Override
stream.write = (data) => {
this[type](String(data).trim())
}
}
restoreStd () {
this._restoreStream(this.stdout)
this._restoreStream(this.stderr)
}
_restoreStream (stream) {
if (!stream) {
return
}
if (stream.__write) {
stream.write = stream.__write
delete stream.__write
}
}
pauseLogs () {
paused = true
}
resumeLogs () {
paused = false
// Process queue
const _queue = queue.splice(0)
for (const item of _queue) {
item[0]._logFn(item[1], item[2])
}
}
mockTypes (mockFn) {
this._mockFn = mockFn || this._mockFn
if (typeof this._mockFn !== 'function') {
return
}
for (const type in this._types) {
this[type] = this._mockFn(type, this._types[type]) || this[type]
}
}
_wrapLogFn (defaults) {
function logFn () {
if (paused) {
queue.push([this, defaults, arguments])
return
}
return this._logFn(defaults, arguments)
}
return logFn.bind(this)
}
_logFn (defaults, args) {
if (defaults.level > this.level) {
return this._async ? Promise.resolve(false) : false
}
// Construct a new log object
const logObj = Object.assign({
date: new Date(),
args: []
}, defaults)
// Consume arguments
if (args.length === 1 && isLogObj(args[0])) {
Object.assign(logObj, args[0])
} else {
logObj.args = Array.from(args)
}
// Aliases
if (logObj.message) {
logObj.args.unshift(logObj.message)
delete logObj.message
}
if (logObj.additional) {
if (!Array.isArray(logObj.additional)) {
logObj.additional = logObj.additional.split('\n')
}
logObj.args.push('\n' + logObj.additional.join('\n'))
delete logObj.additional
}
// Normalize type and tag to lowercase
logObj.type = typeof logObj.type === 'string' ? logObj.type.toLowerCase() : ''
logObj.tag = typeof logObj.tag === 'string' ? logObj.tag.toLowerCase() : ''
// Resolve log
/**
* @param newLog false if the throttle expired and
* we don't want to log a duplicate
*/
const resolveLog = (newLog = false) => {
const repeated = this._lastLogCount - this._throttleMin
if (this._lastLog && repeated > 0) {
const args = [...this._lastLog.args]
if (repeated > 1) {
args.push(`(repeated ${repeated} times)`)
}
this._log({ ...this._lastLog, args })
this._lastLogCount = 1
}
// Log
if (newLog) {
this._lastLog = logObj
if (this._async) {
return this._logAsync(logObj)
} else {
this._log(logObj)
}
}
}
// Throttle
clearTimeout(this._throttleTimeout)
const diffTime = this._lastLogTime ? logObj.date - this._lastLogTime : 0
this._lastLogTime = logObj.date
if (diffTime < this._throttle) {
try {
const serializedLog = JSON.stringify([logObj.type, logObj.tag, logObj.args])
const isSameLog = this._lastLogSerialized === serializedLog
this._lastLogSerialized = serializedLog
if (isSameLog) {
this._lastLogCount++
if (this._lastLogCount > this._throttleMin) {
// Auto-resolve when throttle is timed out
this._throttleTimeout = setTimeout(resolveLog, this._throttle)
return // SPAM!
}
}
} catch (_) {
// Circular References
}
}
resolveLog(true)
}
_log (logObj) {
for (const reporter of this._reporters) {
reporter.log(logObj, {
async: false,
stdout: this.stdout,
stderr: this.stderr
})
}
}
_logAsync (logObj) {
return Promise.all(
this._reporters.map(reporter => reporter.log(logObj, {
async: true,
stdout: this.stdout,
stderr: this.stderr
}))
)
}
}
// Legacy support
Consola.prototype.add = Consola.prototype.addReporter
Consola.prototype.remove = Consola.prototype.removeReporter
Consola.prototype.clear = Consola.prototype.removeReporter
Consola.prototype.withScope = Consola.prototype.withTag
Consola.prototype.mock = Consola.prototype.mockTypes
Consola.prototype.pause = Consola.prototype.pauseLogs
Consola.prototype.resume = Consola.prototype.resumeLogs
// Export class
export default Consola
+7
View File
@@ -0,0 +1,7 @@
export { default as Consola } from './consola'
export { default as Types } from './types'
export { LogLevel } from './logLevels'
export { isLogObj } from './utils'
export { assignGlobalConsola } from './utils/global'
export * from './reporters'
+11
View File
@@ -0,0 +1,11 @@
export const LogLevel = {}
LogLevel[LogLevel.Fatal = 0] = 'Fatal'
LogLevel[LogLevel.Error = 0] = 'Error'
LogLevel[LogLevel.Warn = 1] = 'Warn'
LogLevel[LogLevel.Log = 2] = 'Log'
LogLevel[LogLevel.Info = 3] = 'Info'
LogLevel[LogLevel.Success = 3] = 'Success'
LogLevel[LogLevel.Debug = 4] = 'Debug'
LogLevel[LogLevel.Trace = 5] = 'Trace'
LogLevel[LogLevel.Silent = -Infinity] = 'Silent'
LogLevel[LogLevel.Verbose = Infinity] = 'Verbose'
+36
View File
@@ -0,0 +1,36 @@
import env from 'std-env'
import { Consola, BasicReporter, FancyReporter, JSONReporter, WinstonReporter, LogLevel } from '.'
function createConsola () {
// Log level
let level = env.debug ? 4 : 3
if (process.env.CONSOLA_LEVEL) {
level = parseInt(process.env.CONSOLA_LEVEL) || level
}
// Create new consola instance
const consola = new Consola({
level,
reporters: [
(env.ci || env.test)
? new BasicReporter()
: new FancyReporter()
]
})
// Expose constructors
consola.Consola = Consola
consola.BasicReporter = BasicReporter
consola.FancyReporter = FancyReporter
consola.JSONReporter = JSONReporter
consola.WinstonReporter = WinstonReporter
consola.LogLevel = LogLevel
return consola
}
if (!global.consola) {
global.consola = createConsola()
}
export default global.consola
+72
View File
@@ -0,0 +1,72 @@
import util from 'util'
import { parseStack } from '../utils/error'
import { writeStream } from '../utils/stream'
import { formatDate } from '../utils/date'
const DEFAULTS = {
dateFormat: 'HH:mm:ss',
formatOptions: {
date: true,
colors: false,
compact: true
}
}
const bracket = x => x ? `[${x}]` : ''
export default class BasicReporter {
constructor (options) {
this.options = Object.assign({}, DEFAULTS, options)
}
formatStack (stack) {
return ' ' + parseStack(stack).join('\n ')
}
formatArgs (args) {
const _args = args.map(arg => {
if (arg && typeof arg.stack === 'string') {
return arg.message + '\n' + this.formatStack(arg.stack)
}
return arg
})
// Only supported with Node >= 10
// https://nodejs.org/api/util.html#util_util_inspect_object_options
if (typeof util.formatWithOptions === 'function') {
return util.formatWithOptions(this.options.formatOptions, ..._args)
} else {
return util.format(..._args)
}
}
formatDate (date) {
return this.options.formatOptions.date ? formatDate(this.options.dateFormat, date) : ''
}
filterAndJoin (arr) {
return arr.filter(x => x).join(' ')
}
formatLogObj (logObj) {
const message = this.formatArgs(logObj.args)
return this.filterAndJoin([
bracket(logObj.type),
bracket(logObj.tag),
message
])
}
log (logObj, { async, stdout, stderr } = {}) {
const line = this.formatLogObj(logObj, {
width: stdout.columns || 0
})
return writeStream(
line + '\n',
logObj.level < 2 ? stderr : stdout,
async ? 'async' : 'default'
)
}
}
+54
View File
@@ -0,0 +1,54 @@
export default class BrowserReporter {
constructor (options) {
this.options = Object.assign({}, options)
this.defaultColor = '#7f8c8d' // Gray
this.levelColorMap = {
0: '#c0392b', // Red
1: '#f39c12', // Yellow
3: '#00BCD4' // Cyan
}
this.typeColorMap = {
success: '#2ecc71' // Green
}
}
log (logObj) {
const consoleLogFn = logObj.level < 1
// eslint-disable-next-line no-console
? (console.__error || console.error)
// eslint-disable-next-line no-console
: logObj.level === 1 && console.warn ? (console.__warn || console.warn) : (console.__log || console.log)
// Type
const type = logObj.type !== 'log' ? logObj.type : ''
// Tag
const tag = logObj.tag ? logObj.tag : ''
// Styles
const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor
const style = `
background: ${color};
border-radius: 0.5em;
color: white;
font-weight: bold;
padding: 2px 0.5em;
`
const badge = `%c${[tag, type].filter(Boolean).join(':')}`
// Log to the console
if (typeof logObj.args[0] === 'string') {
consoleLogFn(
`${badge}%c ${logObj.args[0]}`,
style,
// Empty string as style resets to default console style
'',
...logObj.args.slice(1)
)
} else {
consoleLogFn(badge, style, ...logObj.args)
}
}
}
+87
View File
@@ -0,0 +1,87 @@
import stringWidth from 'string-width'
import figures from 'figures'
import chalk from 'chalk'
import BasicReporter from './basic'
import { parseStack } from '../utils/error'
import { chalkColor, chalkBgColor } from '../utils/chalk'
import { TYPE_COLOR_MAP, LEVEL_COLOR_MAP } from '../utils/fancy'
const DEFAULTS = {
secondaryColor: 'grey',
formatOptions: {
date: true,
colors: true,
compact: false
}
}
const TYPE_ICONS = {
info: figures('ℹ'),
success: figures('✔'),
debug: figures('›'),
trace: figures('›'),
log: ''
}
export default class FancyReporter extends BasicReporter {
constructor (options) {
super(Object.assign({}, DEFAULTS, options))
}
formatStack (stack) {
const grey = chalkColor('grey')
const cyan = chalkColor('cyan')
return '\n' + parseStack(stack)
.map(line => ' ' + line
.replace(/^at +/, m => grey(m))
.replace(/\((.+)\)/, (_, m) => `(${cyan(m)})`)
)
.join('\n')
}
formatType (logObj, isBadge) {
const typeColor = TYPE_COLOR_MAP[logObj.type] ||
LEVEL_COLOR_MAP[logObj.level] ||
this.options.secondaryColor
if (isBadge) {
return chalkBgColor(typeColor).black(` ${logObj.type.toUpperCase()} `)
}
const _type = typeof TYPE_ICONS[logObj.type] === 'string' ? TYPE_ICONS[logObj.type] : (logObj.icon || logObj.type)
return _type ? chalkColor(typeColor)(_type) : ''
}
formatLogObj (logObj, { width }) {
const [message, ...additional] = this.formatArgs(logObj.args).split('\n')
const isBadge = typeof logObj.badge !== 'undefined' ? Boolean(logObj.badge) : logObj.level < 2
const secondaryColor = chalkColor(this.options.secondaryColor)
const date = this.formatDate(logObj.date)
const coloredDate = date && secondaryColor(date)
const type = this.formatType(logObj, isBadge)
const tag = logObj.tag ? secondaryColor(logObj.tag) : ''
const formattedMessage = message.replace(/`([^`]+)`/g, (_, m) => chalk.cyan(m))
let line
const left = this.filterAndJoin([type, formattedMessage])
const right = this.filterAndJoin([tag, coloredDate])
const space = width - stringWidth(left) - stringWidth(right) - 2
if (space > 0 && width >= 80) {
line = left + ' '.repeat(space) + right
} else {
line = left
}
line += additional.length ? '\n' + additional.join('\n') : ''
return isBadge ? '\n' + line + '\n' : line
}
}
+5
View File
@@ -0,0 +1,5 @@
export { default as BasicReporter } from './basic'
export { default as BrowserReporter } from './browser'
export { default as FancyReporter } from './fancy'
export { default as JSONReporter } from './json'
export { default as WinstonReporter } from './winston'
+9
View File
@@ -0,0 +1,9 @@
export default class JSONReporter {
constructor ({ stream } = {}) {
this.stream = stream || process.stdout
}
log (logObj) {
this.stream.write(JSON.stringify(logObj) + '\n')
}
}
+45
View File
@@ -0,0 +1,45 @@
// This reporter is compatible with Winston 3
// https://github.com/winstonjs/winston
// eslint-disable-next-line
const _require = typeof __non_webpack_require__ !== 'undefined' ? __non_webpack_require__ : require // bypass webpack
export default class WinstonReporter {
constructor (logger) {
if (logger && logger.log) {
this.logger = logger
} else {
const winston = _require('winston')
this.logger = winston.createLogger(Object.assign({
level: 'info',
format: winston.format.simple(),
transports: [
new winston.transports.Console()
]
}, logger))
}
}
log (logObj) {
const args = [].concat(logObj.args)
const arg0 = args.shift()
this.logger.log({
level: levels[logObj.level] || 'info',
label: logObj.tag,
message: arg0,
args: args,
timestamp: logObj.date.getTime() / 1000
})
}
}
const levels = {
0: 'error',
1: 'warn',
2: 'info',
3: 'verbose',
4: 'debug',
5: 'silly'
}
+50
View File
@@ -0,0 +1,50 @@
import { LogLevel } from './logLevels'
export default {
// Silent
silent: {
level: -1
},
// Level 0
fatal: {
level: LogLevel.Fatal
},
error: {
level: LogLevel.Error
},
// Level 1
warn: {
level: LogLevel.Warn
},
// Level 2
log: {
level: LogLevel.Log
},
// Level 3
info: {
level: LogLevel.Info
},
success: {
level: LogLevel.Success
},
// Level 4
debug: {
level: LogLevel.Debug
},
// Level 5
trace: {
level: LogLevel.Trace
},
// Verbose
verbose: {
level: LogLevel.Trace
},
// Legacy
ready: {
level: LogLevel.Info
},
start: {
level: LogLevel.Info
}
}
+37
View File
@@ -0,0 +1,37 @@
import chalk from 'chalk'
const _colorCache = {}
export function chalkColor (name) {
let color = _colorCache[name]
if (color) {
return color
}
if (name[0] === '#') {
color = chalk.hex(name)
} else {
color = chalk[name] || chalk.keyword(name)
}
_colorCache[name] = color
return color
}
const _bgColorCache = {}
export function chalkBgColor (name) {
let color = _bgColorCache[name]
if (color) {
return color
}
if (name[0] === '#') {
color = chalk.bgHex(name)
} else {
color = chalk['bg' + name[0].toUpperCase() + name.slice(1)] || chalk.bgKeyword(name)
}
_bgColorCache[name] = color
return color
}
+5
View File
@@ -0,0 +1,5 @@
import dayjs from 'dayjs'
export function formatDate (timeFormat, date) {
return dayjs(date).format(timeFormat)
}
+16
View File
@@ -0,0 +1,16 @@
import { sep } from 'path'
export function parseStack (stack) {
const cwd = process.cwd() + sep
const lines = stack
.split('\n')
.splice(1)
.map(l => l
.trim()
.replace('file://', '')
.replace(cwd, '')
)
return lines
}
+10
View File
@@ -0,0 +1,10 @@
export const TYPE_COLOR_MAP = {
info: 'cyan'
}
export const LEVEL_COLOR_MAP = {
0: 'red',
1: 'yellow',
2: 'white',
3: 'green'
}
+30
View File
@@ -0,0 +1,30 @@
import { vsprintf } from 'printj'
const FORMAT_ARGS = [
['additional', 5],
['message', 4],
['type', 2],
['date', 1],
['tag', 3]
] // .sort((a, b) => b[0].length - a[0].length)
const _compileCache = {}
// process.on('beforeExit', () => { console.log(_compileCache) })
export function compileFormat (format) {
if (_compileCache[format]) {
return _compileCache[format]
}
let _format = format
for (const arg of FORMAT_ARGS) {
_format = _format.replace(new RegExp('([%-])' + arg[0], 'g'), '$1' + arg[1])
}
_compileCache[format] = _format
return _format
}
export function formatString (format, argv) {
return vsprintf(compileFormat(format), argv)
}
+38
View File
@@ -0,0 +1,38 @@
export function assignGlobalReference (newInstance, referenceKey) {
if (!newInstance.constructor || (global[referenceKey] && !global[referenceKey].constructor)) {
throw new Error('Assigning to global reference is only supported for class instances')
} else if (newInstance.constructor && !global[referenceKey]) {
global[referenceKey] = newInstance
} else if (!(
newInstance instanceof global[referenceKey].constructor ||
global[referenceKey] instanceof newInstance.constructor
)) {
throw new Error(`Not a ${global[referenceKey].constructor.name} instance`)
}
const oldInstance = Object.create(global[referenceKey])
for (const prop in global[referenceKey]) {
oldInstance[prop] = global[referenceKey][prop]
delete global[referenceKey][prop]
}
for (const prop of Object.getOwnPropertySymbols(global[referenceKey])) {
oldInstance[prop] = global[referenceKey][prop]
delete global[referenceKey][prop]
}
for (const prop in newInstance) {
global[referenceKey][prop] = newInstance[prop]
}
for (const prop of Object.getOwnPropertySymbols(newInstance)) {
global[referenceKey][prop] = newInstance[prop]
}
return oldInstance
}
export function assignGlobalConsola (newConsola) {
return assignGlobalReference(newConsola, 'consola')
}
+23
View File
@@ -0,0 +1,23 @@
export function isPlainObject (obj) {
return Object.prototype.toString.call(obj) === '[object Object]'
}
// TODO: remove for consola@3
export function isLogObj (arg) {
// Should be plain object
if (!isPlainObject(arg)) {
return false
}
// Should contains either 'message' or 'args' field
if (!arg.message && !arg.args) {
return false
}
// Handle non-standard error objects
if (arg.stack) {
return false
}
return true
}
+20
View File
@@ -0,0 +1,20 @@
import { writeSync } from 'fs'
export function writeStream (data, stream, mode = 'default') {
const write = stream.__write || stream.write
switch (mode) {
case 'async':
return new Promise((resolve) => {
if (write.call(stream, data) === true) {
resolve()
} else {
stream.once('drain', () => { resolve() })
}
})
case 'sync':
return writeSync(stream.fd, data)
default:
return write.call(stream, data)
}
}
+41
View File
@@ -0,0 +1,41 @@
export function centerAlign (str, len, space = ' ') {
const free = len - str.length
if (free <= 0) {
return str
}
const freeLeft = Math.floor(free / 2)
let _str = ''
for (let i = 0; i < len; i++) {
_str += (i < freeLeft || i >= freeLeft + str.length) ? space : str[i - freeLeft]
}
return _str
}
export function rightAlign (str, len, space = ' ') {
const free = len - str.length
if (free <= 0) {
return str
}
let _str = ''
for (let i = 0; i < len; i++) {
_str += i < free ? space : str[i - free]
}
return _str
}
export function leftAlign (str, len, space = ' ') {
let _str = ''
for (let i = 0; i < len; i++) {
_str += i < str.length ? str[i] : space
}
return _str
}
export function align (alignment, str, len, space = ' ') {
switch (alignment) {
case 'left': return leftAlign(str, len, space)
case 'right': return rightAlign(str, len, space)
case 'center': return centerAlign(str, len, space)
default: return str
}
}
+182
View File
@@ -0,0 +1,182 @@
import { InspectOptions } from 'util';
export enum LogLevel {
Fatal= 0,
Error= 0,
Warn= 1,
Log= 2,
Info= 3,
Success= 3,
Debug= 4,
Trace= 5,
Silent= -Infinity,
Verbose= Infinity,
}
export type logType =
| 'silent'
| 'fatal'
| 'error'
| 'warn'
| 'log'
| 'info'
| 'success'
| 'debug'
| 'trace'
| 'verbose'
| 'ready'
| 'start'
export interface ConsolaLogObject {
level?: LogLevel,
tag?: string,
type?: logType,
message?: string,
additional?: string | string[],
args?: any[],
date?: Date,
}
export interface ConsolaReporterLogObject {
level: LogLevel,
type: logType,
tag: string;
args: any[],
date: Date,
}
type ConsolaMock = (...args: any) => void
type ConsolaMockFn = (type: logType, defaults: ConsolaLogObject) => ConsolaMock
export interface ConsolaReporterArgs {
async: boolean,
stdout: NodeJS.WritableStream,
stderr: NodeJS.WritableStream,
}
export interface ConsolaReporter {
log: (logObj: ConsolaReporterLogObject, args: ConsolaReporterArgs) => void
}
export interface ConsolaOptions {
reporters?: ConsolaReporter[],
types?: { [type in logType]: ConsolaLogObject },
level?: LogLevel,
defaults?: ConsolaLogObject,
async?: boolean,
stdout?: NodeJS.WritableStream,
stderr?: NodeJS.WritableStream,
mockFn?: ConsolaMockFn,
throttle?: number,
}
export declare class Consola {
constructor(options: ConsolaOptions)
level: LogLevel
readonly stdout: NodeJS.WritableStream
readonly stderr: NodeJS.WritableStream
// Built-in log levels
fatal(message: ConsolaLogObject | any, ...args: any[]): void
error(message: ConsolaLogObject | any, ...args: any[]): void
warn(message: ConsolaLogObject | any, ...args: any[]): void
log(message: ConsolaLogObject | any, ...args: any[]): void
info(message: ConsolaLogObject | any, ...args: any[]): void
start(message: ConsolaLogObject | any, ...args: any[]): void
success(message: ConsolaLogObject | any, ...args: any[]): void
ready(message: ConsolaLogObject | any, ...args: any[]): void
debug(message: ConsolaLogObject | any, ...args: any[]): void
trace(message: ConsolaLogObject | any, ...args: any[]): void
// Create
create(options: ConsolaOptions): Consola
withDefaults(defaults: ConsolaLogObject): Consola
withTag(tag: string): Consola
withScope(tag: string): Consola
// Reporter
addReporter(reporter: ConsolaReporter): Consola
setReporters(reporters: Array<ConsolaReporter>): Consola
removeReporter(reporter?: ConsolaReporter): Consola
remove(reporter?: ConsolaReporter): Consola
clear(reporter?: ConsolaReporter): Consola
// Wrappers
wrapAll(): void
restoreAll(): void
wrapConsole(): void
restoreConsole(): void
wrapStd(): void
restoreStd(): void
// Pause/Resume
pauseLogs(): void
pause(): void
resumeLogs(): void
resume(): void
// Mock
mockTypes(mockFn: ConsolaMockFn): any
mock(mockFn: ConsolaMockFn): any
}
export interface BasicReporterOptions {
dateFormat?: string;
formatOptions?: InspectOptions;
}
export declare class BasicReporter implements ConsolaReporter {
protected options: BasicReporterOptions;
constructor(options?: BasicReporterOptions);
public log(logObj: ConsolaReporterLogObject, args: ConsolaReporterArgs): void;
protected formatStack(stack: string): string;
protected formatArgs(args: any[]): string;
protected formatDate(date: Date): string;
protected filterAndJoin(arr: Array<string | undefined>): string;
protected formatLogObj(logObj: ConsolaReporterLogObject): string;
}
export interface FancyReporterOptions extends BasicReporterOptions{
secondaryColor?: string;
}
export declare class FancyReporter extends BasicReporter {
constructor(options?: FancyReporterOptions);
protected formatType(logObj: ConsolaReporterLogObject): void;
}
export type BrowserReporterOptions = {};
export declare class BrowserReporter implements ConsolaReporter {
public log(logObj: ConsolaReporterLogObject, args: ConsolaReporterArgs): void;
}
export type JSONReporterOptions = {
stream?: NodeJS.WritableStream;
};
export declare class JSONReporter implements ConsolaReporter {
constructor(options?: JSONReporterOptions);
public log(logObj: ConsolaReporterLogObject, args: ConsolaReporterArgs): void;
}
export type Winston = any;
export declare class WinstonReporter implements ConsolaReporter {
constructor(logger?: Winston);
public log(logObj: ConsolaReporterLogObject, args: ConsolaReporterArgs): void;
}
declare const consolaGlobalInstance: Consola;
export default consolaGlobalInstance