From 3e44d2a5662b188f3f1b5ae5d70795030b768531 Mon Sep 17 00:00:00 2001 From: zengyawen Date: Tue, 15 Feb 2022 11:54:35 +0800 Subject: [PATCH 1/2] update docs Signed-off-by: zengyawen --- ...t.md => database-preference-guidelines.md} | 0 ...iew.md => database-preference-overview.md} | 0 ...t.md => database-relational-guidelines.md} | 0 .../reference/apis/Readme-CN.md | 1 + .../reference/apis/js-apis-hilog.md | 182 ++++++++++++++++++ 5 files changed, 183 insertions(+) rename en/application-dev/database/{lightweight-data-store-development.md => database-preference-guidelines.md} (100%) rename en/application-dev/database/{lightweight-data-store-overview.md => database-preference-overview.md} (100%) rename en/application-dev/database/{database-relational-development.md => database-relational-guidelines.md} (100%) create mode 100644 zh-cn/application-dev/reference/apis/js-apis-hilog.md diff --git a/en/application-dev/database/lightweight-data-store-development.md b/en/application-dev/database/database-preference-guidelines.md similarity index 100% rename from en/application-dev/database/lightweight-data-store-development.md rename to en/application-dev/database/database-preference-guidelines.md diff --git a/en/application-dev/database/lightweight-data-store-overview.md b/en/application-dev/database/database-preference-overview.md similarity index 100% rename from en/application-dev/database/lightweight-data-store-overview.md rename to en/application-dev/database/database-preference-overview.md diff --git a/en/application-dev/database/database-relational-development.md b/en/application-dev/database/database-relational-guidelines.md similarity index 100% rename from en/application-dev/database/database-relational-development.md rename to en/application-dev/database/database-relational-guidelines.md diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md index fbe27929e9f..8b2cdb6da52 100644 --- a/zh-cn/application-dev/reference/apis/Readme-CN.md +++ b/zh-cn/application-dev/reference/apis/Readme-CN.md @@ -71,6 +71,7 @@ - [应用打点](js-apis-hiappevent.md) - [性能打点](js-apis-bytrace.md) - [故障日志获取](js-apis-faultLogger.md) + - [日志打印](js-apis-hilog.md) - 语言基础类库 - [获取进程相关的信息](js-apis-process.md) - [URL字符串解析](js-apis-url.md) diff --git a/zh-cn/application-dev/reference/apis/js-apis-hilog.md b/zh-cn/application-dev/reference/apis/js-apis-hilog.md new file mode 100644 index 00000000000..10809a70e65 --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-hilog.md @@ -0,0 +1,182 @@ +# 日志打印 + +> **说明:** +> +> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 + +## 导入模块 + +``` +import hilog from '@ohos.hilog'; +``` + +## 系统能力 + +SystemCapability.HiviewDFX.HiLog + +## hilog.debug + +debug(domain: number, tag: string, format: string, ...args: any[]) : void + +debug日志输出,打印debug级别日志。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------- | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | +| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | +| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | + +**示例:** + +``` +hilog.debug(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +``` + +**输出:** + +``` +09-08 12:49:35.941 1547 2452 D FF00/testTag: 1: hello World 3.0 +``` + +## **hilog.info** + +info(domain: number, tag: string, format: string, ...args: any[]) : void + +info日志输出,打印info级别日志。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------- | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | +| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | +| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | + +**示例:** + +``` +hilog.info(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +``` + +**输出:** + +``` +09-08 12:49:35.941 1547 2452 I FF00/testTag: 1: hello World 3.0 +``` + +## hilog.warn + +warn(domain: number, tag: string, format: string, ...args: any[]) : void + +warn日志输出,打印warn级别日志。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------- | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | +| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | +| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | + +**示例:** + +``` +hilog.warn(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +``` + +**输出:** + +``` +09-08 12:49:35.941 1547 2452 W FF00/testTag: 1: hello World 3.0 +``` + +## hilog.error + +error(domain: number, tag: string, format: string, ...args: any[]) : void + +error日志输出,打印error级别日志。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------- | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | +| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | +| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | + +**示例:** + +``` +hilog.error(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +``` + +**输出:** + +``` +09-08 12:49:35.941 1547 2452 E FF00/testTag: 1: hello World 3.0 +``` + +## hilog.fatal + +fatal(domain: number, tag: string, format: string, ...args: any[]) : void + +fatal日志输出,打印fatal级别日志。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | -------------- | ---- | ------------------------------------------------------------ | +| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | +| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | +| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 | +| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 | + +**示例:** + +``` +hilog.fatal(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0); +``` + +**输出:** + +``` +09-08 12:49:35.941 1547 2452 F FF00/testTag: 1: hello World 3.0 +``` + +## hilog.isLoggable + +isLoggable(domain: number, tag: string, level: LogLevel) : boolean + +检查一个domain、tag和日志级别是否被禁止打印日志。 + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | --------------------- | ---- | ------------------------------------------ | +| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 | +| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 | +| level | [LogLevel](#loglevel) | 是 | 日志级别。 | + +**示例:** + +``` +hilog.isLoggable(0xFF00, "testTag", hilog.DEBUG); +``` + +## LogLevel + +用于表示事件类型。 + +| 名称 | 默认值 | 说明 | +| ----- | ------ | ----------- | +| DEBUG | 3 | DEBUG级别。 | +| INFO | 4 | INFO级别。 | +| WARN | 5 | WARN级别。 | +| ERROR | 6 | ERROR级别。 | +| FATAL | 7 | FATAL级别。 | \ No newline at end of file -- Gitee From 1166dc1a97048654160b6b4fa77ca38fb93b9d8c Mon Sep 17 00:00:00 2001 From: zengyawen Date: Tue, 15 Feb 2022 14:34:33 +0800 Subject: [PATCH 2/2] update docs Signed-off-by: zengyawen --- en/application-dev/reference/apis/js-apis-util.md | 13 ++++++------- .../application-dev/reference/apis/js-apis-util.md | 12 ++++++------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-util.md b/en/application-dev/reference/apis/js-apis-util.md index 6301c943364..420cddd41ba 100644 --- a/en/application-dev/reference/apis/js-apis-util.md +++ b/en/application-dev/reference/apis/js-apis-util.md @@ -193,8 +193,8 @@ Calls back an asynchronous function. In the callback, the first parameter indica } var cb = util.callbackWrapper(promiseFn); cb((err, ret) => { - expect(err).strictEqual('value'); - expect(ret).strictEqual(undefined); + console.log(err); + console.log(ret); }) ``` @@ -259,7 +259,7 @@ Processes an asynchronous function and returns a promise version. } let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World'); newPromiseObj.then(res => { - expect(res).strictEqual('HelloWorld'); + console.log(res); }) ``` @@ -3054,7 +3054,7 @@ Encodes the input content asynchronously. var rarray = new Uint8Array([99,122,69,122]); await that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { - expect(val[i]).assertEqual(rarray[i]) + console.log(val[i]) } }) done(); @@ -3115,7 +3115,7 @@ Encodes the input content asynchronously into a string. var that = new util.Base64(); var array = new Uint8Array([115,49,51]); await that.encodeToString(array).then(val=>{ - expect(val).assertEqual('czEz') + console.log(val) }) done(); ``` @@ -3177,7 +3177,7 @@ Decodes the input content asynchronously. var rarray = new Uint8Array([115,49,51]); await that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { - expect(val[i]).assertEqual(rarray[i]) + console.log(val[i]) } }) done(); @@ -5174,4 +5174,3 @@ Checks whether the input value is of the **WeakSet** type. var result = that.isWeakSet(new WeakSet()); ``` - diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md index 0a49bd1313b..6b08fdcb79e 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-util.md +++ b/zh-cn/application-dev/reference/apis/js-apis-util.md @@ -86,8 +86,8 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void } var cb = util.callbackWrapper(promiseFn); cb((err, ret) => { - expect(err).strictEqual('value'); - expect(ret).strictEqual(undefined); + console.log(err); + console.log(ret); }) ``` @@ -119,7 +119,7 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object } let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World'); newPromiseObj.then(res => { - expect(res).strictEqual('HelloWorld'); + console.log(res); }) ``` @@ -1426,7 +1426,7 @@ encode(src:Uint8Array):Promise<Uint8Array> var rarray = new Uint8Array([99,122,69,122]); that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { - expect(val[i]).assertEqual(rarray[i]) + console.log(val[i]) } }) ``` @@ -1453,7 +1453,7 @@ encodeToString(src:Uint8Array):Promise<string> var that = new util.Base64(); var array = new Uint8Array([115,49,51]); that.encodeToString(array).then(val=>{ - expect(val).assertEqual('czEz') + console.log(val) }) ``` @@ -1481,7 +1481,7 @@ decode(src:Uint8Array | string):Promise<Uint8Array> var rarray = new Uint8Array([115,49,51]); that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { - expect(val[i]).assertEqual(rarray[i]) + console.log(val[i]) } }) ``` -- Gitee