当前位置:网站首页>Shell 日志与打印输出
Shell 日志与打印输出
2022-06-23 00:35:00 【ghostwritten】
Shell 日志与打印输出
良好的 shell 脚本从记录日志内容,规范日志格式开始。
1
write_log()
{
LOG_FILE=$LOGDIR/cckiller_$(date +%Y-%m-%d).log
logout=""
for((i=2;i<=$#;i++)); do
j=${
!i}
logout="${logout} $j "
done
if [[ $LOG_LEVEL == "INFO" ]] && [[ "$1" == "INFO" ]];then
echo "[`date "+%Y-%m-%d %H:%M:%S"`][$1]: ${logout}" | tee -ai $LOG_FILE
elif [[ $LOG_LEVEL == "DEBUG" ]];then
echo "[`date "+%Y-%m-%d %H:%M:%S"`][$1]: ${logout}" | tee -ai $LOG_FILE
else
echo "[`date "+%Y-%m-%d %H:%M:%S"`][$1]: ${logout}"
fi
}
边栏推荐
- 在一条DML语句中插入/更新/删除/获取几百万行数据,你会特别注意什么?
- Kunlun distributed database sequence function and its implementation mechanism
- Is it safe for CICC securities to open an account? What is its relationship with CICC?
- 包管理工具--NPM、--CNPM、 --Yarn、 --CYarn
- 外包干了四年,感觉废了..
- Kunlundb query optimization (III) sort push down
- 掘地三尺搞定 Redis 与 MySQL 数据一致性问题
- Typecho仿卢松松博客主题模板/科技资讯博客主题模板
- #yyds干货盘点#尾递归比递归好在哪儿
- LeetCode刷题——715. Range 模块
猜你喜欢

初学者如何快速入门深度学习?

EasyCVR使用RTMP推流时不显示界面如何解决?

New paradigm of semantic segmentation! Structtoken: Rethinking the per pixel classification paradigm

语义分割新范式!StructToken:对per-pixel 分类范式的重新思考

数据库每日一题---第20天:按日期分组销售产品

再立云计算“昆仑”,联想混合云Lenovo xCloud凭什么?

數據庫中數據的儲存結構和方式是什麼?

ROS2暑期学校 ROS2 Summer School 2022-转-

Introduction to the use of opencvsharp (C openCV) wechat QRcode decoding function (with source code attached)
#yyds干货盘点#尾递归比递归好在哪儿
随机推荐
Database daily question - day 20: selling products by date
Several abnormal scenarios of things system
a++,++a,!,~
华为云如何实现实时音视频全球低时延网络架构【上】
Some thoughts about the technology of test / development programmers are very advanced, and they can't go on
EasyCVR硬件盒子如何设置断电自启动
Kunlundb backup and recovery
[go] go mod mode, package 12import/add is not in goroot
使用GetX构建更优雅的Flutter页面结构
【GO】go多态
TIDB监控升级解决panic的漫漫探索之路
What is the storage structure and mode of data in the database?
声网多人视频录制与合成支持掉线再录制 | 掘金技术征文
图神经网络有哪些用途和应用?
昆仑分布式数据库Sequence功能及其实现机制
包管理工具--NPM、--CNPM、 --Yarn、 --CYarn
How to set the power-off auto start of easycvr hardware box
OLAP - Druid introduction
MGRE环境下的OSPF实验
股票在哪个平台买比较安全呢?