Browse Source

添加日志

master
zhaohe 2 years ago
parent
commit
e9697eac06
  1. 7
      README.md
  2. 33
      boardinit.sh
  3. 42
      env/spd_logger_cfg.json
  4. 1
      src/service/can_service.cpp

7
README.md

@ -21,12 +21,11 @@ TOOD:
## 编译RK3328
```bash
# 板子初始化
./sh/boardinit.sh \
--device_info "DEVICE_ID=iflytop_demo_device" \
./boardinit.sh \
--device_info "DEVICE_ID=a8000_1" \
--device_info "FRP_SERVER_ADDR=47.92.195.73" \
--device_info "STARTUP_DEFAULT_URL=127.0.0.1:80" \
--fixmac true \
--ip 192.168.1.191
--ip 192.168.1.164
# 初始化环境

33
boardinit.sh

@ -24,6 +24,19 @@ function fixmac() {
echo ""
}
function create_rc_local() {
#!/bin/bash
echo "#!/bin/bash" >/etc/rc.local
echo "cd /app/" >>/etc/rc.local
echo "./startup.sh" >>/etc/rc.local
chmod +x /etc/rc.local
echo "++++++++++ create /etc/rc.local ++++++++++"
cat /etc/rc.local
echo ""
}
function generate_device_info() {
#
# /etc/device_info.env
@ -32,16 +45,6 @@ function generate_device_info() {
#
# 判断DEVICE_ID和FRP_SERVER_ADDR是否为空
if [ -z "$DEVICE_ID" ]; then
echo "DEVICE_ID is empty"
exit 1
fi
if [ -z "$FTP_SERVER_ADDR" ]; then
echo "FTP_SERVER_ADDR is empty"
exit 1
fi
echo "" >/etc/device_info.env
for item in "${DEVICE_INFO[@]}"; do
echo "$item" >>/etc/device_info.env
@ -99,7 +102,6 @@ function update_frpc_config() {
set -e
FIX_MAC=""
PARAMETERS=$@
DEVICE_INFO=[]
EXEC_IN_BOARD=false
for i in "$@"; do
@ -130,11 +132,10 @@ for i in "$@"; do
esac
done
## 如果EXEC_IN_BOARD为空,则将自身拷贝到目标设备再次执行
if [ "$EXEC_IN_BOARD" != "true" ]; then
echo "scp ./sh/boardinit.sh root@$IP:/tmp"
scp ./sh/boardinit.sh root@$IP:/tmp
scp ./boardinit.sh root@$IP:/tmp
echo "ssh root@$IP \"/tmp/boardinit.sh $PARAMETERS --exec_in_board true\""
echo ""
ssh root@$IP "/tmp/boardinit.sh $PARAMETERS --exec_in_board true"
@ -146,7 +147,7 @@ if [ "$FIX_MAC" == "true" ]; then
fixmac eth0
fi
update_frpc_config
# update_frpc_config
generate_device_info
#
@ -156,3 +157,7 @@ generate_device_info
# 2. apt-get安装一些依赖包
# 3. 修复一些当前文件系统的部分BUG
#
create_rc_local
apt-get update
apt install psmisc

42
env/spd_logger_cfg.json

@ -0,0 +1,42 @@
[
{
"name": "infologger",
"type": "daily_file_sink_mt",
"filename": "logs/infolog.log",
"max_files": 30,
"rotate_on_open": true,
"level" : 2
},
{
"name": "debuglogger",
"type": "daily_file_sink_mt",
"filename": "logs/debuglog.log",
"max_files": 10,
"rotate_on_open": true,
"level": 0
},
{
"name": "terminal",
"type": "stdout_color_sink_mt",
"level": 0
},
{
"name": "IflytopWSService",
"level": 0
},
{
"name": "SocketCan",
"level": 0
},
{
"name": "root",
"type": "logger",
"level": 2,
"sinks": [
"terminal",
"debuglogger",
"infologger"
]
}
]

1
src/service/can_service.cpp

@ -56,6 +56,7 @@ SocketCan::SocketCanError_t CanService::sendPacketToIflytopCanSubDevice(shared_p
logger->error("createSocketCanFrame fail,{}", icps_packet->toString());
return SocketCan::kErrorFrameFormat;
}
logger->debug("tx:{}",icps_packet->toString());
return m_socketCan->sendFrame(frame, overtime_ms);
// if (erro != SocketCan::SocketCanError_t::kSuccess) {
// logger->error("sendFrame fail,{}", SocketCan::SocketCanError_t2Str(erro));

Loading…
Cancel
Save