func log_output(str_content string) {
fd,_:=os.OpenFile("a.txt",os.O_RDWR|os.O_CREATE|os.O_APPEND,0644)
fd_time:=time.Now().Format("2006-01-02 15:04:05");
fd_content:=strings.Join([]string{"======",fd_time,"=====",str_content,"\n"},"")
buf:=[]byte(fd_content)
fd.Write(buf)
fd.Close()
}
golang调试日志写到txt
最新推荐文章于 2025-04-30 22:38:42 发布
本文介绍了一个使用Go语言实现的日志记录函数,该函数能够将包含时间戳的日志信息追加到指定文件中,适用于各种日志记录需求。
321

被折叠的 条评论
为什么被折叠?



