From a9045b1ec64192ff270e39e0a7b1af18f837bf6e Mon Sep 17 00:00:00 2001 From: liujiahui Date: Thu, 11 Sep 2025 14:58:05 +0800 Subject: [PATCH] =?UTF-8?q?imp:=E4=BF=AE=E6=94=B9=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/entryability/EntryAbility.ets | 21 ++++++------- entry/src/main/ets/pages/Index.ets | 10 +++---- entry/src/main/ets/utils/CommonUtils.ets | 5 ++-- entry/src/main/ets/view/LocalFileList.ets | 2 +- entry/src/main/ets/view/Preview.ets | 2 +- entry/src/main/ets/view/RemoteFileList.ets | 30 ++++++++----------- entry/src/main/ets/view/TitleBar.ets | 2 +- 7 files changed, 34 insertions(+), 38 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index e451390..ef654f6 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -25,46 +25,47 @@ export default class EntryAbility extends UIAbility { onCreate(_want: Want, _launchParam: AbilityConstant.LaunchParam): void { try { this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + hilog.info(DOMAIN, 'onCreate', 'Ability onCreate'); } catch (error) { - hilog.error(0xFF00, 'EntryAbility', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(DOMAIN, 'EntryAbility', `have errors Code: ${error.code}, message: ${error.message}`); } } onDestroy(): void { - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + hilog.info(DOMAIN, 'testTag', 'onDestroy', 'Ability onDestroy'); } onWindowStageCreate(windowStage: window.WindowStage): void { // Main window is created, set main page for this ability - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + hilog.info(DOMAIN, 'testTag', 'onWindowStageCreate', 'Ability onWindowStageCreate'); try { windowStage.loadContent('pages/Index', (err: BusinessError) => { if (err.code) { - hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + hilog.error(DOMAIN, 'EntryAbility', `have errors Code: ${err.code}, message: ${err.message}`); return; } - hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + hilog.info(DOMAIN, 'onWindowStageCreate', 'Succeeded in loading the content.'); uiContext = windowStage.getMainWindowSync().getUIContext(); AppStorage.setOrCreate('uiContext', windowStage.getMainWindowSync().getUIContext()); }); } catch (error) { - hilog.error(0xFF00, 'EntryAbility', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(DOMAIN, 'EntryAbility', + `onWindowStageCreate have errors Code: ${error.code}, message: ${error.message}`); } } onWindowStageDestroy(): void { // Main window is destroyed, release UI related resources - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + hilog.info(DOMAIN, 'onWindowStageDestroy', 'Ability onWindowStageDestroy'); } onForeground(): void { // Ability has brought to foreground - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + hilog.info(DOMAIN, 'onForeground', 'Ability onForeground'); } onBackground(): void { // Ability has back to background - hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + hilog.info(DOMAIN, 'onBackground', 'Ability onBackground'); } } diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 22c2417..5992274 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -1,13 +1,13 @@ /* * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * Licensed under the Apache License, Version 2.0 (the 'License'); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, + * distributed under the License is distributed on an 'AS IS' BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. @@ -62,7 +62,7 @@ struct Index { try { // Create files in a distributed directory let file = fs.openSync(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); - hilog.info(0x0000, 'Index', '%{public}s', 'Succeeded in creating.'); + hilog.info(0x0000, 'Index', 'openSync Succeeded in creating.'); // Write content to a file fs.writeSync(file.fd, this.fileContent); // close file @@ -73,7 +73,7 @@ struct Index { this.fileContent = ''; // [EndExclude create_file] } catch (error) { - hilog.error(0xFF00, 'Index', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(0xFF00, 'Index', `openSync have errors Code: ${error.code}, message: ${error.message}`); } // [EndExclude import_file] } @@ -114,7 +114,7 @@ struct Index { this.uiContext!.getPromptAction().showToast({ message: $r('app.string.reauthorization') }); } } catch (error) { - hilog.error(0xFF00, 'Index', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(0xFF00, 'Index', `permissions have errors Code: ${error.code}, message: ${error.message}`); } } diff --git a/entry/src/main/ets/utils/CommonUtils.ets b/entry/src/main/ets/utils/CommonUtils.ets index 83b9424..d06cf54 100644 --- a/entry/src/main/ets/utils/CommonUtils.ets +++ b/entry/src/main/ets/utils/CommonUtils.ets @@ -24,7 +24,7 @@ class CommonUtils { try { uiContext.getPromptAction().showToast({ message }); } catch (error) { - hilog.error(0xFF00, 'CommonUtils', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(0xFF00, 'CommonUtils', `showToast have errors Code: ${error.code}, message: ${error.message}`); } } @@ -34,8 +34,7 @@ class CommonUtils { const srcUri = pathDir + `/${selectedValue}`; // Splicing the sandbox path of the required file fs.unlink(srcUri, (err: BusinessError) => { if (err) { - hilog.error(0x0000, 'RemoteFile', '%{public}s', - 'remove file failed with error message: ' + err.message + ', error code: ' + err.code); + hilog.error(0x0000, 'delete', 'have errors Code ' + err.message + ', error code: ' + err.code); callback(false); } else { this.showToast($r('app.string.delete_successfully'), uiContext!); diff --git a/entry/src/main/ets/view/LocalFileList.ets b/entry/src/main/ets/view/LocalFileList.ets index 838982e..c9992ec 100644 --- a/entry/src/main/ets/view/LocalFileList.ets +++ b/entry/src/main/ets/view/LocalFileList.ets @@ -71,7 +71,7 @@ export struct LocalFileList { try { this.localFileListArr = await fs.listFile(pathDir); } catch (error) { - hilog.error(0xFF00, 'LocalFileList', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(0xFF00, 'LocalFileList', `getFileList have errors Code: ${error.code}, message: ${error.message}`); } // [StartExclude get_file] if (this.localFileListArr.length > 0) { diff --git a/entry/src/main/ets/view/Preview.ets b/entry/src/main/ets/view/Preview.ets index df1bbef..950fbd4 100644 --- a/entry/src/main/ets/view/Preview.ets +++ b/entry/src/main/ets/view/Preview.ets @@ -52,7 +52,7 @@ export struct Preview { try { this.fileContent = fs.readTextSync(this.targetPath); //Read the file, fileContent is the content of the read file } catch (error) { - hilog.error(0xFF00, 'Preview', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(0xFF00, 'Preview', `readTextSync have errors Code: ${error.code}, message: ${error.message}`); } } diff --git a/entry/src/main/ets/view/RemoteFileList.ets b/entry/src/main/ets/view/RemoteFileList.ets index f2e0cf2..911bc44 100644 --- a/entry/src/main/ets/view/RemoteFileList.ets +++ b/entry/src/main/ets/view/RemoteFileList.ets @@ -51,7 +51,7 @@ export struct RemoteFileList { @State connectedNetworkIds: string[] = []; listeners: fs.DfsListeners = { onStatus: (_networkId: string, _status: number): void => { - hilog.info(0x0000, 'RemoteFile', '%{public}s', 'Failed to access public directory'); + hilog.info(0x0000, 'RemoteFile', 'Failed to access public directory'); } }; ProgressDialog: CustomDialogController = new CustomDialogController({ @@ -97,11 +97,10 @@ export struct RemoteFileList { if (!this.connectedNetworkIds.includes(deviceInfo.networkId!)) { this.connectedNetworkIds.push(deviceInfo.networkId!); } - hilog.info(0x0000, 'RemoteFile', '%{public}s', - `Success to connect dfs for network ${deviceInfo.networkId}`); + hilog.info(0x0000, 'RemoteFile', `connectDfs Success to connect dfs for network ${deviceInfo.networkId}`); }) .catch((error: BusinessError) => { - hilog.error(0x0000, 'RemoteFile', '%{public}s', + hilog.error(0x0000, 'RemoteFile', `Failed to connect dfs for network ${deviceInfo.networkId}. Code: ${error.code}, message: ${error.message}`); }); }); @@ -119,12 +118,10 @@ export struct RemoteFileList { this.isEdit = false; } } catch (error) { - hilog.error(0x0000, 'RemoteFile', '%{public}s', - `Error in remoteFileListArr. Code: ${error.code}, message: ${error.message}`); + hilog.error(0x0000, 'RemoteFile', `promistAll listFile. Code: ${error.code}, message: ${error.message}`); } }).catch((error: BusinessError) => { - hilog.error(0x0000, 'RemoteFile', '%{public}s', - `Error in connection process. Code: ${error.code}, message: ${error.message}`); + hilog.error(0x0000, 'RemoteFile', `promistAll have error. Code: ${error.code}, message: ${error.message}`); }); } @@ -132,7 +129,7 @@ export struct RemoteFileList { async disconnectAllDfs() { // If there are no connected devices, return directly if (this.connectedNetworkIds.length === 0) { - hilog.info(0x0000, 'RemoteFile', '%{public}s', 'No connected devices to disconnect'); + hilog.info(0x0000, 'RemoteFile', 'No connected devices to disconnect'); return; } @@ -140,12 +137,11 @@ export struct RemoteFileList { const disconnectPromises = this.connectedNetworkIds.map(networkId => { return fs.disconnectDfs(networkId) .then(() => { - hilog.info(0x0000, 'RemoteFile', '%{public}s', - `Success to disconnect dfs for network ${networkId}`); + hilog.info(0x0000, 'RemoteFile', `Success to disconnect dfs for network ${networkId}`); }) .catch((error: BusinessError) => { const err: BusinessError = error as BusinessError; - hilog.error(0x0000, 'RemoteFile', '%{public}s', + hilog.error(0x0000, 'RemoteFile', `Failed to disconnect dfs for network ${networkId}. Code: ${err.code}, message: ${err.message}`); }); }); @@ -154,7 +150,7 @@ export struct RemoteFileList { // Clear the list of connected devices this.connectedNetworkIds = []; - hilog.info(0x0000, 'RemoteFile', '%{public}s', 'All connected devices disconnect process completed'); + hilog.info(0x0000, 'RemoteFile', 'All connected devices disconnect process completed'); } aboutToDisappear(): void { @@ -178,7 +174,8 @@ export struct RemoteFileList { this.isShowDialog = false; } } catch (error) { - hilog.error(0xFF00, 'RemoteFileList', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(0xFF00, 'RemoteFileList', + `getRemoteFileList have errors Code: ${error.code}, message: ${error.message}`); } } @@ -213,13 +210,12 @@ export struct RemoteFileList { 'progressListener': progressListener }; fs.copy(srcUri, destUri, copyOption).then(() => { - hilog.info(0x0000, 'RemoteFile', '%{public}s', 'Success to copy.'); + hilog.info(0x0000, 'RemoteFile', 'Success to copy.'); }).catch((err: BusinessError) => { hilog.error(0x0000, 'RemoteFile', `Failed to copy.Code:${err.code},message: ${err.message}`); }); } catch (err) { - hilog.error(0x0000, 'RemoteFile', '%{public}s', - `Failed to copy.Code try: ${err.code}, message: ${err.message}`); + hilog.error(0x0000, 'RemoteFile', `catch Failed to copy.Code: ${err.code}, message: ${err.message}`); } } } diff --git a/entry/src/main/ets/view/TitleBar.ets b/entry/src/main/ets/view/TitleBar.ets index c7650f5..b745254 100644 --- a/entry/src/main/ets/view/TitleBar.ets +++ b/entry/src/main/ets/view/TitleBar.ets @@ -76,7 +76,7 @@ export struct TitleBar { // [EndExclude save_file] } } catch (error) { - hilog.error(0xFF00, 'TitleBar', `have errors Code: ${error.code}, message: ${error.message}`); + hilog.error(0xFF00, 'TitleBar', `catch have errors Code: ${error.code}, message: ${error.message}`); } } -- Gitee