1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit PerformanceAnalysisKit 19 */ 20 21import type { AsyncCallback } from './@ohos.base'; 22 23/** 24 * @namespace logLibrary 25 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 26 * @systemapi 27 * @since arkts {'1.1':'10','1.2':'20'} 28 * @arkts 1.1&1.2 29 */ 30declare namespace logLibrary { 31 /** 32 * Log file entry 33 * 34 * @typedef LogEntry 35 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 36 * @systemapi 37 * @since arkts {'1.1':'10','1.2':'20'} 38 * @arkts 1.1&1.2 39 */ 40 interface LogEntry { 41 /** 42 * Log file name 43 * 44 * @type { string } 45 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 46 * @systemapi 47 * @since arkts {'1.1':'10','1.2':'20'} 48 * @arkts 1.1&1.2 49 */ 50 name: string; 51 52 /** 53 * File modification time, expressed by the number of seconds elapsed from 1970-01-01 54 * 55 * @type { number } 56 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 57 * @systemapi 58 * @since arkts {'1.1':'10','1.2':'20'} 59 * @arkts 1.1&1.2 60 */ 61 mtime: number; 62 63 /** 64 * Log file size, byte 65 * 66 * @type { number } 67 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 68 * @systemapi 69 * @since arkts {'1.1':'10','1.2':'20'} 70 * @arkts 1.1&1.2 71 */ 72 size: number; 73 } 74 75 /** 76 * List all log names of log type 77 * 78 * @permission ohos.permission.READ_HIVIEW_SYSTEM 79 * @param { string } logType - Log type 80 * @returns { LogEntry[] } Return LogEntry[] 81 * @throws { BusinessError } 201 - Permission denied 82 * @throws { BusinessError } 202 - Permission denied, non-system app called system api 83 * @throws { BusinessError } 401 - Invalid argument. Possible causes: 84 * <br>1. Mandatory parameters are left unspecified. 85 * <br>2. Incorrect parameter types. 86 * <br>3. Parameter verification failed. 87 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 88 * @systemapi 89 * @since arkts {'1.1':'10','1.2':'20'} 90 * @arkts 1.1&1.2 91 */ 92 function list(logType: string): LogEntry[]; 93 94 /** 95 * Copy log to dest path 96 * 97 * @permission ohos.permission.READ_HIVIEW_SYSTEM 98 * @param { string } logType - Log type 99 * @param { string } logName - Log name 100 * @param { string } dest - Log path under hiview sandbox of HAP 101 * @returns { Promise<void> } Return Promise 102 * @throws { BusinessError } 201 - Permission denied 103 * @throws { BusinessError } 202 - Permission denied, non-system app called system api 104 * @throws { BusinessError } 401 - Invalid argument. Possible causes: 105 * <br>1. Mandatory parameters are left unspecified. 106 * <br>2. Incorrect parameter types. 107 * <br>3. Parameter verification failed. 108 * @throws { BusinessError } 21300001 - Source file does not exists 109 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 110 * @systemapi 111 * @since arkts {'1.1':'10','1.2':'20'} 112 * @arkts 1.1&1.2 113 */ 114 function copy(logType: string, logName: string, dest: string): Promise<void>; 115 116 /** 117 * Copy log to dest path 118 * 119 * @permission ohos.permission.READ_HIVIEW_SYSTEM 120 * @param { string } logType - Log type 121 * @param { string } logName - Log name 122 * @param { string } dest - Log path under hiview sandbox of HAP 123 * @param { AsyncCallback<void> } callback - After finish copy log will callback 124 * @throws { BusinessError } 201 - Permission denied 125 * @throws { BusinessError } 202 - Permission denied, non-system app called system api 126 * @throws { BusinessError } 401 - Invalid argument. Possible causes: 127 * <br>1. Mandatory parameters are left unspecified. 128 * <br>2. Incorrect parameter types. 129 * <br>3. Parameter verification failed. 130 * @throws { BusinessError } 21300001 - Source file does not exists 131 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 132 * @systemapi 133 * @since arkts {'1.1':'10','1.2':'20'} 134 * @arkts 1.1&1.2 135 */ 136 function copy(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void; 137 138 /** 139 * Move log to dest path 140 * 141 * @permission ohos.permission.WRITE_HIVIEW_SYSTEM 142 * @param { string } logType - Log type 143 * @param { string } logName - Log name 144 * @param { string } dest - Log path under hiview sandbox of HAP 145 * @returns { Promise<void> } Return Promise 146 * @throws { BusinessError } 201 - Permission denied 147 * @throws { BusinessError } 202 - Permission denied, non-system app called system api 148 * @throws { BusinessError } 401 - Invalid argument. Possible causes: 149 * <br>1. Mandatory parameters are left unspecified. 150 * <br>2. Incorrect parameter types. 151 * <br>3. Parameter verification failed. 152 * @throws { BusinessError } 21300001 - Source file does not exists 153 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 154 * @systemapi 155 * @since arkts {'1.1':'10','1.2':'20'} 156 * @arkts 1.1&1.2 157 */ 158 function move(logType: string, logName: string, dest: string): Promise<void>; 159 160 /** 161 * Move log to dest path 162 * 163 * @permission ohos.permission.WRITE_HIVIEW_SYSTEM 164 * @param { string } logType - Log type 165 * @param { string } logName - Log name 166 * @param { string } dest - Log path under hiview sandbox of HAP 167 * @param { AsyncCallback<void> } callback - After finish move log will callback 168 * @throws { BusinessError } 201 - Permission denied 169 * @throws { BusinessError } 202 - Permission denied, non-system app called system api 170 * @throws { BusinessError } 401 - Invalid argument. Possible causes: 171 * <br>1. Mandatory parameters are left unspecified. 172 * <br>2. Incorrect parameter types. 173 * <br>3. Parameter verification failed. 174 * @throws { BusinessError } 21300001 - Source file does not exists 175 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 176 * @systemapi 177 * @since arkts {'1.1':'10','1.2':'20'} 178 * @arkts 1.1&1.2 179 */ 180 function move(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void; 181 182 /** 183 * Delete the log based on log name and log type 184 * 185 * @permission ohos.permission.WRITE_HIVIEW_SYSTEM 186 * @param { string } logType - Log type 187 * @param { string } logName - Log name 188 * @throws { BusinessError } 201 - Permission denied 189 * @throws { BusinessError } 202 - Permission denied, non-system app called system api 190 * @throws { BusinessError } 401 - Invalid argument. Possible causes: 191 * <br>1. Mandatory parameters are left unspecified. 192 * <br>2. Incorrect parameter types. 193 * <br>3. Parameter verification failed. 194 * @throws { BusinessError } 21300001 - Source file does not exists 195 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary 196 * @systemapi 197 * @since arkts {'1.1':'10','1.2':'20'} 198 * @arkts 1.1&1.2 199 */ 200 function remove(logType: string, logName: string): void; 201} 202 203export default logLibrary;