You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

268 lines
7.4KB

  1. /*
  2. * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * Libav is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with Libav; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVUTIL_LOG_H
  21. #define AVUTIL_LOG_H
  22. #include <stdarg.h>
  23. #include "avutil.h"
  24. #include "attributes.h"
  25. #include "version.h"
  26. /**
  27. * Describe the class of an AVClass context structure. That is an
  28. * arbitrary struct of which the first field is a pointer to an
  29. * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
  30. */
  31. typedef struct AVClass {
  32. /**
  33. * The name of the class; usually it is the same name as the
  34. * context structure type to which the AVClass is associated.
  35. */
  36. const char* class_name;
  37. /**
  38. * A pointer to a function which returns the name of a context
  39. * instance ctx associated with the class.
  40. */
  41. const char* (*item_name)(void* ctx);
  42. /**
  43. * a pointer to the first option specified in the class if any or NULL
  44. *
  45. * @see av_set_default_options()
  46. */
  47. const struct AVOption *option;
  48. /**
  49. * LIBAVUTIL_VERSION with which this structure was created.
  50. * This is used to allow fields to be added without requiring major
  51. * version bumps everywhere.
  52. */
  53. int version;
  54. /**
  55. * Offset in the structure where log_level_offset is stored.
  56. * 0 means there is no such variable
  57. */
  58. int log_level_offset_offset;
  59. /**
  60. * Offset in the structure where a pointer to the parent context for
  61. * logging is stored. For example a decoder could pass its AVCodecContext
  62. * to eval as such a parent context, which an av_log() implementation
  63. * could then leverage to display the parent context.
  64. * The offset can be NULL.
  65. */
  66. int parent_log_context_offset;
  67. /**
  68. * Return next AVOptions-enabled child or NULL
  69. */
  70. void* (*child_next)(void *obj, void *prev);
  71. /**
  72. * Return an AVClass corresponding to the next potential
  73. * AVOptions-enabled child.
  74. *
  75. * The difference between child_next and this is that
  76. * child_next iterates over _already existing_ objects, while
  77. * child_class_next iterates over _all possible_ children.
  78. */
  79. const struct AVClass* (*child_class_next)(const struct AVClass *prev);
  80. } AVClass;
  81. /**
  82. * @addtogroup lavu_log
  83. *
  84. * @{
  85. *
  86. * @defgroup lavu_log_constants Logging Constants
  87. *
  88. * @{
  89. */
  90. /**
  91. * Print no output.
  92. */
  93. #define AV_LOG_QUIET -8
  94. /**
  95. * Something went really wrong and we will crash now.
  96. */
  97. #define AV_LOG_PANIC 0
  98. /**
  99. * Something went wrong and recovery is not possible.
  100. * For example, no header was found for a format which depends
  101. * on headers or an illegal combination of parameters is used.
  102. */
  103. #define AV_LOG_FATAL 8
  104. /**
  105. * Something went wrong and cannot losslessly be recovered.
  106. * However, not all future data is affected.
  107. */
  108. #define AV_LOG_ERROR 16
  109. /**
  110. * Something somehow does not look correct. This may or may not
  111. * lead to problems. An example would be the use of '-vstrict -2'.
  112. */
  113. #define AV_LOG_WARNING 24
  114. /**
  115. * Standard information.
  116. */
  117. #define AV_LOG_INFO 32
  118. /**
  119. * Detailed information.
  120. */
  121. #define AV_LOG_VERBOSE 40
  122. /**
  123. * Stuff which is only useful for libav* developers.
  124. */
  125. #define AV_LOG_DEBUG 48
  126. /**
  127. * Extremely verbose debugging, useful for libav* development.
  128. */
  129. #define AV_LOG_TRACE 56
  130. /**
  131. * @}
  132. */
  133. /**
  134. * Sets additional colors for extended debugging sessions.
  135. * @code
  136. av_log(ctx, AV_LOG_DEBUG|AV_LOG_C(134), "Message in purple\n");
  137. @endcode
  138. * Requires 256color terminal support. Uses outside debugging is not
  139. * recommended.
  140. */
  141. #define AV_LOG_C(x) (x << 8)
  142. /**
  143. * Send the specified message to the log if the level is less than or equal
  144. * to the current av_log_level. By default, all logging messages are sent to
  145. * stderr. This behavior can be altered by setting a different logging callback
  146. * function.
  147. * @see av_log_set_callback
  148. *
  149. * @param avcl A pointer to an arbitrary struct of which the first field is a
  150. * pointer to an AVClass struct.
  151. * @param level The importance level of the message expressed using a @ref
  152. * lavu_log_constants "Logging Constant".
  153. * @param fmt The format string (printf-compatible) that specifies how
  154. * subsequent arguments are converted to output.
  155. */
  156. void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
  157. /**
  158. * Send the specified message to the log if the level is less than or equal
  159. * to the current av_log_level. By default, all logging messages are sent to
  160. * stderr. This behavior can be altered by setting a different logging callback
  161. * function.
  162. * @see av_log_set_callback
  163. *
  164. * @param avcl A pointer to an arbitrary struct of which the first field is a
  165. * pointer to an AVClass struct.
  166. * @param level The importance level of the message expressed using a @ref
  167. * lavu_log_constants "Logging Constant".
  168. * @param fmt The format string (printf-compatible) that specifies how
  169. * subsequent arguments are converted to output.
  170. * @param vl The arguments referenced by the format string.
  171. */
  172. void av_vlog(void *avcl, int level, const char *fmt, va_list vl);
  173. /**
  174. * Get the current log level
  175. *
  176. * @see lavu_log_constants
  177. *
  178. * @return Current log level
  179. */
  180. int av_log_get_level(void);
  181. /**
  182. * Set the log level
  183. *
  184. * @see lavu_log_constants
  185. *
  186. * @param level Logging level
  187. */
  188. void av_log_set_level(int level);
  189. /**
  190. * Set the logging callback
  191. *
  192. * @see av_log_default_callback
  193. *
  194. * @param callback A logging function with a compatible signature.
  195. */
  196. void av_log_set_callback(void (*callback)(void*, int, const char*, va_list));
  197. /**
  198. * Default logging callback
  199. *
  200. * It prints the message to stderr, optionally colorizing it.
  201. *
  202. * @param avcl A pointer to an arbitrary struct of which the first field is a
  203. * pointer to an AVClass struct.
  204. * @param level The importance level of the message expressed using a @ref
  205. * lavu_log_constants "Logging Constant".
  206. * @param fmt The format string (printf-compatible) that specifies how
  207. * subsequent arguments are converted to output.
  208. * @param vl The arguments referenced by the format string.
  209. */
  210. void av_log_default_callback(void *avcl, int level, const char *fmt,
  211. va_list vl);
  212. /**
  213. * Return the context name
  214. *
  215. * @param ctx The AVClass context
  216. *
  217. * @return The AVClass class_name
  218. */
  219. const char* av_default_item_name(void* ctx);
  220. /**
  221. * Skip repeated messages, this requires the user app to use av_log() instead of
  222. * (f)printf as the 2 would otherwise interfere and lead to
  223. * "Last message repeated x times" messages below (f)printf messages with some
  224. * bad luck.
  225. * Also to receive the last, "last repeated" line if any, the user app must
  226. * call av_log(NULL, AV_LOG_QUIET, ""); at the end
  227. */
  228. #define AV_LOG_SKIP_REPEATED 1
  229. void av_log_set_flags(int arg);
  230. /**
  231. * @}
  232. */
  233. #endif /* AVUTIL_LOG_H */