blob: fa71216b8a82d14f96ded723fec62df9f98c3531 [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
David Turnerd2b1f351999-12-16 23:11:37 +000034 void FT_Message( const char* fmt, ... )
35 {
36 va_list ap;
37
38
39 va_start( ap, fmt );
40 vprintf( fmt, ap );
41 va_end( ap );
42 }
43
44
45 void FT_Panic( const char* fmt, ... )
46 {
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 /* */
David Turnerd2b1f351999-12-16 23:11:37 +000075 EXPORT_FUNC
76 void FT_SetTraceLevel( FT_Trace component,
77 char level )
78 {
79 if ( component >= trace_max )
80 return;
81
82 /* if component is `trace_any', then change _all_ levels at once */
83 if ( component == trace_any )
84 {
85 int n;
86
87
88 for ( n = trace_any; n < trace_max; n++ )
89 ft_trace_levels[n] = level;
90 }
91 else /* otherwise, only change individual component */
92 ft_trace_levels[component] = level;
93 }
94
95#endif /* FT_DEBUG_LEVEL_TRACE */
96
97#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
98
99
100/* END */