• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 10
28 */
29declare namespace logLibrary {
30  /**
31   * Log file entry
32   *
33   * @typedef LogEntry
34   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
35   * @systemapi
36   * @since 10
37   */
38  interface LogEntry {
39    /**
40     * Log file name
41     *
42     * @type { string }
43     * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
44     * @systemapi
45     * @since 10
46     */
47    name: string;
48
49    /**
50     * File modification time, expressed by the number of seconds elapsed from 1970-01-01
51     *
52     * @type { number }
53     * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
54     * @systemapi
55     * @since 10
56     */
57    mtime: number;
58
59    /**
60     * Log file size, byte
61     *
62     * @type { number }
63     * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
64     * @systemapi
65     * @since 10
66     */
67    size: number;
68  }
69
70  /**
71   * List all log names of log type
72   *
73   * @permission ohos.permission.READ_HIVIEW_SYSTEM
74   * @param { string } logType - Log type
75   * @returns { LogEntry[] } Return LogEntry[]
76   * @throws { BusinessError } 201 - Permission denied
77   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
78   * @throws { BusinessError } 401 - Invalid argument. Possible causes:
79   * <br>1. Mandatory parameters are left unspecified.
80   * <br>2. Incorrect parameter types.
81   * <br>3. Parameter verification failed.
82   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
83   * @systemapi
84   * @since 10
85   */
86  function list(logType: string): LogEntry[];
87
88  /**
89   * Copy log to dest path
90   *
91   * @permission ohos.permission.READ_HIVIEW_SYSTEM
92   * @param { string } logType - Log type
93   * @param { string } logName - Log name
94   * @param { string } dest - Log path under hiview sandbox of HAP
95   * @returns { Promise<void> } Return Promise
96   * @throws { BusinessError } 201 - Permission denied
97   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
98   * @throws { BusinessError } 401 - Invalid argument. Possible causes:
99   * <br>1. Mandatory parameters are left unspecified.
100   * <br>2. Incorrect parameter types.
101   * <br>3. Parameter verification failed.
102   * @throws { BusinessError } 21300001 - Source file does not exists
103   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
104   * @systemapi
105   * @since 10
106   */
107  function copy(logType: string, logName: string, dest: string): Promise<void>;
108
109  /**
110   * Copy log to dest path
111   *
112   * @permission ohos.permission.READ_HIVIEW_SYSTEM
113   * @param { string } logType - Log type
114   * @param { string } logName - Log name
115   * @param { string } dest - Log path under hiview sandbox of HAP
116   * @param { AsyncCallback<void> } callback - After finish copy log will callback
117   * @throws { BusinessError } 201 - Permission denied
118   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
119   * @throws { BusinessError } 401 - Invalid argument. Possible causes:
120   * <br>1. Mandatory parameters are left unspecified.
121   * <br>2. Incorrect parameter types.
122   * <br>3. Parameter verification failed.
123   * @throws { BusinessError } 21300001 - Source file does not exists
124   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
125   * @systemapi
126   * @since 10
127   */
128  function copy(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void;
129
130  /**
131   * Move log to dest path
132   *
133   * @permission ohos.permission.WRITE_HIVIEW_SYSTEM
134   * @param { string } logType - Log type
135   * @param { string } logName - Log name
136   * @param { string } dest - Log path under hiview sandbox of HAP
137   * @returns { Promise<void> } Return Promise
138   * @throws { BusinessError } 201 - Permission denied
139   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
140   * @throws { BusinessError } 401 - Invalid argument. Possible causes:
141   * <br>1. Mandatory parameters are left unspecified.
142   * <br>2. Incorrect parameter types.
143   * <br>3. Parameter verification failed.
144   * @throws { BusinessError } 21300001 - Source file does not exists
145   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
146   * @systemapi
147   * @since 10
148   */
149  function move(logType: string, logName: string, dest: string): Promise<void>;
150
151  /**
152   * Move log to dest path
153   *
154   * @permission ohos.permission.WRITE_HIVIEW_SYSTEM
155   * @param { string } logType - Log type
156   * @param { string } logName - Log name
157   * @param { string } dest - Log path under hiview sandbox of HAP
158   * @param { AsyncCallback<void> } callback - After finish move log will callback
159   * @throws { BusinessError } 201 - Permission denied
160   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
161   * @throws { BusinessError } 401 - Invalid argument. Possible causes:
162   * <br>1. Mandatory parameters are left unspecified.
163   * <br>2. Incorrect parameter types.
164   * <br>3. Parameter verification failed.
165   * @throws { BusinessError } 21300001 - Source file does not exists
166   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
167   * @systemapi
168   * @since 10
169   */
170  function move(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void;
171
172  /**
173   * Delete the log based on log name and log type
174   *
175   * @permission ohos.permission.WRITE_HIVIEW_SYSTEM
176   * @param { string } logType - Log type
177   * @param { string } logName - Log name
178   * @throws { BusinessError } 201 - Permission denied
179   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
180   * @throws { BusinessError } 401 - Invalid argument. Possible causes:
181   * <br>1. Mandatory parameters are left unspecified.
182   * <br>2. Incorrect parameter types.
183   * <br>3. Parameter verification failed.
184   * @throws { BusinessError } 21300001 - Source file does not exists
185   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
186   * @systemapi
187   * @since 10
188   */
189  function remove(logType: string, logName: string): void;
190}
191
192export default logLibrary;