@wiajs/log 4.3.12 → 4.3.13
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/log.cjs +1 -1
- package/dist/log.js +20 -6
- package/dist/log.min.js +2 -2
- package/dist/log.mjs +1 -1
- package/lib/browser.js +14 -1
- package/package.json +1 -1
package/dist/log.cjs
CHANGED
package/dist/log.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
/*!
|
2
|
-
* wia log v4.3.
|
2
|
+
* wia log v4.3.13
|
3
3
|
* (c) 2024-2024 Sibyl Yu and contributors
|
4
4
|
* Released under the MIT License.
|
5
5
|
*/
|
6
6
|
(function (global, factory) {
|
7
|
-
typeof exports === 'object' && typeof module !== 'undefined' ?
|
8
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
9
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Log =
|
10
|
-
})(this, (function () { 'use strict';
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Log = {}));
|
10
|
+
})(this, (function (exports) { 'use strict';
|
11
11
|
|
12
12
|
/**
|
13
13
|
* 前端日志输出,封装 console日志,简化代码,支持模块或直接输出
|
@@ -171,7 +171,21 @@
|
|
171
171
|
const desc = getDesc(args);
|
172
172
|
desc ? console.trace(desc, ...args) : console.trace(...args);
|
173
173
|
};
|
174
|
+
/**
|
175
|
+
* 获取模块文件名称
|
176
|
+
* esm: import.meta.url or cjs: __filename
|
177
|
+
* @param {string} file
|
178
|
+
* @returns
|
179
|
+
*/ function name(file) {
|
180
|
+
// import.meta.url: 'file:///D:/prj/wiajs/req/test/log.t.js'
|
181
|
+
// file = fileURLToPath(file) // fileUrl 转成路径
|
182
|
+
// const baseName = path.basename(file)
|
183
|
+
// return baseName.replace(path.extname(baseName), '')
|
184
|
+
return '';
|
185
|
+
}
|
186
|
+
// export { log, Log };
|
174
187
|
|
175
|
-
|
188
|
+
exports.log = log;
|
189
|
+
exports.name = name;
|
176
190
|
|
177
191
|
}));
|
package/dist/log.min.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
|
-
* wia log v4.3.
|
2
|
+
* wia log v4.3.13
|
3
3
|
* (c) 2024-2024 Sibyl Yu and contributors
|
4
4
|
* Released under the MIT License.
|
5
5
|
*/
|
6
|
-
var o,e;o=this,e=function(){"use strict";let
|
6
|
+
var o,e;o=this,e=function(o){"use strict";let e=class{constructor(o){this.m="",this.fn="",this.m=o}getDesc(o){let e="";try{const n=this,{m:s}=n;let t="",c="";if(o.length>1){const e=o.at(-1);"object"==typeof e?({desc:c,fn:t}=e):"string"==typeof e&&(c=e),(c||t)&&(t=t||n.fn,n.fn=t,o.pop())}t=t||n.fn,s&&(c=`${c}[${s}${t?":"+t:""}]`),e=c}catch(o){console.error(`getDesc exp:${o.message}`)}return e}log(...o){const e=this,n=o.at(-1);if(1===o.length&&"object"==typeof n&&n.fn)e.fn="";else{const n=e.getDesc(o);console.log(n,...o)}}debug(...o){const e=this.getDesc(o);e?console.log(e,...o):console.log(...o)}info(...o){const e=this.getDesc(o);e?console.info(e,...o):console.log(...o)}warn(...o){const{desc:e,arg:n}=this.getDesc(o);e?console.warn(e,...n):console.log(...o)}trace(...o){const{desc:e,arg:n}=this.getDesc(o);e?console.trace(e,...n):console.trace(...o)}error(...o){const e=this.getDesc(o);e?console.error(e,...o):console.log(...o)}err(...o){const e=o?.[0];(e instanceof Error||e&&e.message&&e.cause&&e.stack)&&(o[0]={exp:o[0].message}),this.error(...o)}};function n(o){let e="";const n=o.at(-1);return"string"==typeof n&&(e=n,o.pop()),e}function s(...o){const s=o.at(-1);if(1!==o.length||!s?.m){const e=n(o);return void(e?console.log(e,...o):console.log(...o))}const t=new e(s?.m),c=(...o)=>t.log(...o);return c.debug=t.debug.bind(t),c.info=t.info.bind(t),c.warn=t.warn.bind(t),c.info=t.info.bind(t),c.trace=t.trace.bind(t),c.error=t.error.bind(t),c.err=t.err.bind(t),c}s.err=(...o)=>{const e=n(o),s=o?.[0];(s instanceof Error||s&&s.message&&s.cause&&s.stack)&&(o[0]={exp:o[0].message}),e?console.error(e,...o):console.error(...o)},s.error=(...o)=>{const e=n(o);e?console.error(e,...o):console.error(...o)},s.warn=(...o)=>{const e=n(o);e?console.warn(e,...o):console.warn(...o)},s.info=(...o)=>{const e=n(o);e?console.info(e,...o):console.info(...o)},s.debug=(...o)=>{const e=n(o);e?console.log(e,...o):console.log(...o)},s.trace=(...o)=>{const e=n(o);e?console.trace(e,...o):console.trace(...o)},o.log=s,o.name=function(o){return""}},"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((o="undefined"!=typeof globalThis?globalThis:o||self).Log={});
|
package/dist/log.mjs
CHANGED
package/lib/browser.js
CHANGED
@@ -160,4 +160,17 @@ function getDesc(args) {
|
|
160
160
|
const desc = getDesc(args);
|
161
161
|
desc ? console.trace(desc, ...args) : console.trace(...args);
|
162
162
|
};
|
163
|
-
|
163
|
+
/**
|
164
|
+
* 获取模块文件名称
|
165
|
+
* esm: import.meta.url or cjs: __filename
|
166
|
+
* @param {string} file
|
167
|
+
* @returns
|
168
|
+
*/ function name(file) {
|
169
|
+
// import.meta.url: 'file:///D:/prj/wiajs/req/test/log.t.js'
|
170
|
+
// file = fileURLToPath(file) // fileUrl 转成路径
|
171
|
+
// const baseName = path.basename(file)
|
172
|
+
// return baseName.replace(path.extname(baseName), '')
|
173
|
+
return '';
|
174
|
+
}
|
175
|
+
export { name, log }; // export default log;
|
176
|
+
// export { log, Log };
|