• 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
16import type { AsyncCallback } from './@ohos.base';
17
18/**
19 * @namespace logLibrary
20 * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
21 * @systemapi
22 * @since 10
23 */
24declare namespace logLibrary {
25  /**
26   * Log file entry
27   *
28   * @typedef LogEntry
29   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
30   * @systemapi
31   * @since 10
32   */
33  interface LogEntry {
34    /**
35     * Log file name
36     *
37     * @type { string }
38     * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
39     * @systemapi
40     * @since 10
41     */
42    name: string;
43
44    /**
45     * File modification time, expressed by the number of seconds elapsed from 1970-01-01
46     *
47     * @type { number }
48     * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
49     * @systemapi
50     * @since 10
51     */
52    mtime: number;
53
54    /**
55     * Log file size, byte
56     *
57     * @type { number }
58     * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
59     * @systemapi
60     * @since 10
61     */
62    size: number;
63  }
64
65  /**
66   * List all log names of log type
67   *
68   * @permission ohos.permission.READ_HIVIEW_SYSTEM
69   * @param { string } logType - Log type
70   * @returns { LogEntry[] } Return LogEntry[]
71   * @throws { BusinessError } 201 - Permission denied
72   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
73   * @throws { BusinessError } 401 - Invalid argument
74   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
75   * @systemapi
76   * @since 10
77   */
78  function list(logType: string): LogEntry[];
79
80  /**
81   * Copy log to dest path
82   *
83   * @permission ohos.permission.READ_HIVIEW_SYSTEM
84   * @param { string } logType - Log type
85   * @param { string } logName - Log name
86   * @param { string } dest - Log path under hiview sandbox of HAP
87   * @returns { Promise<void> } Return Promise
88   * @throws { BusinessError } 201 - Permission denied
89   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
90   * @throws { BusinessError } 401 - Invalid argument
91   * @throws { BusinessError } 21300001 - Source file does not exists
92   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
93   * @systemapi
94   * @since 10
95   */
96  function copy(logType: string, logName: string, dest: string): Promise<void>;
97
98  /**
99   * Copy log to dest path
100   *
101   * @permission ohos.permission.READ_HIVIEW_SYSTEM
102   * @param { string } logType - Log type
103   * @param { string } logName - Log name
104   * @param { string } dest - Log path under hiview sandbox of HAP
105   * @param { AsyncCallback<void> } callback - After finish copy log will callback
106   * @throws { BusinessError } 201 - Permission denied
107   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
108   * @throws { BusinessError } 401 - Invalid argument
109   * @throws { BusinessError } 21300001 - Source file does not exists
110   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
111   * @systemapi
112   * @since 10
113   */
114  function copy(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void;
115
116  /**
117   * Move log to dest path
118   *
119   * @permission ohos.permission.WRITE_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   * @returns { Promise<void> } Return Promise
124   * @throws { BusinessError } 201 - Permission denied
125   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
126   * @throws { BusinessError } 401 - Invalid argument
127   * @throws { BusinessError } 21300001 - Source file does not exists
128   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
129   * @systemapi
130   * @since 10
131   */
132  function move(logType: string, logName: string, dest: string): Promise<void>;
133
134  /**
135   * Move log to dest path
136   *
137   * @permission ohos.permission.WRITE_HIVIEW_SYSTEM
138   * @param { string } logType - Log type
139   * @param { string } logName - Log name
140   * @param { string } dest - Log path under hiview sandbox of HAP
141   * @param { AsyncCallback<void> } callback - After finish move log will callback
142   * @throws { BusinessError } 201 - Permission denied
143   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
144   * @throws { BusinessError } 401 - Invalid argument
145   * @throws { BusinessError } 21300001 - Source file does not exists
146   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
147   * @systemapi
148   * @since 10
149   */
150  function move(logType: string, logName: string, dest: string, callback: AsyncCallback<void>): void;
151
152  /**
153   * Delete the log based on log name and log type
154   *
155   * @permission ohos.permission.WRITE_HIVIEW_SYSTEM
156   * @param { string } logType - Log type
157   * @param { string } logName - Log name
158   * @throws { BusinessError } 201 - Permission denied
159   * @throws { BusinessError } 202 - Permission denied, non-system app called system api
160   * @throws { BusinessError } 401 - Invalid argument
161   * @throws { BusinessError } 21300001 - Source file does not exists
162   * @syscap SystemCapability.HiviewDFX.Hiview.LogLibrary
163   * @systemapi
164   * @since 10
165   */
166  function remove(logType: string, logName: string): void;
167}
168
169export default logLibrary;