log_producer_client.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef LOG_SDK_LOG_PRODUCER_CLIENT_H
  2. #define LOG_SDK_LOG_PRODUCER_CLIENT_H
  3. #include "log_define.h"
  4. #include "log_producer_config.h"
  5. LOG_CPP_START
  6. /**
  7. * log producer client
  8. */
  9. typedef struct _log_producer_client
  10. {
  11. volatile int32_t valid_flag;
  12. int32_t log_level;
  13. void* private_data;
  14. }log_producer_client;
  15. /**
  16. * init log producer environment
  17. * @note should been called before create any log producer client
  18. * @note no multi thread safe
  19. * @return OK if success, others the error code
  20. */
  21. LOG_EXPORT log_producer_result log_producer_env_init();
  22. /**
  23. * destroy log producer environment
  24. * @note should been called after all log producer clients destroyed
  25. * @note no multi thread safe
  26. */
  27. LOG_EXPORT void log_producer_env_destroy();
  28. /**
  29. * create log producer client with a producer config
  30. * @param config log_producer_config
  31. * @param send_done_function this function will be called when send done(can be ok or fail), set to NULL if you don't care about it
  32. * @param user_param this param will send back in send_done_function
  33. * @return producer client ptr, NULL if create fail
  34. */
  35. LOG_EXPORT log_producer_client* create_log_producer_client(log_producer_config* config, on_log_producer_send_done_function send_done_function, void* user_param);
  36. /**
  37. * destroy log producer client
  38. * @param client
  39. * @note no multi thread safe
  40. */
  41. LOG_EXPORT void destroy_log_producer_client(log_producer_client* client);
  42. /**
  43. * add log天眼
  44. * @param client
  45. * @param log
  46. * @param flush
  47. * @return ok if success, LOG_PRODUCER_DROP_ERROR if buffer is full, LOG_PRODUCER_INVALID if client is destroyed, LOG_PRODUCER_PERSISTENT_ERROR is save binlog failed.
  48. */
  49. LOG_EXPORT log_producer_result log_producer_client_add_log(log_producer_client* client, log_item* log, int flush, long record_time);
  50. /**
  51. * add log天眼
  52. * */
  53. LOG_EXPORT log_producer_result log_producer_client_add_beidou_log(log_producer_client* client, beidou_log_item* log, int flush);
  54. LOG_EXPORT void log_producer_set_testLogMode();
  55. LOG_EXPORT int log_producer_sendTestLog_loki(const char* app, const char* env, const char* body);
  56. LOG_CPP_END
  57. #endif