log_upload.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Tencent is pleased to support the open source community by making IoT Hub
  3. available.
  4. * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
  5. * Licensed under the MIT License (the "License"); you may not use this file
  6. except in
  7. * compliance with the License. You may obtain a copy of the License at
  8. * http://opensource.org/licenses/MIT
  9. * Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is
  11. * distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  12. KIND,
  13. * either express or implied. See the License for the specific language
  14. governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef QCLOUD_IOT_LOG_UPLOAD_H_
  19. #define QCLOUD_IOT_LOG_UPLOAD_H_
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #include "qcloud_iot_export_log.h"
  24. /**
  25. * @brief init the log upload functions
  26. *
  27. * @param init_params
  28. * @return QCLOUD_RET_SUCCESS when success
  29. */
  30. int init_log_uploader(LogUploadInitParams *init_params);
  31. /**
  32. * @brief free log buffer and finish the log upload functions
  33. */
  34. void fini_log_uploader(void);
  35. /**
  36. * @brief check if log uploader is init or not
  37. */
  38. bool is_log_uploader_init(void);
  39. /**
  40. * @brief append one log item to upload buffer
  41. *
  42. * @param log_content
  43. * @param log_size
  44. * @return 0 when success, -1 when fail
  45. */
  46. int append_to_upload_buffer(const char *log_content, size_t log_size);
  47. /**
  48. * @brief clear current upload buffer
  49. *
  50. * @return
  51. */
  52. void clear_upload_buffer(void);
  53. /**
  54. * @brief do one upload to server
  55. *
  56. * @param force_upload if true, it will do upload right away, otherwise it will
  57. * check log_level, buffer left and upload interval
  58. * @return QCLOUD_RET_SUCCESS when success or no log to upload or timer is not
  59. * expired
  60. */
  61. int do_log_upload(bool force_upload);
  62. /**
  63. * @brief set the log mqtt client to get system time
  64. *
  65. * @param client
  66. */
  67. void set_log_mqtt_client(void *client);
  68. /**
  69. * @brief set if only do log upload when communication error with IoT Hub
  70. *
  71. * @param value if true, only do log upload when communication error with IoT
  72. * Hub
  73. */
  74. void set_log_upload_in_comm_err(bool value);
  75. /**
  76. * @brief get current upload log_level from IoT Hub
  77. *
  78. * @param log_level
  79. * @return QCLOUD_RET_SUCCESS when success
  80. */
  81. int qcloud_get_log_level(int *log_level);
  82. /**
  83. * @brief get the log mqtt client
  84. *
  85. * @return log mqtt client
  86. */
  87. void *get_log_mqtt_client(void);
  88. /**
  89. * @brief get the device info of log client
  90. *
  91. * @return device info pointer of log client
  92. */
  93. void * get_log_dev_info(void);
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif // QCLOUD_IOT_LOG_UPLOAD_H_