elog_file.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * This file is part of the EasyLogger Library.
  3. *
  4. * Copyright (c) 2015-2019, Qintl, <qintl_linux@163.com>
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining
  7. * a copy of this software and associated documentation files (the
  8. * 'Software'), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be
  15. * included in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  18. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  21. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. * Function: It is an head file for file log plugin. You can see all be called functions.
  26. * Created on: 2019-01-05
  27. */
  28. #ifndef __ELOG_FILE__H__
  29. #define __ELOG_FILE__H__
  30. #include <stdio.h>
  31. #include <elog.h>
  32. #include <elog_file_cfg.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* EasyLogger file log plugin's software version number */
  37. #define ELOG_FILE_SW_VERSION "V1.0.0"
  38. #ifdef linux
  39. #define likely(x) __builtin_expect(!!(x), 1)
  40. #define unlikely(x) __builtin_expect(!!(x), 0)
  41. #else
  42. #define likely(x) (x)
  43. #define unlikely(x) (x)
  44. #endif
  45. typedef struct {
  46. char *name; /* file name */
  47. size_t max_size; /* file max size */
  48. int max_rotate; /* max rotate file count */
  49. } ElogFileCfg;
  50. /* elog_file.c */
  51. int elog_file_init(void);
  52. void elog_file_write(const char *log, size_t size);
  53. void elog_file_config(ElogFileCfg *cfg);
  54. void elog_file_deinit(void);
  55. /* elog_file_port.c */
  56. int elog_file_port_init(void);
  57. void elog_file_port_lock(void);
  58. void elog_file_port_unlock(void);
  59. void elog_file_port_deinit(void);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif