jpulog.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: LGPL-2.1 OR BSD-3-Clause */
  2. /*
  3. * Copyright (c) 2018, Chips&Media
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  19. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef _LOG_H_
  27. #define _LOG_H_
  28. #ifdef USE_FEEDING_METHOD_BUFFER
  29. #include "codaj12/jpuapi/jputypes.h"
  30. #else
  31. #include "jputypes.h"
  32. #endif
  33. enum
  34. {
  35. ERR=0,
  36. WARN,
  37. TRACE,
  38. INFO,
  39. DEBUG,
  40. MAX_LOG_LEVEL
  41. };
  42. enum
  43. {
  44. LOG_HAS_DAY_NAME = 1, /**< Include day name [default: no] */
  45. LOG_HAS_YEAR = 2, /**< Include year digit [no] */
  46. LOG_HAS_MONTH = 4, /**< Include month [no] */
  47. LOG_HAS_DAY_OF_MON = 8, /**< Include day of month [no] */
  48. LOG_HAS_TIME = 16, /**< Include time [yes] */
  49. LOG_HAS_MICRO_SEC = 32, /**< Include microseconds [yes] */
  50. LOG_HAS_FILE = 64, /**< Include sender in the log [yes] */
  51. LOG_HAS_NEWLINE = 128, /**< Terminate each call with newline [yes] */
  52. LOG_HAS_CR = 256, /**< Include carriage return [no] */
  53. LOG_HAS_SPACE = 512, /**< Include two spaces before log [yes] */
  54. LOG_HAS_COLOR = 1024, /**< Colorize logs [yes on win32] */
  55. LOG_HAS_LEVEL_TEXT = 2048 /**< Include level text string [no] */
  56. };
  57. enum {
  58. TERM_COLOR_R = 2, /**< Red */
  59. TERM_COLOR_G = 4, /**< Green */
  60. TERM_COLOR_B = 1, /**< Blue. */
  61. TERM_COLOR_BRIGHT = 8 /**< Bright mask. */
  62. };
  63. #define MAX_PRINT_LENGTH 512
  64. #ifdef ANDROID
  65. #include <utils/Log.h>
  66. #undef LOG_NDEBUG
  67. #define LOG_NDEBUG 0
  68. #undef LOG_TAG
  69. #define LOG_TAG "JPUAPI"
  70. #endif
  71. #define JLOG LogMsg
  72. #define LOG_ENABLE_FILE SetLogDecor(GetLogDecor()|LOG_HAS_FILE);
  73. #if defined (__cplusplus)
  74. extern "C" {
  75. #endif
  76. BOOL InitLog(const char* path);
  77. void DeInitLog();
  78. void SetMaxLogLevel(int level);
  79. int GetMaxLogLevel();
  80. void SetLogColor(int level, int color);
  81. int GetLogColor(int level);
  82. void SetLogDecor(int decor);
  83. int GetLogDecor();
  84. void LogMsg(int level, const char *format, ...);
  85. void timer_start();
  86. void timer_stop();
  87. double timer_elapsed_us();
  88. double timer_elapsed_ms();
  89. int timer_is_valid();
  90. double timer_frequency();
  91. #if defined (__cplusplus)
  92. }
  93. #endif
  94. #endif //#ifndef _LOG_H_