@mxweb/core 1.0.1 → 1.0.2
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/CHANGELOG.md +10 -0
- package/dist/logger.js +1 -1
- package/dist/logger.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.2] - 2024-12-18
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Build**: Improved terser configuration for logger module
|
|
13
|
+
- Added custom `terserWithOptions()` plugin for file-specific minification
|
|
14
|
+
- Logger module now keeps console calls while still being minified
|
|
15
|
+
- Other modules continue to have console calls removed during minification
|
|
16
|
+
- Added `loggerMinifyOptions` with `drop_console: false` for logger
|
|
17
|
+
|
|
8
18
|
## [1.0.1] - 2024-12-16
|
|
9
19
|
|
|
10
20
|
### Changed
|
package/dist/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("@mxweb/utils");const o={warn:"[33m",log:"[36m",error:"[31m",info:"[32m",debug:"[34m",reset:"[0m"};class
|
|
1
|
+
"use strict";var t=require("@mxweb/utils");const o={warn:"[33m",log:"[36m",error:"[31m",info:"[32m",debug:"[34m",reset:"[0m"};class e{constructor(o="@mxweb"){this.prefix=o,this.allowLog="production"!==t.getEnv("NODE_ENV")&&"false"!==t.getEnv("DEBUG")}static get instance(){return e._instance||(e._instance=new e),e._instance}static create(t){return new e(t)}isAllowLog(){return this.allowLog}formatPrefix(t){return`${o[t]}[${this.prefix}]${o.reset}`}output(t,o,e,...i){if(!this.isAllowLog())return;const s=this.formatPrefix(t);console[o](`${s} ${e}`,...i)}warn(t,...o){this.output("warn","warn",t,...o)}log(t,...o){this.output("log","log",t,...o)}error(t,...o){this.output("error","error",t,...o)}info(t,...o){this.output("info","info",t,...o)}debug(t,...o){this.output("debug","debug",t,...o)}http(t,e,i,s,r){const n=`${t} ${e} ${i>=500?o.error:i>=400?o.warn:i>=300?o.log:o.info}${i}${o.reset} - ${s} bytes in ${r}ms`;this.output("info","info",n)}timestamp(t,o,...e){if(!this.isAllowLog())return;const i=(new Date).toISOString(),s=this.formatPrefix(t);console["log"===t?"log":t](`${s} [${i}] ${o}`,...e)}json(t,o,e){if(!this.isAllowLog())return;const i=this.formatPrefix(t);console["log"===t?"log":t](`${i} ${o}:`,JSON.stringify(e,null,2))}separator(t="-",o=50){this.isAllowLog()&&console.log(t.repeat(o))}group(t,o){if(!this.isAllowLog())return;const e=this.formatPrefix("info");console.group(`${e} ${t}`),o(),console.groupEnd()}table(t,o){this.isAllowLog()&&console.table(t,o)}time(t){this.isAllowLog()&&console.time(`[${this.prefix}] ${t}`)}timeEnd(t){this.isAllowLog()&&console.timeEnd(`[${this.prefix}] ${t}`)}}const i=e.instance;exports.Logger=e,exports.logger=i;
|
package/dist/logger.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getEnv as
|
|
1
|
+
import{getEnv as o}from"@mxweb/utils";const t={warn:"[33m",log:"[36m",error:"[31m",info:"[32m",debug:"[34m",reset:"[0m"};class i{constructor(t="@mxweb"){this.prefix=t,this.allowLog="production"!==o("NODE_ENV")&&"false"!==o("DEBUG")}static get instance(){return i._instance||(i._instance=new i),i._instance}static create(o){return new i(o)}isAllowLog(){return this.allowLog}formatPrefix(o){return`${t[o]}[${this.prefix}]${t.reset}`}output(o,t,i,...s){if(!this.isAllowLog())return;const e=this.formatPrefix(o);console[t](`${e} ${i}`,...s)}warn(o,...t){this.output("warn","warn",o,...t)}log(o,...t){this.output("log","log",o,...t)}error(o,...t){this.output("error","error",o,...t)}info(o,...t){this.output("info","info",o,...t)}debug(o,...t){this.output("debug","debug",o,...t)}http(o,i,s,e,r){const n=`${o} ${i} ${s>=500?t.error:s>=400?t.warn:s>=300?t.log:t.info}${s}${t.reset} - ${e} bytes in ${r}ms`;this.output("info","info",n)}timestamp(o,t,...i){if(!this.isAllowLog())return;const s=(new Date).toISOString(),e=this.formatPrefix(o);console["log"===o?"log":o](`${e} [${s}] ${t}`,...i)}json(o,t,i){if(!this.isAllowLog())return;const s=this.formatPrefix(o);console["log"===o?"log":o](`${s} ${t}:`,JSON.stringify(i,null,2))}separator(o="-",t=50){this.isAllowLog()&&console.log(o.repeat(t))}group(o,t){if(!this.isAllowLog())return;const i=this.formatPrefix("info");console.group(`${i} ${o}`),t(),console.groupEnd()}table(o,t){this.isAllowLog()&&console.table(o,t)}time(o){this.isAllowLog()&&console.time(`[${this.prefix}] ${o}`)}timeEnd(o){this.isAllowLog()&&console.timeEnd(`[${this.prefix}] ${o}`)}}const s=i.instance;export{i as Logger,s as logger};
|
package/package.json
CHANGED