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