From df7c1d57136320a0a1ff2f73c3caccb3b2f408f5 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Wed, 7 Sep 2022 15:42:25 +0800 Subject: [PATCH] fix(app): fallback to console when __log__ is not found --- packages/uni-shared/dist/uni-shared.cjs.js | 8 +++++++- packages/uni-shared/dist/uni-shared.es.js | 8 +++++++- packages/uni-shared/src/hbx/formatLog.ts | 7 ++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/uni-shared/dist/uni-shared.cjs.js b/packages/uni-shared/dist/uni-shared.cjs.js index e64af96c2..31f1eb1b0 100644 --- a/packages/uni-shared/dist/uni-shared.cjs.js +++ b/packages/uni-shared/dist/uni-shared.cjs.js @@ -656,7 +656,13 @@ function parseUrl(url) { function formatAppLog(type, filename, ...args) { // @ts-ignore - uni.__log__ && uni.__log__(type, filename, ...args); + if (uni.__log__) { + // @ts-ignore + uni.__log__(type, filename, ...args); + } + else { + console[type].apply(console, [...args, filename]); + } } function formatH5Log(type, filename, ...args) { console[type].apply(console, [...args, filename]); diff --git a/packages/uni-shared/dist/uni-shared.es.js b/packages/uni-shared/dist/uni-shared.es.js index b0f4eadc9..29b805315 100644 --- a/packages/uni-shared/dist/uni-shared.es.js +++ b/packages/uni-shared/dist/uni-shared.es.js @@ -652,7 +652,13 @@ function parseUrl(url) { function formatAppLog(type, filename, ...args) { // @ts-ignore - uni.__log__ && uni.__log__(type, filename, ...args); + if (uni.__log__) { + // @ts-ignore + uni.__log__(type, filename, ...args); + } + else { + console[type].apply(console, [...args, filename]); + } } function formatH5Log(type, filename, ...args) { console[type].apply(console, [...args, filename]); diff --git a/packages/uni-shared/src/hbx/formatLog.ts b/packages/uni-shared/src/hbx/formatLog.ts index cb147b43d..ad35ab0bf 100644 --- a/packages/uni-shared/src/hbx/formatLog.ts +++ b/packages/uni-shared/src/hbx/formatLog.ts @@ -4,7 +4,12 @@ export function formatAppLog( ...args: unknown[] ) { // @ts-ignore - uni.__log__ && uni.__log__(type, filename, ...args) + if (uni.__log__) { + // @ts-ignore + uni.__log__(type, filename, ...args) + } else { + ;(console[type] as Function).apply(console, [...args, filename]) + } } export function formatH5Log( -- GitLab