@teambit/logger 0.0.1140 → 0.0.1142

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.
@@ -1,4 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <testsuites tests="0" failures="0" errors="0" skipped="0">
3
- <testsuite name="teambit.harmony/logger@0.0.1140" tests="0" failures="0" errors="0" skipped="0"/>
3
+ <testsuite name="teambit.harmony/logger@0.0.1142" tests="0" failures="0" errors="0" skipped="0"/>
4
4
  </testsuites>
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.harmony/logger-preview"]=t():e["teambit.harmony/logger-preview"]=t()}(self,(()=>(()=>{"use strict";var e={5161:(e,t,n)=>{Object.defineProperty(t,"V",{enumerable:!0,get:function(){return o.default}});var o=r(n(9536));function r(e){return e&&e.__esModule?e:{default:e}}r.__bit_component={id:"teambit.harmony/aspect-docs/logger@0.0.168",homepage:"https://bit.cloud/teambit/harmony/aspect-docs/logger",exported:!0}},9536:(e,t,n)=>{var o={id:"teambit.harmony/aspect-docs/logger@0.0.168",homepage:"https://bit.cloud/teambit/harmony/aspect-docs/logger",exported:!0};Object.defineProperty(t,"__esModule",{value:!0}),t.default=c,s(n(1594));var r=n(5016),a=["components"];function s(e){return e&&e.__esModule?e:{default:e}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i.apply(null,arguments)}function l(e,t){if(null==e)return{};var n,o,r=m(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function m(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}s.__bit_component=o,i.__bit_component=o,l.__bit_component=o,m.__bit_component=o;var d={},p="wrapper";function c(e){var t=e.components,n=l(e,a);return(0,r.mdx)(p,i({},d,n,{components:t,mdxType:"MDXLayout"}),(0,r.mdx)("h2",null,"Create a logger"),(0,r.mdx)("p",null,"In your extension, add ",(0,r.mdx)("inlineCode",{parentName:"p"},"LoggerMain")," as a dependency and create a new logger by running"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre"},"LoggerMain.createLogger('your-extension-id');\n")),(0,r.mdx)("h2",null,"Log to a file"),(0,r.mdx)("p",null,"The following standard methods are available to log into a file. By default it's the ",(0,r.mdx)("inlineCode",{parentName:"p"},"debug.log")," file located at ",(0,r.mdx)("inlineCode",{parentName:"p"},"~/Library/Caches/Bit/logs")," for Mac/Linux or ",(0,r.mdx)("inlineCode",{parentName:"p"},"%LOCALAPPDATA%\\Bit")," for Windows."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"logger.trace(message: string, ...meta: any[]);\nlogger.debug(message: string, ...meta: any[]);\nlogger.info(message: string, ...meta: any[]);\nlogger.warn(message: string, ...meta: any[]);\nlogger.error(message: string, ...meta: any[]);\n")),(0,r.mdx)("p",null,"The message color is coded uniquely per extension-id. This way, it's easier to scroll the logs and distinguish between the extensions."),(0,r.mdx)("p",null,"The format of the message logged to the file is ",(0,r.mdx)("strong",{parentName:"p"},'"TIMESTAMP LEVEL: EXT-ID, MSG ',"[META]",'"'),'. The "',"[META]",'" part is ',(0,r.mdx)("inlineCode",{parentName:"p"},"JSON.stringify")," of the second parameter in case it's an object. Otherwise, it's ignored."),(0,r.mdx)("p",null,"JSON format is available as well. To use it, run ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit config set log_json_format true"),"."),(0,r.mdx)("p",null,"It's possible to have the console as an extra layer so these messages will be printed to the screen as well, see below."),(0,r.mdx)("h3",null,"Log stack trace"),(0,r.mdx)("p",null,"Normally, there is no need to log the Error object because it being caught by the end of the process and gets logged by Bit. Sometimes though it is needed to locally catch the error and continue, which can be useful to log the entire error object include the stack trace. In which case, pass the error object as the second parameter. e.g. ",(0,r.mdx)("inlineCode",{parentName:"p"},"catch(err) { logger.error('got an error during component-load', err); }")),(0,r.mdx)("h3",null,"Log also to the console"),(0,r.mdx)("p",null,"To see the same massages above printed into the screen, use the global flag ",(0,r.mdx)("inlineCode",{parentName:"p"},"--log [level]"),". For example, ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit status --log=error"),". If the level was not entered, it defaults to ",(0,r.mdx)("inlineCode",{parentName:"p"},"info"),"."),(0,r.mdx)("p",null,"Alternatively, you can set an environment variable ",(0,r.mdx)("inlineCode",{parentName:"p"},"BIT_LOG")," with the desired level."),(0,r.mdx)("p",null,"The format of the message logged to the console is ",(0,r.mdx)("strong",{parentName:"p"},'"MSG ',"[META]",'"'),' The "',"[META]",'" part is the same as above.'),(0,r.mdx)("h2",null,"Report progress"),(0,r.mdx)("p",null,"During the command execution it's helpful to see the progress on the screen. The following options log to the file and in addition, print to the screen. Use only these methods and avoid calling ",(0,r.mdx)("inlineCode",{parentName:"p"},"console.log")," to not break the output (or potentially the JSON structure)."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},'Please note that these methods print to the screen only when a command is not considered "internal" (such commands normally run on the remote server) and when a command is not used with ',(0,r.mdx)("inlineCode",{parentName:"p"},"--json")," flag. To specifically disable console-printing to a command, set the ",(0,r.mdx)("inlineCode",{parentName:"p"},"loader")," property to ",(0,r.mdx)("inlineCode",{parentName:"p"},"false"),".")),(0,r.mdx)("h3",null,"Status Line (spinner)"),(0,r.mdx)("p",null,"The status-line is a single line on the bottom of the screen, with a spinner/loader prefix. It's changing constantly during the command execution. This is the main indicator for the end-user of what's going on at the moment."),(0,r.mdx)("p",null,"To set the text of this status-line, call:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-js"},"logger.setStatusLine((text: string));\n")),(0,r.mdx)("p",null,"Once the command completed, the spinner is stopped and the status-line is cleared. Then, the command results are printed. If, for some reason, it is needed to clear the status-line before, just call ",(0,r.mdx)("inlineCode",{parentName:"p"},"logger.clearStatusLine()"),"."),(0,r.mdx)("h3",null,"Persist text"),(0,r.mdx)("p",null,"Sometimes it's helpful to indicate that a phase has completed. Either successfully or failed. The following methods help with this:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-js"},"// print to the screen with a green `✔` prefix. if message is empty, print the last logged message.\nlogger.consoleSuccess(message?: string);\n\n// print to the screen with a red `✖` prefix. if message is empty, print the last logged message.\nlogger.consoleFailure(message?: string);\n")),(0,r.mdx)("p",null,"To print without any prefix, use ",(0,r.mdx)("inlineCode",{parentName:"p"},"logger.console(message);")),(0,r.mdx)("h3",null,"Long Running Process Logger"),(0,r.mdx)("p",null,"Run the following to get an instance of the ",(0,r.mdx)("inlineCode",{parentName:"p"},"LongProcessLogger")," and start logging the process description."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-js"},"logger.createLongProcessLogger(processDescription: string, totalItems?: number): LongProcessLogger;\n")),(0,r.mdx)("p",null,"If the process involves iteration over a list of items, such as running tag on a list of components, then pass the ",(0,r.mdx)("inlineCode",{parentName:"p"},"totalItems")," as the total number of the components in the list."),(0,r.mdx)("p",null,"Later, during the iteration, call ",(0,r.mdx)("inlineCode",{parentName:"p"},"logProgress(componentName)")," on the ",(0,r.mdx)("inlineCode",{parentName:"p"},"LongProcessLogger")," instance.\nonce done, call ",(0,r.mdx)("inlineCode",{parentName:"p"},"end()"),", which logs the duration of the process in ms."),(0,r.mdx)("p",null,"Here is an example of the messages produced by this longProcessLogger. The status-line always shows the last message."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"teambit.workspace/workspace, loading components (total: 20)\nteambit.workspace/workspace, loading components (1/20). ui/button\nteambit.workspace/workspace, loading components (2/20). ui/form\n...\nteambit.workspace/workspace, loading components (20/20). ui/page\nteambit.workspace/workspace, loading components (completed in 200ms)\n")),(0,r.mdx)("p",null,"An example when there is no ",(0,r.mdx)("inlineCode",{parentName:"p"},"totalItems"),"."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"teambit.workspace/workspace, loading components\nteambit.workspace/workspace, loading components (completed in 200ms)\n")))}c.__bit_component=o,c.isMDXComponent=!0},9539:(e,t,n)=>{var o={id:"teambit.harmony/logger@0.0.1140",homepage:"https://bit.cloud/teambit/harmony/logger",exported:!0};function r(){const e=a(n(1594));return r=function(){return e},e}function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,r.__bit_component=o,a.__bit_component=o;const s=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/logger.svg"}));s.__bit_component=o,t.Logo=s},5016:e=>{e.exports=MdxJsReact},1594:e=>{e.exports=React}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{compositions:()=>u,compositions_metadata:()=>f,overview:()=>h});var r={};n.r(r),n.d(r,{default:()=>g});var a=n(9539),s=(n(1594),n(5016));const i=TeambitMdxUiMdxScopeContext;var l=n(5161),m=["components"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},d.apply(null,arguments)}var p={},c="wrapper";function g(e){var t=e.components,n=function(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(e,m);return(0,s.mdx)(c,d({},p,n,{components:t,mdxType:"MDXLayout"}),(0,s.mdx)(i.MDXScopeProvider,{components:{Logger:l.V},mdxType:"MDXScopeProvider"},(0,s.mdx)(l.V,{mdxType:"Logger"})))}g.isMDXComponent=!0;const u=[a],h=[r],f={compositions:[{displayName:"Logo",identifier:"Logo"}]};return o})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.harmony/logger-preview"]=t():e["teambit.harmony/logger-preview"]=t()}(self,(()=>(()=>{"use strict";var e={5161:(e,t,n)=>{Object.defineProperty(t,"V",{enumerable:!0,get:function(){return o.default}});var o=r(n(9536));function r(e){return e&&e.__esModule?e:{default:e}}r.__bit_component={id:"teambit.harmony/aspect-docs/logger@0.0.168",homepage:"https://bit.cloud/teambit/harmony/aspect-docs/logger",exported:!0}},9536:(e,t,n)=>{var o={id:"teambit.harmony/aspect-docs/logger@0.0.168",homepage:"https://bit.cloud/teambit/harmony/aspect-docs/logger",exported:!0};Object.defineProperty(t,"__esModule",{value:!0}),t.default=c,s(n(1594));var r=n(5016),a=["components"];function s(e){return e&&e.__esModule?e:{default:e}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},i.apply(null,arguments)}function l(e,t){if(null==e)return{};var n,o,r=m(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function m(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}s.__bit_component=o,i.__bit_component=o,l.__bit_component=o,m.__bit_component=o;var d={},p="wrapper";function c(e){var t=e.components,n=l(e,a);return(0,r.mdx)(p,i({},d,n,{components:t,mdxType:"MDXLayout"}),(0,r.mdx)("h2",null,"Create a logger"),(0,r.mdx)("p",null,"In your extension, add ",(0,r.mdx)("inlineCode",{parentName:"p"},"LoggerMain")," as a dependency and create a new logger by running"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre"},"LoggerMain.createLogger('your-extension-id');\n")),(0,r.mdx)("h2",null,"Log to a file"),(0,r.mdx)("p",null,"The following standard methods are available to log into a file. By default it's the ",(0,r.mdx)("inlineCode",{parentName:"p"},"debug.log")," file located at ",(0,r.mdx)("inlineCode",{parentName:"p"},"~/Library/Caches/Bit/logs")," for Mac/Linux or ",(0,r.mdx)("inlineCode",{parentName:"p"},"%LOCALAPPDATA%\\Bit")," for Windows."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-ts"},"logger.trace(message: string, ...meta: any[]);\nlogger.debug(message: string, ...meta: any[]);\nlogger.info(message: string, ...meta: any[]);\nlogger.warn(message: string, ...meta: any[]);\nlogger.error(message: string, ...meta: any[]);\n")),(0,r.mdx)("p",null,"The message color is coded uniquely per extension-id. This way, it's easier to scroll the logs and distinguish between the extensions."),(0,r.mdx)("p",null,"The format of the message logged to the file is ",(0,r.mdx)("strong",{parentName:"p"},'"TIMESTAMP LEVEL: EXT-ID, MSG ',"[META]",'"'),'. The "',"[META]",'" part is ',(0,r.mdx)("inlineCode",{parentName:"p"},"JSON.stringify")," of the second parameter in case it's an object. Otherwise, it's ignored."),(0,r.mdx)("p",null,"JSON format is available as well. To use it, run ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit config set log_json_format true"),"."),(0,r.mdx)("p",null,"It's possible to have the console as an extra layer so these messages will be printed to the screen as well, see below."),(0,r.mdx)("h3",null,"Log stack trace"),(0,r.mdx)("p",null,"Normally, there is no need to log the Error object because it being caught by the end of the process and gets logged by Bit. Sometimes though it is needed to locally catch the error and continue, which can be useful to log the entire error object include the stack trace. In which case, pass the error object as the second parameter. e.g. ",(0,r.mdx)("inlineCode",{parentName:"p"},"catch(err) { logger.error('got an error during component-load', err); }")),(0,r.mdx)("h3",null,"Log also to the console"),(0,r.mdx)("p",null,"To see the same massages above printed into the screen, use the global flag ",(0,r.mdx)("inlineCode",{parentName:"p"},"--log [level]"),". For example, ",(0,r.mdx)("inlineCode",{parentName:"p"},"bit status --log=error"),". If the level was not entered, it defaults to ",(0,r.mdx)("inlineCode",{parentName:"p"},"info"),"."),(0,r.mdx)("p",null,"Alternatively, you can set an environment variable ",(0,r.mdx)("inlineCode",{parentName:"p"},"BIT_LOG")," with the desired level."),(0,r.mdx)("p",null,"The format of the message logged to the console is ",(0,r.mdx)("strong",{parentName:"p"},'"MSG ',"[META]",'"'),' The "',"[META]",'" part is the same as above.'),(0,r.mdx)("h2",null,"Report progress"),(0,r.mdx)("p",null,"During the command execution it's helpful to see the progress on the screen. The following options log to the file and in addition, print to the screen. Use only these methods and avoid calling ",(0,r.mdx)("inlineCode",{parentName:"p"},"console.log")," to not break the output (or potentially the JSON structure)."),(0,r.mdx)("blockquote",null,(0,r.mdx)("p",{parentName:"blockquote"},'Please note that these methods print to the screen only when a command is not considered "internal" (such commands normally run on the remote server) and when a command is not used with ',(0,r.mdx)("inlineCode",{parentName:"p"},"--json")," flag. To specifically disable console-printing to a command, set the ",(0,r.mdx)("inlineCode",{parentName:"p"},"loader")," property to ",(0,r.mdx)("inlineCode",{parentName:"p"},"false"),".")),(0,r.mdx)("h3",null,"Status Line (spinner)"),(0,r.mdx)("p",null,"The status-line is a single line on the bottom of the screen, with a spinner/loader prefix. It's changing constantly during the command execution. This is the main indicator for the end-user of what's going on at the moment."),(0,r.mdx)("p",null,"To set the text of this status-line, call:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-js"},"logger.setStatusLine((text: string));\n")),(0,r.mdx)("p",null,"Once the command completed, the spinner is stopped and the status-line is cleared. Then, the command results are printed. If, for some reason, it is needed to clear the status-line before, just call ",(0,r.mdx)("inlineCode",{parentName:"p"},"logger.clearStatusLine()"),"."),(0,r.mdx)("h3",null,"Persist text"),(0,r.mdx)("p",null,"Sometimes it's helpful to indicate that a phase has completed. Either successfully or failed. The following methods help with this:"),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-js"},"// print to the screen with a green `✔` prefix. if message is empty, print the last logged message.\nlogger.consoleSuccess(message?: string);\n\n// print to the screen with a red `✖` prefix. if message is empty, print the last logged message.\nlogger.consoleFailure(message?: string);\n")),(0,r.mdx)("p",null,"To print without any prefix, use ",(0,r.mdx)("inlineCode",{parentName:"p"},"logger.console(message);")),(0,r.mdx)("h3",null,"Long Running Process Logger"),(0,r.mdx)("p",null,"Run the following to get an instance of the ",(0,r.mdx)("inlineCode",{parentName:"p"},"LongProcessLogger")," and start logging the process description."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-js"},"logger.createLongProcessLogger(processDescription: string, totalItems?: number): LongProcessLogger;\n")),(0,r.mdx)("p",null,"If the process involves iteration over a list of items, such as running tag on a list of components, then pass the ",(0,r.mdx)("inlineCode",{parentName:"p"},"totalItems")," as the total number of the components in the list."),(0,r.mdx)("p",null,"Later, during the iteration, call ",(0,r.mdx)("inlineCode",{parentName:"p"},"logProgress(componentName)")," on the ",(0,r.mdx)("inlineCode",{parentName:"p"},"LongProcessLogger")," instance.\nonce done, call ",(0,r.mdx)("inlineCode",{parentName:"p"},"end()"),", which logs the duration of the process in ms."),(0,r.mdx)("p",null,"Here is an example of the messages produced by this longProcessLogger. The status-line always shows the last message."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"teambit.workspace/workspace, loading components (total: 20)\nteambit.workspace/workspace, loading components (1/20). ui/button\nteambit.workspace/workspace, loading components (2/20). ui/form\n...\nteambit.workspace/workspace, loading components (20/20). ui/page\nteambit.workspace/workspace, loading components (completed in 200ms)\n")),(0,r.mdx)("p",null,"An example when there is no ",(0,r.mdx)("inlineCode",{parentName:"p"},"totalItems"),"."),(0,r.mdx)("pre",null,(0,r.mdx)("code",{parentName:"pre",className:"language-bash"},"teambit.workspace/workspace, loading components\nteambit.workspace/workspace, loading components (completed in 200ms)\n")))}c.__bit_component=o,c.isMDXComponent=!0},3273:(e,t,n)=>{var o={id:"teambit.harmony/logger@0.0.1142",homepage:"https://bit.cloud/teambit/harmony/logger",exported:!0};function r(){const e=a(n(1594));return r=function(){return e},e}function a(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,r.__bit_component=o,a.__bit_component=o;const s=()=>r().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},r().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/logger.svg"}));s.__bit_component=o,t.Logo=s},5016:e=>{e.exports=MdxJsReact},1594:e=>{e.exports=React}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var a=t[o]={exports:{}};return e[o](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.r(o),n.d(o,{compositions:()=>u,compositions_metadata:()=>f,overview:()=>h});var r={};n.r(r),n.d(r,{default:()=>g});var a=n(3273),s=(n(1594),n(5016));const i=TeambitMdxUiMdxScopeContext;var l=n(5161),m=["components"];function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},d.apply(null,arguments)}var p={},c="wrapper";function g(e){var t=e.components,n=function(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(t.includes(o))continue;n[o]=e[o]}return n}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(e,m);return(0,s.mdx)(c,d({},p,n,{components:t,mdxType:"MDXLayout"}),(0,s.mdx)(i.MDXScopeProvider,{components:{Logger:l.V},mdxType:"MDXScopeProvider"},(0,s.mdx)(l.V,{mdxType:"Logger"})))}g.isMDXComponent=!0;const u=[a],h=[r],f={compositions:[{displayName:"Logo",identifier:"Logo"}]};return o})()));
@@ -1440,7 +1440,7 @@
1440
1440
  "_legacy": {
1441
1441
  "scope": "teambit.harmony",
1442
1442
  "name": "logger",
1443
- "version": "0.0.1140"
1443
+ "version": "0.0.1142"
1444
1444
  },
