logging.cpp

来自「一个非常好的人工智能开发工具开源软件」· C++ 代码 · 共 50 行

CPP
50
字号
/*** *** See the file "L2_RTI_EO1/disclaimers-and-notices-L2.txt" for  *** information on usage and redistribution of this file,  *** and for a DISCLAIMER OF ALL WARRANTIES. ***/#include "Logging.hpp"#include <stdio.h>  // for errno#include <string.h>#include "ExceptionAction.hpp"// Construct a LOG_MSG and enqueue itvoid Logging::log(logType type, const char *message) {  if (strlen(message) < MAX_MSG_LENGTH) { // the message fits; send it    LOG_MSG output;    output.msgType = type;    strncpy(output.msg, message, MAX_MSG_LENGTH);    sendToDisk(output);  } else {    ExceptionAction::logMessageTooLong(message);  }}// Enqueue the message to the telemetry queuevoid Logging::sendToTelemetry(const L2ResultMsg& l2resultMsg) {  if (msgQSend(RTI_TO_SCL_MQID,	       (char*)&l2resultMsg,	       sizeof(L2ResultMsg),	       WAIT_FOREVER,	       MSG_PRI_NORMAL) != 0) {    ExceptionAction::sendFailure(ExceptionAction::SND_LOGGING,				 ExceptionAction::RCV_TELEMETRY,				 errno);  }}// Enqueue the message to the logging queuevoid Logging::sendToDisk(const LOG_MSG& logMsg) {  if (msgQSend(L2RTI_TO_LOG_MQID,	       (char*)&logMsg,	       sizeof(LOG_MSG),	       WAIT_FOREVER,	       MSG_PRI_NORMAL) != 0) {    ExceptionAction::sendFailure(ExceptionAction::SND_LOGGING,				 ExceptionAction::RCV_LOG_HANDLER,				 errno);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?