Open-source solutions for creating a cyclical logfile?

我是研究僧i 提交于 2019-12-07 05:04:07

问题


if (!wheel) { wheel = new Wheel(); }   // or some such

My google goggles aren't working too well today. I figured this one must have been coded a gazillion times already and was looking for some FOSS code, but couldn't find any.

Before I reinvent the spherical axle-surrounding device, can anyone point me at a URL?

I am coding in C for an embedded system (Atmel UC3), but that shouldn't make any difference, just explain why I need a cyclical logfile (because of limited storage).

I want to log events to a file on an SD card and when the reaches a certain size I want to start writing again at the start. Any URLs for that? (fixed entry size is ok; otherwise it might get nasty on wraparound).

Thanks a 1,000,000 in advance!


回答1:


Sourceforge has a project called Cyclic Logs which may be what you need.

If not, it's not the hardest thing to implement. Just treat it like a normal cyclic memory space. But instead of having it be resident in memory have it reside on the disk.

( maintain a pointer to the head of the log and the end of the log ( increment as needed ))

Store those as headers to the log or as another flat file.



来源:https://stackoverflow.com/questions/9075532/open-source-solutions-for-creating-a-cyclical-logfile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!