赞
踩
以格式化输出方式打印调试信息
console.debug()
console.debug(‘debug。。。’ )
以格式化输出方式打印日志信息
console.log()
console.log(‘info。。。’)
以格式化输出方式打印警告信息
console.warn()
输出信息
console.info()
console.info(`Aceaaa${JSON.stringify(oldValue)} `)
一定注意引号是英文下的“`” ,即ESC下的"```"
新建logger.ets 文件
导入鸿蒙基础库
import hilog from ‘@ohos.hilog’;
import hilog from '@ohos.hilog'; class Logger { private domain: number; private prefix: string; private format: string = '%{public}s, %{public}s'; constructor(prefix: string = 'MyApp', domain: number = 0xFF00) { this.prefix = prefix; this.domain = domain; } debug(...args: string[]): void { hilog.debug(this.domain, this.prefix, this.format, args); } info(...args: string[]): void { hilog.info(this.domain, this.prefix, this.format, args); } warn(...args: string[]): void { hilog.warn(this.domain, this.prefix, this.format, args); } error(...args: string[]): void { hilog.error(this.domain, this.prefix, this.format, args); } } export default new Logger('[OxHornCampus]', 0xFF00)
import Logger from '../Logger';
Logger.info(`输出内容。。。。。`);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。