ged_log.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2015 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __GED_LOG_H__
  14. #define __GED_LOG_H__
  15. #include "ged_type.h"
  16. #if defined(__GNUC__)
  17. #define GED_LOG_BUF_FORMAT_PRINTF(x,y) __attribute__((format(printf,x,y)))
  18. #else
  19. #define GED_LOG_BUF_FORMAT_PRINTF(x,y)
  20. #endif
  21. #define GED_LOG_BUF_NAME_LENGTH 64
  22. #define GED_LOG_BUF_NODE_NAME_LENGTH 64
  23. typedef enum GED_LOG_BUF_TYPE_TAG
  24. {
  25. GED_LOG_BUF_TYPE_RINGBUFFER,
  26. GED_LOG_BUF_TYPE_QUEUEBUFFER,
  27. GED_LOG_BUF_TYPE_QUEUEBUFFER_AUTO_INCREASE,
  28. } GED_LOG_BUF_TYPE;
  29. GED_LOG_BUF_HANDLE ged_log_buf_alloc(int i32MaxLineCount, int i32MaxBufferSizeByte, GED_LOG_BUF_TYPE eType, const char* pszName, const char* pszNodeName);
  30. GED_ERROR ged_log_buf_resize(GED_LOG_BUF_HANDLE hLogBuf, int i32NewMaxLineCount, int i32NewMaxBufferSizeByte);
  31. GED_ERROR ged_log_buf_ignore_lines(GED_LOG_BUF_HANDLE hLogBuf, int i32LineCount);
  32. GED_ERROR ged_log_buf_reset(GED_LOG_BUF_HANDLE hLogBuf);
  33. void ged_log_buf_free(GED_LOG_BUF_HANDLE hLogBuf);
  34. /* query by Name, return NULL if not found */
  35. GED_LOG_BUF_HANDLE ged_log_buf_get(const char* pszName);
  36. /* register a pointer, it will be set after the corresponding buffer is allcated. */
  37. int ged_log_buf_get_early(const char* pszName, GED_LOG_BUF_HANDLE *callback_set_handle);
  38. GED_ERROR ged_log_buf_print(GED_LOG_BUF_HANDLE hLogBuf, const char *fmt, ...) GED_LOG_BUF_FORMAT_PRINTF(2,3);
  39. enum
  40. {
  41. /* bit 0~7 reserved for internal used */
  42. GED_RESVERED = 0xFF,
  43. /* log with a prefix kernel time */
  44. GED_LOG_ATTR_TIME = 0x100,
  45. /* log with a prefix user time, pid, tid */
  46. GED_LOG_ATTR_TIME_TPT = 0x200,
  47. };
  48. GED_ERROR ged_log_buf_print2(GED_LOG_BUF_HANDLE hLogBuf, int i32LogAttrs, const char *fmt, ...) GED_LOG_BUF_FORMAT_PRINTF(3,4);
  49. GED_ERROR ged_log_system_init(void);
  50. void ged_log_system_exit(void);
  51. int ged_log_buf_write(GED_LOG_BUF_HANDLE hLogBuf, const char __user *pszBuffer, int i32Count);
  52. void ged_log_trace_begin(char *name);
  53. void ged_log_trace_end(void);
  54. void ged_log_trace_counter(char *name, int count);
  55. #endif