fix: 日志修改
This commit is contained in:
		
							parent
							
								
									4226dbf1f2
								
							
						
					
					
						commit
						0608d66933
					
				| @ -10,6 +10,7 @@ import { DrivingDataStorage } from '../utils/business/DrivingDataStorage'; | ||||
| import { InitTable } from '../utils/table/Operation'; | ||||
| import FileUtils from '../utils/FileUtils'; | ||||
| import { EntryTag } from '../config'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| 
 | ||||
| export default class EntryAbility extends UIAbility { | ||||
|   async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { | ||||
| @ -23,6 +24,9 @@ export default class EntryAbility extends UIAbility { | ||||
|       if (data !== '' && data !== undefined) { | ||||
|         const result: EnvironmentConfigurationType = JSON.parse(data) | ||||
|         AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", result) | ||||
|         if(result.isOpenLog){ | ||||
|           dConsole.init(result.isOpenLog) | ||||
|         } | ||||
|         const host = `http://${result.centerIp}:${result.centerPort}` | ||||
|         AppStorage.setOrCreate<string>("host", host) | ||||
|       } | ||||
|  | ||||
| @ -10,6 +10,7 @@ import { voiceService } from '../utils/Voice'; | ||||
| import dayTs from '../utils/Date'; | ||||
| import { ObtainUdpBusinessInstance } from '../utils/business/ObtainUdpBusiness'; | ||||
| import common from '@ohos.app.ability.common'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| @ -65,7 +66,7 @@ struct Index { | ||||
|       } | ||||
|       if (status == 'idle') { | ||||
|         if (val == 'kszj.wav') { | ||||
|           console.log('finsh'); | ||||
|           dConsole.log('finsh'); | ||||
|           this.initfackCheck(0); | ||||
|           // this.getCheckList(true) | ||||
|         } else { | ||||
| @ -81,7 +82,7 @@ struct Index { | ||||
|   } | ||||
| 
 | ||||
|   openChuankouFn() { | ||||
|     console.log('SerialOpen in carcheck, path=' + this.devPath) | ||||
|     dConsole.log('SerialOpen in carcheck, path=' + this.devPath) | ||||
| 
 | ||||
|     this.fd = testNapi.SerialOpen(this.devPath); | ||||
|     let parity = 0x4e; // 'N' | ||||
| @ -93,13 +94,13 @@ struct Index { | ||||
|     let databuff = [0x61, 0xAA, 0x0A, 0X15, 0X00]; // send ABCDE | ||||
| 
 | ||||
|     let ret = testNapi.SerialSend(this.fd, databuff); | ||||
|     console.log('mmmm', ret) | ||||
|     dConsole.log('mmmm', ret) | ||||
|     let revTestInfo = testNapi?.SerialRecv(this.fd, timeout); | ||||
| 
 | ||||
|     console.log('revTestInfo', revTestInfo.recevedBuf.length) | ||||
|     dConsole.log('revTestInfo', revTestInfo.recevedBuf.length) | ||||
| 
 | ||||
|     const message = revTestInfo?.recevedBuf?.toString() | ||||
|     console.log('chuankou', this.index, message) | ||||
|     dConsole.log('chuankou', this.index, message) | ||||
|     if (message == '') { | ||||
|       this.stopFlag = true | ||||
|       return | ||||
| @ -170,7 +171,7 @@ struct Index { | ||||
|       }) | ||||
|       this.checkListCopy = JSON.parse(JSON.stringify(this.checkList)) | ||||
|     }).catch((error: BusinessError) => { | ||||
|       console.log('error12error' + error) | ||||
|       dConsole.log('error12error' + error) | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
| @ -315,13 +316,13 @@ struct Index { | ||||
|   initfackCheck(index: number) { | ||||
|     const that = this | ||||
|     setTimeout(() => { | ||||
|       console.log('indexindex', index) | ||||
|       dConsole.log('indexindex', index) | ||||
|       if (index >= 3) { | ||||
|         this.getCheckList() | ||||
|         return | ||||
|       } | ||||
| 
 | ||||
|       console.log('this.index', index,) | ||||
|       dConsole.log('this.index', index,) | ||||
|       that.passArray[index] = true | ||||
|       if (index == 2) { | ||||
|         // let flag = false; | ||||
| @ -608,7 +609,7 @@ struct Index { | ||||
|               .backgroundImageSize({ width: '100%', height: '100%' }) | ||||
|               .margin({ bottom: 10 * this.ratio }) | ||||
|               .onClick(() => { | ||||
|                 console.log('xhsx') | ||||
|                 dConsole.log('xhsx') | ||||
|                 this.xhxs() | ||||
|               }) | ||||
|               .zIndex(11) | ||||
|  | ||||
| @ -21,6 +21,7 @@ import { DifferentialAndSignal } from '../utils/business/DifferentialAndSignalWo | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| import dayTs from '../utils/Date'; | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| struct Index { | ||||
|   @State url: string = '' | ||||
| @ -81,7 +82,7 @@ struct Index { | ||||
|   } | ||||
| 
 | ||||
|   async onPageShow(): Promise<void> { | ||||
|     dConsole.log("首页 onPageShow") | ||||
|     dConsole.log("首页 onPageShow2") | ||||
|     await UseAuth(this.context) | ||||
|     if (!this.isPlay) { | ||||
|       this.avPlayer.playAudio(['welcome.wav']) | ||||
|  | ||||
| @ -20,6 +20,7 @@ import systemTime from '@ohos.systemTime'; | ||||
| import { VideoConfigData } from '../../mock'; | ||||
| import FileUtils from '../../utils/FileUtils'; | ||||
| import { FileHelper } from '../../utils/FileHelp'; | ||||
| import { dConsole } from '../../utils/LogWorker'; | ||||
| 
 | ||||
| //获取设备信息 | ||||
| export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<string> { | ||||
| @ -34,7 +35,7 @@ export async function GetDeviceInfo(context: common.UIAbilityContext): Promise<s | ||||
|       resolve("") | ||||
|     } else { | ||||
|       const fileData: CarConfigurationParamsType = JSON.parse(data) | ||||
|       console.log("获取设备号", fileData.deviceName) | ||||
|       dConsole.log("获取设备号", fileData.deviceName) | ||||
|       AppStorage.setOrCreate('deviceNo', fileData.deviceName) | ||||
|       resolve(fileData.deviceName) | ||||
|     } | ||||
| @ -49,11 +50,11 @@ export async function GetCarInfo(): Promise<CarInfoType> { | ||||
|     deviceNo: AppStorage.get<string>('deviceNo') || "" | ||||
|   }; | ||||
|   let res: ApiResponseType = await obtainCarExamInfo(params) | ||||
|   console.log("获取到的车辆信息", res) | ||||
|   dConsole.log("获取到的车辆信息", res) | ||||
|   if (res.obtainCarExamInfoRsp && res.obtainCarExamInfoRsp.body) { | ||||
|     const carInfo: ObtainCarExamInfoRspBody = res?.obtainCarExamInfoRsp?.body! | ||||
|     carInfo.plateNo = decodeURIComponent(carInfo.plateNo) | ||||
|     console.log("Worker received message car", JSON.stringify(carInfo)) | ||||
|     dConsole.log("Worker received message car", JSON.stringify(carInfo)) | ||||
|     AppStorage.setOrCreate('carInfo', carInfo) | ||||
|     return carInfo | ||||
|   } | ||||
| @ -78,7 +79,7 @@ export async function UseAuth(context: common.UIAbilityContext): Promise<boolean | ||||
|         } | ||||
|       } | ||||
|     }).catch((err: BusinessError) => { | ||||
|       console.log("获取权限失败", JSON.stringify(err)) | ||||
|       dConsole.log("获取权限失败", JSON.stringify(err)) | ||||
|       reject(false) | ||||
|     }) | ||||
|   }) | ||||
| @ -103,12 +104,12 @@ export async function SetCurrentTime(): Promise<void> { | ||||
|   if (currentTime) { | ||||
|     times = new Date(currentTime).getTime(); | ||||
|   } else { | ||||
|     console.error("currentTime is undefined"); | ||||
|     dConsole.error("currentTime is undefined"); | ||||
|   } | ||||
|   try { | ||||
|     await systemTime.setTime(times) | ||||
|   } catch (error) { | ||||
|     console.log('时间同步失败', error) | ||||
|     dConsole.log('时间同步失败', error) | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -3,6 +3,7 @@ import { TestRealExam } from '../../mock'; | ||||
| import { CarInfoType, ExtendType, Gps, LANE, PLCType, Radar, Vision } from '../../model'; | ||||
| import { ArrayToByteArray, NumberToByteArray } from '../../utils/Common'; | ||||
| import dayTs from '../../utils/Date'; | ||||
| import { dConsole } from '../../utils/LogWorker'; | ||||
| 
 | ||||
| 
 | ||||
| // 中心信号转换 | ||||
| @ -105,7 +106,7 @@ export function getKmProjectVoice( | ||||
|   const param544Str: number[] = (Reflect.get(judgeConfig, '544')?.split(',')) || [] | ||||
|   const param405Str: number = Reflect.get(judgeConfig, '405') || 0; | ||||
| 
 | ||||
|   console.info('surenjun => param544Str.length', param544Str.length) | ||||
|   dConsole.info('surenjun => param544Str.length', param544Str.length) | ||||
| 
 | ||||
|   const num: number = lane?.num | ||||
|   const count: number = lane?.count | ||||
| @ -437,7 +438,7 @@ export function UploadRegulatoryCodeConversion( | ||||
|       break; | ||||
|   } | ||||
|   //TODO 兼容新监管code | ||||
|   // console.info('surenjun showToast') | ||||
|   // dConsole.info('surenjun showToast') | ||||
|   // promptAction.showToast({ | ||||
|   //   message: decodeURIComponent(toast), | ||||
|   //   duration: 4000 | ||||
| @ -679,7 +680,7 @@ export const senorToWXDataStr = async (tempData: PLCType) => { | ||||
|     '0xFFFFFFF' | ||||
|   ] | ||||
|   return wuXiData.map(d => (d + '')).join(','); | ||||
|   // console.log('wuXiData',wuXiData.join(',')); | ||||
|   // dConsole.log('wuXiData',wuXiData.join(',')); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -7,6 +7,7 @@ import { ApiResponseType, DeviceParamType } from '../model' | ||||
| import dayTs from '../utils/Date' | ||||
| import FileUtils from '../utils/FileUtils' | ||||
| import Prompt from '@system.prompt' | ||||
| import { dConsole } from '../utils/LogWorker' | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| @ -22,11 +23,11 @@ struct Index { | ||||
|   private context = getContext(this) as common.UIAbilityContext; | ||||
| 
 | ||||
|   onPageShow() { | ||||
|     console.log('createDeviceManagerstart') | ||||
|     dConsole.log('createDeviceManagerstart') | ||||
|     try { | ||||
|       deviceManager.createDeviceManager('com.oh.dts', (error: string, value: deviceManager.DeviceManager) => { | ||||
|         if (error) { | ||||
|           console.error('createDeviceManager failed.'); | ||||
|           dConsole.error('createDeviceManager failed.'); | ||||
|           return; | ||||
|         } | ||||
|         this.deviceName = value.getLocalDeviceInfoSync().deviceName | ||||
| @ -36,7 +37,7 @@ struct Index { | ||||
|       }); | ||||
| 
 | ||||
|     } catch (error) { | ||||
|       console.log('createDeviceManagererror', error) | ||||
|       dConsole.log('createDeviceManagererror', error) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  | ||||
| @ -6,6 +6,7 @@ import { GlobalConfig, TerminalInfoTag } from '../config'; | ||||
| import ethernet from '@ohos.net.ethernet'; | ||||
| import { BusinessError } from '@ohos.base'; | ||||
| import Prompt from '@system.prompt'; | ||||
| import { dConsole } from '../utils/LogWorker'; | ||||
| 
 | ||||
| @Entry | ||||
| @Component | ||||
| @ -197,6 +198,7 @@ struct TerminalInfoPage { | ||||
|               console.log(TerminalInfoTag, "保存配置", JSON.stringify(this.config)) | ||||
|               AppStorage.setOrCreate<EnvironmentConfigurationType>("EnvironmentConfiguration", this.config) | ||||
|               this.fileUtil.addFile(GlobalConfig.commonFileWriteAddress + '/config/ipConfig.txt', JSON.stringify(this.config)) | ||||
|               dConsole.init(this.config.isOpenLog) | ||||
|               ethernet.setIfaceConfig("eth0", { | ||||
|                 mode: ethernet.IPSetMode.STATIC, | ||||
|                 ipAddr: this.config.udplocalIp, | ||||
|  | ||||
| @ -7,12 +7,16 @@ const MAX_MESSAGE_LENGTH = 300; | ||||
| const LOG_CHUNK_PREFIX = '[切割消息序号'; | ||||
| 
 | ||||
| class logWorker { | ||||
|   private static instance: logWorker | null = null; | ||||
|   private workerInstance = new worker.ThreadWorker("entry/ets/workers/Log.ets") | ||||
|   // 是否开启日志 1开启 | ||||
|   private isLogEnabled: string = "0"; | ||||
| 
 | ||||
|   constructor() { | ||||
|     console.log("当前环境配置单例模式") | ||||
|     if (logWorker.instance) { | ||||
|       return logWorker.instance; | ||||
|     } | ||||
|     logWorker.instance = this; | ||||
|   } | ||||
| 
 | ||||
|   // 正常日志 | ||||
|  | ||||
| @ -7,6 +7,7 @@ import dayTs from '../utils/Date'; | ||||
| const workerPort: ThreadWorkerGlobalScope = worker.workerPort; | ||||
| 
 | ||||
| workerPort.onmessage = (e: MessageEvents) => { | ||||
|   console.log("日志系统worker收到消息") | ||||
|   // 日志文件目录 | ||||
|   let logPaths: LogPathType = { | ||||
|     log: `${GlobalConfig.commonFileWriteAddress}/logs/${dayTs().format("YYYY_MM_DD")}/log/log.log`, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user