flog.h 794 B

1234567891011121314151617181920212223
  1. #ifndef __FLOG_H__
  2. #define __FLOG_H__
  3. #include <stddef.h>
  4. /* Fault log. Writes timestamped lines to a file (thread-safe). The file is
  5. * periodically truncated (by time and/or by size). */
  6. int flog_init(const char *path, long rotate_ms, long max_bytes);
  7. void flog_shutdown(void);
  8. int flog_enabled(void);
  9. /* Append one fault entry: "[YYYY-MM-DD HH:MM:SS] msg" */
  10. void flog(const char *fmt, ...);
  11. /* Rate-limited flog: same 'cat' logs at most once per min_interval_ms.
  12. * Replaces high-frequency call sites (commit/compose/decode failures). */
  13. void flog_throttled(const char *cat, long min_interval_ms, const char *fmt, ...);
  14. /* Call periodically (e.g. once per main-loop tick): truncates the log when
  15. * rotate_ms elapsed or file exceeds max_bytes. */
  16. void flog_rotate_check(void);
  17. #endif