blob: dae22776ef5b2c876c62ff267579526ac42800f1 [file] [log] [blame]
David Turnerd2b1f351999-12-16 23:11:37 +00001/***************************************************************************/
2/* */
3/* ftdebug.c */
4/* */
5/* Debugging and logging component (body). */
6/* */
Werner Lembergf993b6a2000-01-08 17:10:33 +00007/* Copyright 1996-2000 by */
David Turnerd2b1f351999-12-16 23:11:37 +00008/* David Turner, Robert Wilhelm, and Werner Lemberg. */
9/* */
10/* This file is part of the FreeType project, and may only be used */
11/* modified and distributed under the terms of the FreeType project */
12/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13/* this file you indicate that you have read the license and */
14/* understand and accept it fully. */
15/* */
16/***************************************************************************/
17
18
David Turnerefce08d2000-05-11 18:23:52 +000019#include <freetype/internal/ftdebug.h>
David Turnerd2b1f351999-12-16 23:11:37 +000020
21#ifdef FT_DEBUG_LEVEL_TRACE
22 char ft_trace_levels[trace_max];
23#endif
24
25
26#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
27
28
29#include <stdarg.h>
30#include <stdlib.h>
31#include <string.h>
32
33
Werner Lemberg026bd172000-05-30 05:13:30 +000034 FT_EXPORT_FUNC( void ) FT_Message( const char* fmt, ... )
David Turnerd2b1f351999-12-16 23:11:37 +000035 {
36 va_list ap;
37
38
39 va_start( ap, fmt );
40 vprintf( fmt, ap );
41 va_end( ap );
42 }
43
44
Werner Lemberg026bd172000-05-30 05:13:30 +000045 FT_EXPORT_FUNC( void ) FT_Panic( const char* fmt, ... )
David Turnerd2b1f351999-12-16 23:11:37 +000046 {
47 va_list ap;
48
49
50 va_start( ap, fmt );
51 vprintf( fmt, ap );
52 va_end( ap );
53
54 exit( EXIT_FAILURE );
55 }
56
57
58#ifdef FT_DEBUG_LEVEL_TRACE
59
Werner Lembergf993b6a2000-01-08 17:10:33 +000060
61 /*************************************************************************/
62 /* */
63 /* <Function> */
64 /* FT_SetTraceLevel */
65 /* */
66 /* <Description> */
67 /* Sets the trace level for debugging. */
68 /* */
69 /* <Input> */
70 /* component :: The component which should be traced. See ftdebug.h */
71 /* for a complete list. If set to `trace_any', all */
72 /* components will be traced. */
73 /* level :: The tracing level. */
74 /* */
Werner Lemberg026bd172000-05-30 05:13:30 +000075 FT_EXPORT_FUNC( void ) FT_SetTraceLevel( FT_Trace component,
76 char level )
David Turnerd2b1f351999-12-16 23:11:37 +000077 {
78 if ( component >= trace_max )
79 return;
80
81 /* if component is `trace_any', then change _all_ levels at once */
82 if ( component == trace_any )
83 {
84 int n;
85
86
87 for ( n = trace_any; n < trace_max; n++ )
88 ft_trace_levels[n] = level;
89 }
90 else /* otherwise, only change individual component */
91 ft_trace_levels[component] = level;
92 }
93
94#endif /* FT_DEBUG_LEVEL_TRACE */
95
96#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
97
98
99/* END */