1445
1445
  "_scope": "teambit.harmony"
1446
1446
  }
@@ -3350,7 +3350,7 @@
3350
3350
  "_legacy": {
3351
3351
  "scope": "teambit.harmony",
3352
3352
  "name": "logger",
3353
- "version": "0.0.1140"
3353
+ "version": "0.0.1142"
3354
3354
  },
3355
3355
  "_scope": "teambit.harmony"
3356
3356
  }
@@ -3744,7 +3744,7 @@
3744
3744
  "componentId": {
3745
3745
  "scope": "teambit.harmony",
3746
3746
  "name": "logger",
3747
- "version": "0.0.1140"
3747
+ "version": "0.0.1142"
3748
3748
  },
3749
3749
  "taggedModuleExports": []
3750
3750
  }
package/dist/logger.d.ts CHANGED
@@ -57,8 +57,8 @@ export declare class Logger implements IBitLogger {
57
57
  /**
58
58
  * turn off the logger.
59
59
  */
60
- off(): import("@teambit/legacy/dist/cli/loader/loader").Loader;
61
- on(): import("@teambit/legacy/dist/cli/loader/loader").Loader;
60
+ off(): import("@teambit/legacy.loader/loader").Loader;
61
+ on(): import("@teambit/legacy.loader/loader").Loader;
62
62
  profile(id: string, console?: boolean): void;
63
63
  /**
64
64
  * print to the screen with a red `✖` prefix. if message is empty, print the last logged message.
package/dist/logger.js CHANGED
@@ -11,9 +11,9 @@ function _dreidels() {
11
11
  };
12
12
  return data;
13
13
  }
14
- function _loader() {
15
- const data = _interopRequireDefault(require("@teambit/legacy/dist/cli/loader"));
16
- _loader = function () {
14
+ function _legacy() {
15
+ const data = require("@teambit/legacy.loader");
16
+ _legacy = function () {
17
17
  return data;
18
18
  };
19
19
  return data;
@@ -74,10 +74,10 @@ class Logger {
74
74
  _logger().default.fatal(this.colorMessage(message), ...meta);
75
75
  }
76
76
  get isLoaderStarted() {
77
- return _loader().default.isStarted;
77
+ return _legacy().loader.isStarted;
78
78
  }
79
79
  get isSpinning() {
80
- return _loader().default.isSpinning;
80
+ return _legacy().loader.isSpinning;
81
81
  }
82
82
  get multiSpinner() {
83
83
  if (!this.spinnies) this.spinnies = new (_dreidels().default)();
@@ -101,24 +101,24 @@ class Logger {
101
101
  */
102
102
  setStatusLine(text, shouldPrintOnCI = false) {
103
103
  if (process.env.CI && !shouldPrintOnCI) return;
104
- _loader().default.setTextAndRestart(text);
104
+ _legacy().loader.setTextAndRestart(text);
105
105
  }
106
106
  /**
107
107
  * remove the text from the last line on the screen.
108
108
  */
109
109
  clearStatusLine() {
110
- _loader().default.stop();
110
+ _legacy().loader.stop();
111
111
  }
112
112
  /**
113
113
  * print to the screen. if message is empty, print the last logged message.
114
114
  */
115
115
  console(message, ...meta) {
116
116
  if (message) this.info(message, meta);
117
- if (!_loader().default.isStarted && _logger().default.shouldWriteToConsole) {
117
+ if (!_legacy().loader.isStarted && _logger().default.shouldWriteToConsole) {
118
118
  // eslint-disable-next-line no-console
119
119
  console.log(message, ...meta);
120
120
  } else {
121
- _loader().default.stopAndPersist({
121
+ _legacy().loader.stopAndPersist({
122
122
  text: message
123
123
  });
124
124
  }
@@ -130,11 +130,11 @@ class Logger {
130
130
  */
131
131
  consoleWarn(message, ...meta) {
132
132
  if (message) this.warn(message, ...meta);
133
- if (!_loader().default.isStarted && _logger().default.shouldWriteToConsole) {
133
+ if (!_legacy().loader.isStarted && _logger().default.shouldWriteToConsole) {
134
134
  // eslint-disable-next-line no-console
135
135
  console.warn(message, ...meta);
136
136
  } else {
137
- _loader().default.stopAndPersist({
137
+ _legacy().loader.stopAndPersist({
138
138
  text: message
139
139
  });
140
140
  }
@@ -146,11 +146,11 @@ class Logger {
146
146
  */
147
147
  consoleError(message, ...meta) {
148
148
  if (message) this.error(message, ...meta);
149
- if (!_loader().default.isStarted && _logger().default.shouldWriteToConsole) {
149
+ if (!_legacy().loader.isStarted && _logger().default.shouldWriteToConsole) {
150
150
  // eslint-disable-next-line no-console
151
151
  console.error(message, ...meta);
152
152
  } else {
153
- _loader().default.stopAndPersist({
153
+ _legacy().loader.stopAndPersist({
154
154
  text: message
155
155
  });
156
156
  }
@@ -161,7 +161,7 @@ class Logger {
161
161
  */
162
162
  consoleTitle(message) {
163
163
  this.info(message);
164
- _loader().default.stopAndPersist({
164
+ _legacy().loader.stopAndPersist({
165
165
  text: _chalk().default.bold(message)
166
166
  });
167
167
  }
@@ -170,17 +170,17 @@ class Logger {
170
170
  */
171
171
  consoleSuccess(message, startTime) {
172
172
  if (message) this.info(message);
173
- _loader().default.succeed(message, startTime);
173
+ _legacy().loader.succeed(message, startTime);
174
174
  }
175
175
 
176
176
  /**
177
177
  * turn off the logger.
178
178
  */
179
179
  off() {
180
- return _loader().default.off();
180
+ return _legacy().loader.off();
181
181
  }
182
182
  on() {
183
- return _loader().default.on();
183
+ return _legacy().loader.on();
184
184
  }
185
185
  profile(id, console) {
186
186
  _logger().default.profile(id, console);
@@ -191,7 +191,7 @@ class Logger {
191
191
  */
192
192
  consoleFailure(message) {
193
193
  if (message) this.error(message);
194
- _loader().default.fail(message);
194
+ _legacy().loader.fail(message);
195
195
  }
196
196
  /**
197
197
  * print to the screen with a red `⚠` prefix. if message is empty, print the last logged message.
@@ -201,7 +201,7 @@ class Logger {
201
201
  this.warn(message);
202
202
  message = _chalk().default.yellow(message);
203
203
  }
204
- _loader().default.warn(message);
204
+ _legacy().loader.warn(message);
205
205
  }
206
206
  colorMessage(message) {
207
207
  if (_logger().default.isJsonFormat) return `${this.extensionName}, ${message}`;
@@ -1 +1 @@
1
- {"version":3,"names":["_dreidels","data","_interopRequireDefault","require","_loader","_logger","_chalk","_os","_longProcessLogger","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Logger","constructor","extensionName","trace","message","meta","logger","colorMessage","debug","info","warn","error","fatal","isLoaderStarted","loader","isStarted","isSpinning","multiSpinner","spinnies","Spinnies","createLongProcessLogger","processDescription","totalItems","shouldConsole","LongProcessLogger","setStatusLine","text","shouldPrintOnCI","process","env","CI","setTextAndRestart","clearStatusLine","stop","console","shouldWriteToConsole","log","stopAndPersist","consoleWarn","consoleError","consoleTitle","chalk","bold","consoleSuccess","startTime","succeed","off","on","profile","id","consoleFailure","fail","consoleWarning","yellow","isJsonFormat","successSymbol","platform","green","exports"],"sources":["logger.ts"],"sourcesContent":["import Spinnies from 'dreidels';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport logger, { IBitLogger } from '@teambit/legacy/dist/logger/logger';\nimport chalk from 'chalk';\nimport { platform } from 'os';\nimport { ConsoleOnStart, LongProcessLogger } from './long-process-logger';\n\nexport class Logger implements IBitLogger {\n private spinnies?: Spinnies;\n constructor(private extensionName: string) {}\n\n trace(message: string, ...meta: any[]) {\n logger.trace(this.colorMessage(message), ...meta);\n }\n debug(message: string, ...meta: any[]) {\n logger.debug(this.colorMessage(message), ...meta);\n }\n info(message: string, ...meta: any[]) {\n logger.info(this.colorMessage(message), ...meta);\n }\n warn(message: string, ...meta: any[]) {\n logger.warn(this.colorMessage(message), ...meta);\n }\n error(message: string, ...meta: any[]) {\n logger.error(this.colorMessage(message), ...meta);\n }\n fatal(message: string, ...meta: any[]) {\n logger.fatal(this.colorMessage(message), ...meta);\n }\n\n get isLoaderStarted() {\n return loader.isStarted;\n }\n\n get isSpinning() {\n return loader.isSpinning;\n }\n\n get multiSpinner(): Spinnies {\n if (!this.spinnies) this.spinnies = new Spinnies();\n return this.spinnies;\n }\n\n /**\n * use it for a long running process. upon creation it logs the `processDescription`.\n * if the process involves iteration over a list of items, such as running tag on a list of\n * components, then pass the `totalItems` as the total of the total components in the list.\n * later, during the iteration, call `LongProcessLogger.logProgress(componentName)`.\n * once done, call `LongProcessLogger.end()`\n * the status-line will show all messages in the terminal.\n */\n createLongProcessLogger(\n processDescription: string,\n totalItems?: number,\n shouldConsole?: ConsoleOnStart\n ): LongProcessLogger {\n return new LongProcessLogger(this, this.extensionName, processDescription, totalItems, shouldConsole);\n }\n /**\n * single status-line on the bottom of the screen.\n * the text is replaced every time this method is called.\n */\n setStatusLine(text: string, shouldPrintOnCI = false) {\n if (process.env.CI && !shouldPrintOnCI) return;\n loader.setTextAndRestart(text);\n }\n /**\n * remove the text from the last line on the screen.\n */\n clearStatusLine() {\n loader.stop();\n }\n /**\n * print to the screen. if message is empty, print the last logged message.\n */\n console(message?: string, ...meta: any[]) {\n if (message) this.info(message, meta);\n if (!loader.isStarted && logger.shouldWriteToConsole) {\n // eslint-disable-next-line no-console\n console.log(message, ...meta);\n } else {\n loader.stopAndPersist({ text: message });\n }\n }\n\n /**\n * @deprecated\n * try using consoleWarning. if not possible, rename this method to a clearer one\n */\n consoleWarn(message?: string, ...meta: any[]) {\n if (message) this.warn(message, ...meta);\n if (!loader.isStarted && logger.shouldWriteToConsole) {\n // eslint-disable-next-line no-console\n console.warn(message, ...meta);\n } else {\n loader.stopAndPersist({ text: message });\n }\n }\n\n /**\n * @deprecated\n * try using consoleFailure. if not possible, rename this method to a clearer one\n */\n consoleError(message?: string, ...meta: any[]) {\n if (message) this.error(message, ...meta);\n if (!loader.isStarted && logger.shouldWriteToConsole) {\n // eslint-disable-next-line no-console\n console.error(message, ...meta);\n } else {\n loader.stopAndPersist({ text: message });\n }\n }\n\n /**\n * print to the screen as a title, with bold text.\n */\n consoleTitle(message: string) {\n this.info(message);\n loader.stopAndPersist({ text: chalk.bold(message) });\n }\n /**\n * print to the screen with a green `✔` prefix. if message is empty, print the last logged message.\n */\n consoleSuccess(message?: string, startTime?: [number, number]) {\n if (message) this.info(message);\n loader.succeed(message, startTime);\n }\n\n /**\n * turn off the logger.\n */\n off() {\n return loader.off();\n }\n\n on() {\n return loader.on();\n }\n\n profile(id: string, console?: boolean) {\n logger.profile(id, console);\n }\n\n /**\n * print to the screen with a red `✖` prefix. if message is empty, print the last logged message.\n */\n consoleFailure(message?: string) {\n if (message) this.error(message);\n loader.fail(message);\n }\n /**\n * print to the screen with a red `⚠` prefix. if message is empty, print the last logged message.\n */\n consoleWarning(message?: string) {\n if (message) {\n this.warn(message);\n message = chalk.yellow(message);\n }\n loader.warn(message);\n }\n\n private colorMessage(message: string) {\n if (logger.isJsonFormat) return `${this.extensionName}, ${message}`;\n return `${chalk.bold(this.extensionName)}, ${message}`;\n }\n\n /**\n * a recent change on Windows caused the check mark to be printed as purple.\n * see https://github.com/chalk/chalk/issues/625\n */\n static successSymbol() {\n return platform() === 'win32' ? chalk.green('✓') : chalk.green('✔');\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;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C,EAAEA,CAAA,EAAG;IACH,OAAOjC,iBAAM,CAACiC,EAAE,CAAC,CAAC;EACpB;EAEAC,OAAOA,CAACC,EAAU,EAAEf,OAAiB,EAAE;IACrC5B,iBAAM,CAAC0C,OAAO,CAACC,EAAE,EAAEf,OAAO,CAAC;EAC7B;;EAEA;AACF;AACA;EACEgB,cAAcA,CAAC9C,OAAgB,EAAE;IAC/B,IAAIA,OAAO,EAAE,IAAI,CAACO,KAAK,CAACP,OAAO,CAAC;IAChCU,iBAAM,CAACqC,IAAI,CAAC/C,OAAO,CAAC;EACtB;EACA;AACF;AACA;EACEgD,cAAcA,CAAChD,OAAgB,EAAE;IAC/B,IAAIA,OAAO,EAAE;MACX,IAAI,CAACM,IAAI,CAACN,OAAO,CAAC;MAClBA,OAAO,GAAGqC,gBAAK,CAACY,MAAM,CAACjD,OAAO,CAAC;IACjC;IACAU,iBAAM,CAACJ,IAAI,CAACN,OAAO,CAAC;EACtB;EAEQG,YAAYA,CAACH,OAAe,EAAE;IACpC,IAAIE,iBAAM,CAACgD,YAAY,EAAE,OAAO,GAAG,IAAI,CAACpD,aAAa,KAAKE,OAAO,EAAE;IACnE,OAAO,GAAGqC,gBAAK,CAACC,IAAI,CAAC,IAAI,CAACxC,aAAa,CAAC,KAAKE,OAAO,EAAE;EACxD;;EAEA;AACF;AACA;AACA;EACE,OAAOmD,aAAaA,CAAA,EAAG;IACrB,OAAO,IAAAC,cAAQ,EAAC,CAAC,KAAK,OAAO,GAAGf,gBAAK,CAACgB,KAAK,CAAC,GAAG,CAAC,GAAGhB,gBAAK,CAACgB,KAAK,CAAC,GAAG,CAAC;EACrE;AACF;AAACC,OAAA,CAAA1D,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["_dreidels","data","_interopRequireDefault","require","_legacy","_logger","_chalk","_os","_longProcessLogger","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Logger","constructor","extensionName","trace","message","meta","logger","colorMessage","debug","info","warn","error","fatal","isLoaderStarted","loader","isStarted","isSpinning","multiSpinner","spinnies","Spinnies","createLongProcessLogger","processDescription","totalItems","shouldConsole","LongProcessLogger","setStatusLine","text","shouldPrintOnCI","process","env","CI","setTextAndRestart","clearStatusLine","stop","console","shouldWriteToConsole","log","stopAndPersist","consoleWarn","consoleError","consoleTitle","chalk","bold","consoleSuccess","startTime","succeed","off","on","profile","id","consoleFailure","fail","consoleWarning","yellow","isJsonFormat","successSymbol","platform","green","exports"],"sources":["logger.ts"],"sourcesContent":["import Spinnies from 'dreidels';\nimport { loader } from '@teambit/legacy.loader';\nimport logger, { IBitLogger } from '@teambit/legacy/dist/logger/logger';\nimport chalk from 'chalk';\nimport { platform } from 'os';\nimport { ConsoleOnStart, LongProcessLogger } from './long-process-logger';\n\nexport class Logger implements IBitLogger {\n private spinnies?: Spinnies;\n constructor(private extensionName: string) {}\n\n trace(message: string, ...meta: any[]) {\n logger.trace(this.colorMessage(message), ...meta);\n }\n debug(message: string, ...meta: any[]) {\n logger.debug(this.colorMessage(message), ...meta);\n }\n info(message: string, ...meta: any[]) {\n logger.info(this.colorMessage(message), ...meta);\n }\n warn(message: string, ...meta: any[]) {\n logger.warn(this.colorMessage(message), ...meta);\n }\n error(message: string, ...meta: any[]) {\n logger.error(this.colorMessage(message), ...meta);\n }\n fatal(message: string, ...meta: any[]) {\n logger.fatal(this.colorMessage(message), ...meta);\n }\n\n get isLoaderStarted() {\n return loader.isStarted;\n }\n\n get isSpinning() {\n return loader.isSpinning;\n }\n\n get multiSpinner(): Spinnies {\n if (!this.spinnies) this.spinnies = new Spinnies();\n return this.spinnies;\n }\n\n /**\n * use it for a long running process. upon creation it logs the `processDescription`.\n * if the process involves iteration over a list of items, such as running tag on a list of\n * components, then pass the `totalItems` as the total of the total components in the list.\n * later, during the iteration, call `LongProcessLogger.logProgress(componentName)`.\n * once done, call `LongProcessLogger.end()`\n * the status-line will show all messages in the terminal.\n */\n createLongProcessLogger(\n processDescription: string,\n totalItems?: number,\n shouldConsole?: ConsoleOnStart\n ): LongProcessLogger {\n return new LongProcessLogger(this, this.extensionName, processDescription, totalItems, shouldConsole);\n }\n /**\n * single status-line on the bottom of the screen.\n * the text is replaced every time this method is called.\n */\n setStatusLine(text: string, shouldPrintOnCI = false) {\n if (process.env.CI && !shouldPrintOnCI) return;\n loader.setTextAndRestart(text);\n }\n /**\n * remove the text from the last line on the screen.\n */\n clearStatusLine() {\n loader.stop();\n }\n /**\n * print to the screen. if message is empty, print the last logged message.\n */\n console(message?: string, ...meta: any[]) {\n if (message) this.info(message, meta);\n if (!loader.isStarted && logger.shouldWriteToConsole) {\n // eslint-disable-next-line no-console\n console.log(message, ...meta);\n } else {\n loader.stopAndPersist({ text: message });\n }\n }\n\n /**\n * @deprecated\n * try using consoleWarning. if not possible, rename this method to a clearer one\n */\n consoleWarn(message?: string, ...meta: any[]) {\n if (message) this.warn(message, ...meta);\n if (!loader.isStarted && logger.shouldWriteToConsole) {\n // eslint-disable-next-line no-console\n console.warn(message, ...meta);\n } else {\n loader.stopAndPersist({ text: message });\n }\n }\n\n /**\n * @deprecated\n * try using consoleFailure. if not possible, rename this method to a clearer one\n */\n consoleError(message?: string, ...meta: any[]) {\n if (message) this.error(message, ...meta);\n if (!loader.isStarted && logger.shouldWriteToConsole) {\n // eslint-disable-next-line no-console\n console.error(message, ...meta);\n } else {\n loader.stopAndPersist({ text: message });\n }\n }\n\n /**\n * print to the screen as a title, with bold text.\n */\n consoleTitle(message: string) {\n this.info(message);\n loader.stopAndPersist({ text: chalk.bold(message) });\n }\n /**\n * print to the screen with a green `✔` prefix. if message is empty, print the last logged message.\n */\n consoleSuccess(message?: string, startTime?: [number, number]) {\n if (message) this.info(message);\n loader.succeed(message, startTime);\n }\n\n /**\n * turn off the logger.\n */\n off() {\n return loader.off();\n }\n\n on() {\n return loader.on();\n }\n\n profile(id: string, console?: boolean) {\n logger.profile(id, console);\n }\n\n /**\n * print to the screen with a red `✖` prefix. if message is empty, print the last logged message.\n */\n consoleFailure(message?: string) {\n if (message) this.error(message);\n loader.fail(message);\n }\n /**\n * print to the screen with a red `⚠` prefix. if message is empty, print the last logged message.\n */\n consoleWarning(message?: string) {\n if (message) {\n this.warn(message);\n message = chalk.yellow(message);\n }\n loader.warn(message);\n }\n\n private colorMessage(message: string) {\n if (logger.isJsonFormat) return `${this.extensionName}, ${message}`;\n return `${chalk.bold(this.extensionName)}, ${message}`;\n }\n\n /**\n * a recent change on Windows caused the check mark to be printed as purple.\n * see https://github.com/chalk/chalk/issues/625\n */\n static successSymbol() {\n return platform() === 'win32' ? chalk.green('✓') : chalk.green('✔');\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,IAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,GAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,mBAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,kBAAA,YAAAA,CAAA;IAA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,OAAO,CAAC;IACjC;IACAU,gBAAM,CAACJ,IAAI,CAACN,OAAO,CAAC;EACtB;EAEQG,YAAYA,CAACH,OAAe,EAAE;IACpC,IAAIE,iBAAM,CAACgD,YAAY,EAAE,OAAO,GAAG,IAAI,CAACpD,aAAa,KAAKE,OAAO,EAAE;IACnE,OAAO,GAAGqC,gBAAK,CAACC,IAAI,CAAC,IAAI,CAACxC,aAAa,CAAC,KAAKE,OAAO,EAAE;EACxD;;EAEA;AACF;AACA;AACA;EACE,OAAOmD,aAAaA,CAAA,EAAG;IACrB,OAAO,IAAAC,cAAQ,EAAC,CAAC,KAAK,OAAO,GAAGf,gBAAK,CAACgB,KAAK,CAAC,GAAG,CAAC,GAAGhB,gBAAK,CAACgB,KAAK,CAAC,GAAG,CAAC;EACrE;AACF;AAACC,OAAA,CAAA1D,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_logger@0.0.1140/dist/logger.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_logger@0.0.1140/dist/logger.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_logger@0.0.1142/dist/logger.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_logger@0.0.1142/dist/logger.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@teambit/logger",
3
- "version": "0.0.1140",
3
+ "version": "0.0.1142",
4
4
  "homepage": "https://bit.cloud/teambit/harmony/logger",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.harmony",
8
8
  "name": "logger",
9
- "version": "0.0.1140"
9
+ "version": "0.0.1142"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
13
13
  "dreidels": "0.6.1",
14
14
  "pretty-time": "1.1.0",
15
15
  "@teambit/harmony": "0.4.6",
16
- "@teambit/cli": "0.0.1047"
16
+ "@teambit/cli": "0.0.1049",
17
+ "@teambit/legacy.loader": "0.0.1"
17
18
  },
18
19
  "devDependencies": {
19
20
  "@types/mocha": "9.1.0",