@ribbon-studios/logger 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2023 Rainbow Café
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ ### @ribbon-studios/logger
2
+
3
+ [![NPM Version][npm-version-image]][npm-url]
4
+ [![NPM Downloads][npm-downloads-image]][npm-url]
5
+ [![Coveralls][coveralls-image]][coveralls-url]
6
+
7
+ [![CI Build][github-actions-image]][github-actions-url]
8
+ [![Maintainability][maintainability-image]][maintainability-url]
9
+ [![Semantic Release][semantic-release-image]][semantic-release-url]
10
+ [![Code Style: Prettier][code-style-image]][code-style-url]
11
+
12
+ A simple logger for all Rainbow Cafe Apps & Libraries
13
+
14
+ ### Usage
15
+
16
+ ```ts
17
+ import { Logger, LogLevel } from '@ribbon-studios/logger';
18
+
19
+ Logger.setLevel(LogLevel.INFO); // This is the default LogLevel
20
+
21
+ Logger.silly('hello', 'world!'); // Outputs nothing since its lower then the configured level!
22
+ Logger.info('hello', 'world!'); // '[info]: hello world!'
23
+ Logger.warn('hello', 'world!'); // '[warn]: hello world!'
24
+ Logger.error('hello', 'world!'); // '[error]: hello world!'
25
+ ```
26
+
27
+ [npm-version-image]: https://img.shields.io/npm/v/@ribbon-studios/logger.svg
28
+ [npm-downloads-image]: https://img.shields.io/npm/dm/@ribbon-studios/logger.svg
29
+ [npm-url]: https://npmjs.org/package/@ribbon-studios/logger
30
+ [github-actions-image]: https://img.shields.io/github/actions/workflow/status/ribbon-studios/logger/ci.yml?event=push
31
+ [github-actions-url]: https://github.com/ribbon-studios/logger/actions/workflows/ci.yml?query=branch%3Amain
32
+ [coveralls-image]: https://img.shields.io/coveralls/ribbon-studios/logger.svg
33
+ [coveralls-url]: https://coveralls.io/github/ribbon-studios/logger?branch=main
34
+ [code-style-image]: https://img.shields.io/badge/code%20style-prettier-ff69b4.svg
35
+ [code-style-url]: https://prettier.io
36
+ [maintainability-image]: https://img.shields.io/codeclimate/maintainability/ribbon-studios/refreshly
37
+ [maintainability-url]: https://codeclimate.com/github/ribbon-studios/refreshly/maintainability
38
+ [semantic-release-url]: https://github.com/semantic-release/semantic-release
39
+ [semantic-release-image]: https://img.shields.io/badge/%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079
@@ -0,0 +1 @@
1
+ export * from './logger';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t,o,n=/*#__PURE__*/e(require("chalk")),r=0;function l(e){return"__private_"+r+++"_"+e}function c(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}exports.LogLevel=void 0,(o=exports.LogLevel||(exports.LogLevel={}))[o.ERROR=0]="ERROR",o[o.WARN=1]="WARN",o[o.INFO=2]="INFO",o[o.SILLY=3]="SILLY";var a=Object.keys(exports.LogLevel).reduce(function(e,t){return Math.max(e,t.length)},0)+3,L=((t={})[exports.LogLevel.ERROR]=n.default.red,t[exports.LogLevel.WARN]=n.default.yellow,t[exports.LogLevel.INFO]=n.default.cyan,t[exports.LogLevel.SILLY]=n.default.magenta,t),i=/*#__PURE__*/l("level"),p=/*#__PURE__*/function(){function e(){}return e.isLevel=function(t){return c(e,i)[i]>=t},e.isNotLevel=function(t){return!e.isLevel(t)},e.setLevel=function(t){c(e,i)[i]=t},e.log=function(t){var o;if(!e.isNotLevel(t)){var n=L[t],r=function(e){return e.map(function(e){return e instanceof Error||"object"!=typeof e?e:(t=e,o=new Set,JSON.stringify(t,function(e,t){if("object"==typeof t&&null!==t){if(o.has(t))return;o.add(t)}return t},4));var t,o})}([].slice.call(arguments,1)).map(function(e){return e instanceof Error?e:n(e)});(o=console).log.apply(o,[n("["+exports.LogLevel[t].toLowerCase()+"]:").padEnd(a," ")].concat(r))}},e.error=function(){e.log.apply(e,[exports.LogLevel.ERROR].concat([].slice.call(arguments)))},e.warn=function(){e.log.apply(e,[exports.LogLevel.WARN].concat([].slice.call(arguments)))},e.info=function(){e.log.apply(e,[exports.LogLevel.INFO].concat([].slice.call(arguments)))},e.silly=function(){e.log.apply(e,[exports.LogLevel.SILLY].concat([].slice.call(arguments)))},e}();Object.defineProperty(p,i,{writable:!0,value:exports.LogLevel.INFO}),exports.LEVEL_CHALK=L,exports.Logger=p,exports.MAX_LENGTH=a;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","_LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","_console","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","slice","call","arguments","console","apply","toLowerCase","padEnd","concat","error","warn","info","silly","writable"],"mappings":"8EAGYA,iOAAAA,QAAZA,cAAA,GAAYA,EAAAA,QAAAA,WAAAA,QAAAA,SAKX,CAAA,IAJCA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,MAAA,GAAA,QAGW,IAAAC,EACXC,OAAOC,KAAKH,QAAQA,UAAEI,OAAO,SAACC,EAAQC,GACpC,OAAOC,KAAKC,IAAIH,EAAQC,EAAMG,OAChC,EAAG,GAAK,EAEGC,IAAWC,EAAAA,CAAAA,GAGrBX,QAAAA,SAASY,OAAQC,EAAK,QAACC,IAAGH,EAC1BX,QAAQA,SAACe,MAAOF,EAAK,QAACG,OAAML,EAC5BX,QAAQA,SAACiB,MAAOJ,EAAAA,QAAMK,KAAIP,EAC1BX,QAAAA,SAASmB,OAAQN,EAAK,QAACO,QAAOT,GAC/BU,eAAAC,EAAA,SAKWC,eAAM,WAAA,SAAAA,IAAAA,CAmFhB,OAnFgBA,EAeHC,QAAP,SAAeC,GACpB,OAAOC,EAAAH,EAAMF,GAAAA,IAAWI,CAC1B,EAACF,EAOaI,WAAP,SAAkBF,GACvB,OAAQF,EAAOC,QAAQC,EACzB,EAACF,EAMaK,SAAP,SAAgBH,GACrBC,EAAAH,EAAMF,GAAAA,GAAUI,CAClB,EAACF,EAOaM,IAAP,SAAWJ,GAAsC,IAAAK,EACtD,IAAIP,EAAOI,WAAWF,GAAtB,CAEA,IAAMZ,EAAQH,EAAYe,GAEpBM,ECvEM,SAAiBA,GAC/B,OAAOA,EAASC,IAAI,SAACC,GACnB,OAAIA,aAAmBC,OAA4B,iBAAZD,EAC9BA,GCLaE,EDQLF,ECPbG,EAAQ,IAAIC,IAEXC,KAAKC,UACVJ,EACA,SAACK,EAAKlC,GACJ,GAAqB,iBAAVA,GAAgC,OAAVA,EAAgB,CAC/C,GAAI8B,EAAMK,IAAInC,GAEZ,OAGF8B,EAAMM,IAAIpC,EACZ,CACA,OAAOA,CACT,EACA,IAhBY,IAAU6B,EAClBC,CDQN,EACF,CD+DqBO,CAAgB,GAAAC,MAAAC,KAAAC,UAAA,IAAcd,IAAI,SAACC,GAAO,OACzDA,aAAmBC,MAAQD,EAAUpB,EAAMoB,EAAQ,IAGrDH,EAAAiB,SAAQlB,IAAGmB,MAAAlB,EAAA,CAACjB,EAAK,IAAKb,QAAQA,SAACyB,GAAOwB,cAAa,MAAMC,OAAOjD,EAAY,MAAIkD,OAAKpB,GANrF,CAOF,EAACR,EAMa6B,MAAP,WACL7B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,QAAAA,SAASY,OAAKuC,UAAAP,MAAAC,KAAAC,YAC3B,EAACvB,EAMa8B,KAAP,WACL9B,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,QAAQA,SAACe,MAAIoC,OAAAP,GAAAA,MAAAC,KAAAC,YAC1B,EAACvB,EAMa+B,KAAP,WACL/B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,QAAQA,SAACiB,MAAIkC,OAAA,GAAAP,MAAAC,KAAAC,YAC1B,EAACvB,EAMagC,MAAP,WACLhC,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,QAAAA,SAASmB,OAAKgC,OAAAP,GAAAA,MAAAC,KAAAC,YAC3B,EAACvB,CAAA,CAnFgB,yBAANA,EAAMF,EAAA,CAAAmC,UAAA,EAAAlD,MACSN,QAAAA,SAASiB"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import n from"chalk";var e,t,o=0;function r(n){return"__private_"+o+++"_"+n}function c(n,e){if(!Object.prototype.hasOwnProperty.call(n,e))throw new TypeError("attempted to use private field on non-instance");return n}!function(n){n[n.ERROR=0]="ERROR",n[n.WARN=1]="WARN",n[n.INFO=2]="INFO",n[n.SILLY=3]="SILLY"}(t||(t={}));var l=Object.keys(t).reduce(function(n,e){return Math.max(n,e.length)},0)+3,i=((e={})[t.ERROR]=n.red,e[t.WARN]=n.yellow,e[t.INFO]=n.cyan,e[t.SILLY]=n.magenta,e),a=/*#__PURE__*/r("level"),u=/*#__PURE__*/function(){function n(){}return n.isLevel=function(e){return c(n,a)[a]>=e},n.isNotLevel=function(e){return!n.isLevel(e)},n.setLevel=function(e){c(n,a)[a]=e},n.log=function(e){var o;if(!n.isNotLevel(e)){var r=i[e],c=function(n){return n.map(function(n){return n instanceof Error||"object"!=typeof n?n:(e=n,t=new Set,JSON.stringify(e,function(n,e){if("object"==typeof e&&null!==e){if(t.has(e))return;t.add(e)}return e},4));var e,t})}([].slice.call(arguments,1)).map(function(n){return n instanceof Error?n:r(n)});(o=console).log.apply(o,[r("["+t[e].toLowerCase()+"]:").padEnd(l," ")].concat(c))}},n.error=function(){n.log.apply(n,[t.ERROR].concat([].slice.call(arguments)))},n.warn=function(){n.log.apply(n,[t.WARN].concat([].slice.call(arguments)))},n.info=function(){n.log.apply(n,[t.INFO].concat([].slice.call(arguments)))},n.silly=function(){n.log.apply(n,[t.SILLY].concat([].slice.call(arguments)))},n}();Object.defineProperty(u,a,{writable:!0,value:t.INFO});export{i as LEVEL_CHALK,t as LogLevel,u as Logger,l as MAX_LENGTH};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","_LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","_console","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","slice","call","arguments","console","apply","toLowerCase","padEnd","concat","error","warn","info","silly","writable"],"mappings":"2BAGYA,+LAAZ,SAAYA,GACVA,EAAAA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,MAAA,GAAA,OACD,CALD,CAAYA,IAAAA,EAKX,CAAA,IAEY,IAAAC,EACXC,OAAOC,KAAKH,GAAUI,OAAO,SAACC,EAAQC,GACpC,OAAOC,KAAKC,IAAIH,EAAQC,EAAMG,OAChC,EAAG,GAAK,EAEGC,IAAWC,EAAAA,CAAAA,GAGrBX,EAASY,OAAQC,EAAMC,IAAGH,EAC1BX,EAASe,MAAOF,EAAMG,OAAML,EAC5BX,EAASiB,MAAOJ,EAAMK,KAAIP,EAC1BX,EAASmB,OAAQN,EAAMO,QAAOT,GAC/BU,eAAAC,EAAA,SAKWC,eAAM,WAAA,SAAAA,IAAA,CAmFhB,OAnFgBA,EAeHC,QAAP,SAAeC,GACpB,OAAOC,EAAAH,EAAMF,GAAAA,IAAWI,CAC1B,EAACF,EAOaI,WAAP,SAAkBF,GACvB,OAAQF,EAAOC,QAAQC,EACzB,EAACF,EAMaK,SAAP,SAAgBH,GACrBC,EAAAH,EAAMF,GAAAA,GAAUI,CAClB,EAACF,EAOaM,IAAP,SAAWJ,GAAsC,IAAAK,EACtD,IAAIP,EAAOI,WAAWF,GAAtB,CAEA,IAAMZ,EAAQH,EAAYe,GAEpBM,ECvEM,SAAiBA,GAC/B,OAAOA,EAASC,IAAI,SAACC,GACnB,OAAIA,aAAmBC,OAA4B,iBAAZD,EAC9BA,GCLaE,EDQLF,ECPbG,EAAQ,IAAIC,IAEXC,KAAKC,UACVJ,EACA,SAACK,EAAKlC,GACJ,GAAqB,iBAAVA,GAAgC,OAAVA,EAAgB,CAC/C,GAAI8B,EAAMK,IAAInC,GAEZ,OAGF8B,EAAMM,IAAIpC,EACZ,CACA,OAAOA,CACT,EACA,IAhBY,IAAU6B,EAClBC,CDQN,EACF,CD+DqBO,CAAgB,GAAAC,MAAAC,KAAAC,UAAA,IAAcd,IAAI,SAACC,GAAO,OACzDA,aAAmBC,MAAQD,EAAUpB,EAAMoB,EAAQ,IAGrDH,EAAAiB,SAAQlB,IAAGmB,MAAAlB,EAAA,CAACjB,EAAK,IAAKb,EAASyB,GAAOwB,cAAa,MAAMC,OAAOjD,EAAY,MAAIkD,OAAKpB,GANrF,CAOF,EAACR,EAMa6B,MAAP,WACL7B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,EAASY,OAAKuC,UAAAP,MAAAC,KAAAC,YAC3B,EAACvB,EAMa8B,KAAP,WACL9B,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,EAASe,MAAIoC,OAAAP,GAAAA,MAAAC,KAAAC,YAC1B,EAACvB,EAMa+B,KAAP,WACL/B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,EAASiB,MAAIkC,OAAA,GAAAP,MAAAC,KAAAC,YAC1B,EAACvB,EAMagC,MAAP,WACLhC,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,EAASmB,OAAKgC,OAAAP,GAAAA,MAAAC,KAAAC,YAC3B,EAACvB,CAAA,CAnFgB,yBAANA,EAAMF,EAAA,CAAAmC,UAAA,EAAAlD,MACSN,EAASiB"}
@@ -0,0 +1,2 @@
1
+ import t from"chalk";var e,r=0;function n(t){return"__private_"+r+++"_"+t}function o(t,e){if(!Object.prototype.hasOwnProperty.call(t,e))throw new TypeError("attempted to use private field on non-instance");return t}!function(t){t[t.ERROR=0]="ERROR",t[t.WARN=1]="WARN",t[t.INFO=2]="INFO",t[t.SILLY=3]="SILLY"}(e||(e={}));const a=Object.keys(e).reduce((t,e)=>Math.max(t,e.length),0)+3,i={[e.ERROR]:t.red,[e.WARN]:t.yellow,[e.INFO]:t.cyan,[e.SILLY]:t.magenta};var c=/*#__PURE__*/n("level");class s{static isLevel(t){return o(s,c)[c]>=t}static isNotLevel(t){return!s.isLevel(t)}static setLevel(t){o(s,c)[c]=t}static log(t,...r){if(s.isNotLevel(t))return;const n=i[t],o=function(t){return t.map(t=>t instanceof Error||"object"!=typeof t?t:function(t){const e=new Set;return JSON.stringify(t,(t,r)=>{if("object"==typeof r&&null!==r){if(e.has(r))return;e.add(r)}return r},4)}(t))}(r).map(t=>t instanceof Error?t:n(t));console.log(n(`[${e[t].toLowerCase()}]:`).padEnd(a," "),...o)}static error(...t){s.log(e.ERROR,...t)}static warn(...t){s.log(e.WARN,...t)}static info(...t){s.log(e.INFO,...t)}static silly(...t){s.log(e.SILLY,...t)}}Object.defineProperty(s,c,{writable:!0,value:e.INFO});export{i as LEVEL_CHALK,e as LogLevel,s as Logger,a as MAX_LENGTH};
2
+ //# sourceMappingURL=index.modern.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.modern.mjs","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","rawMessages","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","console","toLowerCase","padEnd","error","warn","info","silly","writable"],"mappings":"yBAGYA,+LAAZ,SAAYA,GACVA,EAAAA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,MAAA,GAAA,OACD,CALD,CAAYA,IAAAA,EAKX,CAAA,IAEY,MAAAC,EACXC,OAAOC,KAAKH,GAAUI,OAAO,CAACC,EAAQC,IAC7BC,KAAKC,IAAIH,EAAQC,EAAMG,QAC7B,GAAK,EAEGC,EAET,CACF,CAACV,EAASW,OAAQC,EAAMC,IACxB,CAACb,EAASc,MAAOF,EAAMG,OACvB,CAACf,EAASgB,MAAOJ,EAAMK,KACvB,CAACjB,EAASkB,OAAQN,EAAMO,SACxB,IAAAC,eAAAC,iBAKWC,EAeJ,cAAOC,CAAQC,GACpB,OAAOC,EAAAH,EAAMF,GAAAA,IAAWI,CAC1B,CAOO,iBAAOE,CAAWF,GACvB,OAAQF,EAAOC,QAAQC,EACzB,CAMO,eAAOG,CAASH,GACrBC,EAAAH,EAAMF,GAAAA,GAAUI,CAClB,CAOO,UAAOI,CAAIJ,KAAoBK,GACpC,GAAIP,EAAOI,WAAWF,GAAQ,OAE9B,MAAMZ,EAAQF,EAAYc,GAEpBM,ECvEM,SAAiBA,GAC/B,OAAOA,EAASC,IAAKC,GACfA,aAAmBC,OAA4B,iBAAZD,EAC9BA,ECLG,SAAUE,GACxB,MAAMC,EAAQ,IAAIC,IAElB,OAAOC,KAAKC,UACVJ,EACA,CAACK,EAAKjC,KACJ,GAAqB,iBAAVA,GAAgC,OAAVA,EAAgB,CAC/C,GAAI6B,EAAMK,IAAIlC,GAEZ,OAGF6B,EAAMM,IAAInC,EACZ,CACA,OAAOA,GAET,EAEJ,CDVWgC,CAAUN,GAErB,CD+DqBU,CAAiBb,GAAaE,IAAKC,GAClDA,aAAmBC,MAAQD,EAAUpB,EAAMoB,IAG7CW,QAAQf,IAAIhB,EAAU,IAAAZ,EAASwB,GAAOoB,mBAAmBC,OAAO5C,EAAY,QAAS6B,EACvF,CAMO,YAAOgB,IAAShB,GACrBR,EAAOM,IAAI5B,EAASW,SAAUmB,EAChC,CAMO,WAAOiB,IAAQjB,GACpBR,EAAOM,IAAI5B,EAASc,QAASgB,EAC/B,CAMO,WAAOkB,IAAQlB,GACpBR,EAAOM,IAAI5B,EAASgB,QAASc,EAC/B,CAMO,YAAOmB,IAASnB,GACrBR,EAAOM,IAAI5B,EAASkB,SAAUY,EAChC,wBAnFWR,EAAMF,EAAA8B,CAAAA,YAAA5C,MACSN,EAASgB"}
@@ -0,0 +1,2 @@
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("chalk")):"function"==typeof define&&define.amd?define(["exports","chalk"],n):n((e||self).logger={},e.chalk)}(this,function(e,n){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t,l,r=/*#__PURE__*/o(n),c=0;function i(e){return"__private_"+c+++"_"+e}function a(e,n){if(!Object.prototype.hasOwnProperty.call(e,n))throw new TypeError("attempted to use private field on non-instance");return e}e.LogLevel=void 0,(l=e.LogLevel||(e.LogLevel={}))[l.ERROR=0]="ERROR",l[l.WARN=1]="WARN",l[l.INFO=2]="INFO",l[l.SILLY=3]="SILLY";var f=Object.keys(e.LogLevel).reduce(function(e,n){return Math.max(e,n.length)},0)+3,u=((t={})[e.LogLevel.ERROR]=r.default.red,t[e.LogLevel.WARN]=r.default.yellow,t[e.LogLevel.INFO]=r.default.cyan,t[e.LogLevel.SILLY]=r.default.magenta,t),L=/*#__PURE__*/i("level"),p=/*#__PURE__*/function(){function n(){}return n.isLevel=function(e){return a(n,L)[L]>=e},n.isNotLevel=function(e){return!n.isLevel(e)},n.setLevel=function(e){a(n,L)[L]=e},n.log=function(o){var t;if(!n.isNotLevel(o)){var l=u[o],r=function(e){return e.map(function(e){return e instanceof Error||"object"!=typeof e?e:(n=e,o=new Set,JSON.stringify(n,function(e,n){if("object"==typeof n&&null!==n){if(o.has(n))return;o.add(n)}return n},4));var n,o})}([].slice.call(arguments,1)).map(function(e){return e instanceof Error?e:l(e)});(t=console).log.apply(t,[l("["+e.LogLevel[o].toLowerCase()+"]:").padEnd(f," ")].concat(r))}},n.error=function(){n.log.apply(n,[e.LogLevel.ERROR].concat([].slice.call(arguments)))},n.warn=function(){n.log.apply(n,[e.LogLevel.WARN].concat([].slice.call(arguments)))},n.info=function(){n.log.apply(n,[e.LogLevel.INFO].concat([].slice.call(arguments)))},n.silly=function(){n.log.apply(n,[e.LogLevel.SILLY].concat([].slice.call(arguments)))},n}();Object.defineProperty(p,L,{writable:!0,value:e.LogLevel.INFO}),e.LEVEL_CHALK=u,e.Logger=p,e.MAX_LENGTH=f});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/logger.ts","../src/utils/messages.ts","../src/utils/stringify.ts"],"sourcesContent":["import chalk, { ChalkInstance } from 'chalk';\nimport { sanitizeMessages } from './utils/messages';\n\nexport enum LogLevel {\n ERROR,\n WARN,\n INFO,\n SILLY,\n}\n\nexport const MAX_LENGTH =\n Object.keys(LogLevel).reduce((output, value) => {\n return Math.max(output, value.length);\n }, 0) + 3;\n\nexport const LEVEL_CHALK: {\n [key in LogLevel]: ChalkInstance;\n} = {\n [LogLevel.ERROR]: chalk.red,\n [LogLevel.WARN]: chalk.yellow,\n [LogLevel.INFO]: chalk.cyan,\n [LogLevel.SILLY]: chalk.magenta,\n};\n\n/**\n * A simple wrapper around 'console.log'\n */\nexport class Logger {\n static #level: LogLevel = LogLevel.INFO;\n\n /**\n * Returns whether the logger is configured to allow the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is equal to or higher priority then the configured level\n *\n * @example\n * Logger.setLevel(LogLevel.INFO);\n * // Returns true\n * Logger.isLevel(LogLevel.ERROR);\n * // Also returns true\n * Logger.isLevel(LogLevel.INFO);\n */\n public static isLevel(level?: LogLevel): boolean {\n return Logger.#level >= level;\n }\n\n /**\n * Returns whether the logger is configured to deny the given log level to output.\n * @param level the level to validate\n * @returns true if the given level is lower priority then the configured level\n */\n public static isNotLevel(level?: LogLevel): boolean {\n return !Logger.isLevel(level);\n }\n\n /**\n * Sets the level to allow to output\n * @param level the level to set\n */\n public static setLevel(level: LogLevel) {\n Logger.#level = level;\n }\n\n /**\n * A wrapper around console.log with color formatting and filtering by the set LogLevel.\n * @param level the LogLevel of this message\n * @param rawMessages the messages to send\n */\n public static log(level: LogLevel, ...rawMessages: any[]): void {\n if (Logger.isNotLevel(level)) return;\n\n const chalk = LEVEL_CHALK[level];\n\n const messages = sanitizeMessages(rawMessages).map((message) =>\n message instanceof Error ? message : chalk(message)\n );\n\n console.log(chalk(`[${LogLevel[level].toLowerCase()}]:`).padEnd(MAX_LENGTH, ' '), ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}\n * @param messages the messages to send\n */\n public static error(...messages: any[]) {\n Logger.log(LogLevel.ERROR, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}\n * @param messages the messages to send\n */\n public static warn(...messages: any[]) {\n Logger.log(LogLevel.WARN, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}\n * @param messages the messages to send\n */\n public static info(...messages: any[]) {\n Logger.log(LogLevel.INFO, ...messages);\n }\n\n /**\n * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}\n * @param messages the messages to send\n */\n public static silly(...messages: any[]) {\n Logger.log(LogLevel.SILLY, ...messages);\n }\n}\n","import { stringify } from './stringify';\n\nexport function sanitizeMessages(messages: any[]): any[] {\n return messages.map((message) => {\n if (message instanceof Error || typeof message !== 'object') {\n return message;\n }\n\n return stringify(message);\n });\n}\n","export function stringify(obj: any) {\n const cache = new Set();\n\n return JSON.stringify(\n obj,\n (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (cache.has(value)) {\n // Circular reference found, discard key\n return;\n }\n // Store value in our collection\n cache.add(value);\n }\n return value;\n },\n 4\n );\n}\n"],"names":["LogLevel","MAX_LENGTH","Object","keys","reduce","output","value","Math","max","length","LEVEL_CHALK","_LEVEL_CHALK","ERROR","chalk","red","WARN","yellow","INFO","cyan","SILLY","magenta","_level","_classPrivateFieldLooseKey","Logger","isLevel","level","_classPrivateFieldLooseBase","isNotLevel","setLevel","log","_console","messages","map","message","Error","obj","cache","Set","JSON","stringify","key","has","add","sanitizeMessages","slice","call","arguments","console","apply","toLowerCase","padEnd","concat","error","warn","info","silly","writable"],"mappings":"iVAGYA,kNAAAA,EAAZA,cAAA,GAAYA,EAAAA,EAAAA,WAAAA,EAAAA,SAKX,CAAA,IAJCA,EAAA,MAAA,GAAA,QACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,KAAA,GAAA,OACAA,EAAAA,EAAA,MAAA,GAAA,QAGW,IAAAC,EACXC,OAAOC,KAAKH,EAAQA,UAAEI,OAAO,SAACC,EAAQC,GACpC,OAAOC,KAAKC,IAAIH,EAAQC,EAAMG,OAChC,EAAG,GAAK,EAEGC,IAAWC,EAAAA,CAAAA,GAGrBX,EAAAA,SAASY,OAAQC,EAAK,QAACC,IAAGH,EAC1BX,EAAQA,SAACe,MAAOF,EAAK,QAACG,OAAML,EAC5BX,EAAQA,SAACiB,MAAOJ,EAAAA,QAAMK,KAAIP,EAC1BX,EAAAA,SAASmB,OAAQN,EAAK,QAACO,QAAOT,GAC/BU,eAAAC,EAAA,SAKWC,eAAM,WAAA,SAAAA,IAAAA,CAmFhB,OAnFgBA,EAeHC,QAAP,SAAeC,GACpB,OAAOC,EAAAH,EAAMF,GAAAA,IAAWI,CAC1B,EAACF,EAOaI,WAAP,SAAkBF,GACvB,OAAQF,EAAOC,QAAQC,EACzB,EAACF,EAMaK,SAAP,SAAgBH,GACrBC,EAAAH,EAAMF,GAAAA,GAAUI,CAClB,EAACF,EAOaM,IAAP,SAAWJ,GAAsC,IAAAK,EACtD,IAAIP,EAAOI,WAAWF,GAAtB,CAEA,IAAMZ,EAAQH,EAAYe,GAEpBM,ECvEM,SAAiBA,GAC/B,OAAOA,EAASC,IAAI,SAACC,GACnB,OAAIA,aAAmBC,OAA4B,iBAAZD,EAC9BA,GCLaE,EDQLF,ECPbG,EAAQ,IAAIC,IAEXC,KAAKC,UACVJ,EACA,SAACK,EAAKlC,GACJ,GAAqB,iBAAVA,GAAgC,OAAVA,EAAgB,CAC/C,GAAI8B,EAAMK,IAAInC,GAEZ,OAGF8B,EAAMM,IAAIpC,EACZ,CACA,OAAOA,CACT,EACA,IAhBY,IAAU6B,EAClBC,CDQN,EACF,CD+DqBO,CAAgB,GAAAC,MAAAC,KAAAC,UAAA,IAAcd,IAAI,SAACC,GAAO,OACzDA,aAAmBC,MAAQD,EAAUpB,EAAMoB,EAAQ,IAGrDH,EAAAiB,SAAQlB,IAAGmB,MAAAlB,EAAA,CAACjB,EAAK,IAAKb,EAAQA,SAACyB,GAAOwB,cAAa,MAAMC,OAAOjD,EAAY,MAAIkD,OAAKpB,GANrF,CAOF,EAACR,EAMa6B,MAAP,WACL7B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,EAAAA,SAASY,OAAKuC,UAAAP,MAAAC,KAAAC,YAC3B,EAACvB,EAMa8B,KAAP,WACL9B,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,EAAQA,SAACe,MAAIoC,OAAAP,GAAAA,MAAAC,KAAAC,YAC1B,EAACvB,EAMa+B,KAAP,WACL/B,EAAOM,IAAGmB,MAAVzB,EAAWvB,CAAAA,EAAQA,SAACiB,MAAIkC,OAAA,GAAAP,MAAAC,KAAAC,YAC1B,EAACvB,EAMagC,MAAP,WACLhC,EAAOM,IAAGmB,MAAVzB,EAAM,CAAKvB,EAAAA,SAASmB,OAAKgC,OAAAP,GAAAA,MAAAC,KAAAC,YAC3B,EAACvB,CAAA,CAnFgB,yBAANA,EAAMF,EAAA,CAAAmC,UAAA,EAAAlD,MACSN,EAAAA,SAASiB"}
@@ -0,0 +1,67 @@
1
+ import { ChalkInstance } from 'chalk';
2
+ export declare enum LogLevel {
3
+ ERROR = 0,
4
+ WARN = 1,
5
+ INFO = 2,
6
+ SILLY = 3
7
+ }
8
+ export declare const MAX_LENGTH: number;
9
+ export declare const LEVEL_CHALK: {
10
+ [key in LogLevel]: ChalkInstance;
11
+ };
12
+ /**
13
+ * A simple wrapper around 'console.log'
14
+ */
15
+ export declare class Logger {
16
+ #private;
17
+ /**
18
+ * Returns whether the logger is configured to allow the given log level to output.
19
+ * @param level the level to validate
20
+ * @returns true if the given level is equal to or higher priority then the configured level
21
+ *
22
+ * @example
23
+ * Logger.setLevel(LogLevel.INFO);
24
+ * // Returns true
25
+ * Logger.isLevel(LogLevel.ERROR);
26
+ * // Also returns true
27
+ * Logger.isLevel(LogLevel.INFO);
28
+ */
29
+ static isLevel(level?: LogLevel): boolean;
30
+ /**
31
+ * Returns whether the logger is configured to deny the given log level to output.
32
+ * @param level the level to validate
33
+ * @returns true if the given level is lower priority then the configured level
34
+ */
35
+ static isNotLevel(level?: LogLevel): boolean;
36
+ /**
37
+ * Sets the level to allow to output
38
+ * @param level the level to set
39
+ */
40
+ static setLevel(level: LogLevel): void;
41
+ /**
42
+ * A wrapper around console.log with color formatting and filtering by the set LogLevel.
43
+ * @param level the LogLevel of this message
44
+ * @param rawMessages the messages to send
45
+ */
46
+ static log(level: LogLevel, ...rawMessages: any[]): void;
47
+ /**
48
+ * A helper that automatically calls {@link Logger.log} with {@link LogLevel.ERROR}
49
+ * @param messages the messages to send
50
+ */
51
+ static error(...messages: any[]): void;
52
+ /**
53
+ * A helper that automatically calls {@link Logger.log} with {@link LogLevel.WARN}
54
+ * @param messages the messages to send
55
+ */
56
+ static warn(...messages: any[]): void;
57
+ /**
58
+ * A helper that automatically calls {@link Logger.log} with {@link LogLevel.INFO}
59
+ * @param messages the messages to send
60
+ */
61
+ static info(...messages: any[]): void;
62
+ /**
63
+ * A helper that automatically calls {@link Logger.log} with {@link LogLevel.SILLY}
64
+ * @param messages the messages to send
65
+ */
66
+ static silly(...messages: any[]): void;
67
+ }
@@ -0,0 +1 @@
1
+ export declare function sanitizeMessages(messages: any[]): any[];
@@ -0,0 +1 @@
1
+ export declare function stringify(obj: any): string;
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@ribbon-studios/logger",
3
+ "version": "2.0.1",
4
+ "source": "src/index.ts",
5
+ "main": "dist/index.js",
6
+ "umd:main": "dist/index.umd.js",
7
+ "module": "dist/index.mjs",
8
+ "exports": {
9
+ "types": "./dist/index.d.ts",
10
+ "require": "./dist/index.js",
11
+ "default": "./dist/index.modern.mjs"
12
+ },
13
+ "types": "dist/index.d.ts",
14
+ "scripts": {
15
+ "lint": "eslint 'src/**/*.ts'",
16
+ "build": "microbundle"
17
+ },
18
+ "dependencies": {
19
+ "chalk": "^5"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^18",
23
+ "@typescript-eslint/eslint-plugin": "^6.1.0",
24
+ "@typescript-eslint/parser": "^6.1.0",
25
+ "chance": "^1.1.11",
26
+ "dedent": "^1.5.1",
27
+ "eslint": "^8.45.0",
28
+ "microbundle": "^0.15.1",
29
+ "string-dedent": "^3.0.1",
30
+ "typescript": "^5.1.6"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/ribbon-studios/logger.git"
38
+ },
39
+ "license": "MIT"
40
+ }