1 Star 0 Fork 5.2K

OpenHarmony-build / docs

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
js-apis-basic-features-logs.md 9.75 KB
一键复制 编辑 原始数据 按行查看 历史
zengyawen 提交于 2021-11-10 20:02 . add arkui

日志打印

导入模块

无需导入。

权限列表

console.debug

debug(message: string): void

打印debug级别的日志信息。

  • 参数

    参数名

    类型

    必填

    说明

    message

    string

    表示要打印的文本信息。

console.log

log(message: string): void

打印debug级别的日志信息。

  • 参数

    参数名

    类型

    必填

    说明

    message

    string

    表示要打印的文本信息。

console.info

info(message: string): void

打印info级别的日志信息。

  • 参数

    参数名

    类型

    必填

    说明

    message

    string

    表示要打印的文本信息。

console.warn

warn(message: string): void

打印warn级别的日志信息。

  • 参数

    参数名

    类型

    必填

    说明

    message

    string

    表示要打印的文本信息。

console.error

error(message: string): void

打印error级别的日志信息。

  • 参数

    参数名

    类型

    必填

    说明

    message

    string

    表示要打印的文本信息。

示例


var versionCode = 1;
console.info('Hello World. The current version code is ' + versionCode);
console.log(`versionCode: ${versionCode}`)
// 以下写法从API Version 6开始支持
console.log('versionCode:%d.', versionCode);

在DevEco Studio的底部,切换到“HiLog”窗口。选择当前的设备及进程,日志级别选择Info,搜索内容设置为“Hello World”。此时窗口仅显示符合条件的日志,效果如图所示:

1
https://gitee.com/openharmony-build/docs.git
git@gitee.com:openharmony-build/docs.git
openharmony-build
docs
docs
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891