rotater.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * This file is part of the zlog Library.
  3. *
  4. * Copyright (C) 2011 by Hardy Simpson <HardySimpson1984@gmail.com>
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING in base directory.
  7. */
  8. #ifndef __zlog_rotater_h
  9. #define __zlog_rotater_h
  10. #include "zc_defs.h"
  11. typedef struct zlog_rotater_s {
  12. pthread_mutex_t lock_mutex;
  13. char *lock_file;
  14. int lock_fd;
  15. /* single-use members */
  16. char *base_path; /* aa.log */
  17. char *archive_path; /* aa.#5i.log */
  18. char glob_path[MAXLEN_PATH + 1]; /* aa.*.log */
  19. size_t num_start_len; /* 3, offset to glob_path */
  20. size_t num_end_len; /* 6, offset to glob_path */
  21. int num_width; /* 5 */
  22. int mv_type; /* ROLLING or SEQUENCE */
  23. int max_count;
  24. zc_arraylist_t *files;
  25. } zlog_rotater_t;
  26. zlog_rotater_t *zlog_rotater_new(char *lock_file);
  27. void zlog_rotater_del(zlog_rotater_t *a_rotater);
  28. /*
  29. * return
  30. * -1 fail
  31. * 0 no rotate, or rotate and success
  32. */
  33. int zlog_rotater_rotate(zlog_rotater_t *a_rotater,
  34. char *base_path, size_t msg_len,
  35. char *archive_path, long archive_max_size, int archive_max_count);
  36. void zlog_rotater_profile(zlog_rotater_t *a_rotater, int flag);
  37. #endif