blob: 5fb000b336b51a29910dae6e0dbfc3f2857f181c [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
Werner Lemberg9a754ce2000-06-02 21:31:32 +000019 /*************************************************************************/
20 /* */
21 /* This component contains various macros and functions used to ease the */
22 /* debugging of the FreeType engine. Its main purpose is in assertion */
23 /* checking, tracing, and error detection. */
24 /* */
25 /* There are now three debugging modes: */
26 /* */
27 /* - trace mode */
28 /* */
29 /* Error and trace messages are sent to the log file (which can be the */
30 /* standard error output). */
31 /* */
32 /* - error mode */
33 /* */
34 /* Only error messages are generated. */
35 /* */
36 /* - release mode: */
37 /* */
38 /* No error message is sent or generated. The code is free from any */
39 /* debugging parts. */
40 /* */
41 /*************************************************************************/
42
43
David Turnerefce08d2000-05-11 18:23:52 +000044#include <freetype/internal/ftdebug.h>
David Turnerd2b1f351999-12-16 23:11:37 +000045
46#ifdef FT_DEBUG_LEVEL_TRACE
47 char ft_trace_levels[trace_max];
48#endif
49
50
51#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
52
53
54#include <stdarg.h>
55#include <stdlib.h>
56#include <string.h>
57
58
Werner Lemberg026bd172000-05-30 05:13:30 +000059 FT_EXPORT_FUNC( void ) FT_Message( const char* fmt, ... )
David Turnerd2b1f351999-12-16 23:11:37 +000060 {
61 va_list ap;
62
63
64 va_start( ap, fmt );
65 vprintf( fmt, ap );
66 va_end( ap );
67 }
68
69
Werner Lemberg026bd172000-05-30 05:13:30 +000070 FT_EXPORT_FUNC( void ) FT_Panic( const char* fmt, ... )
David Turnerd2b1f351999-12-16 23:11:37 +000071 {
72 va_list ap;
73
74
75 va_start( ap, fmt );
76 vprintf( fmt, ap );
77 va_end( ap );
78
79 exit( EXIT_FAILURE );
80 }
81
82
83#ifdef FT_DEBUG_LEVEL_TRACE
84
Werner Lembergf993b6a2000-01-08 17:10:33 +000085
86 /*************************************************************************/
87 /* */
88 /* <Function> */
89 /* FT_SetTraceLevel */
90 /* */
91 /* <Description> */
92 /* Sets the trace level for debugging. */
93 /* */
94 /* <Input> */
95 /* component :: The component which should be traced. See ftdebug.h */
96 /* for a complete list. If set to `trace_any', all */
97 /* components will be traced. */
98 /* level :: The tracing level. */
99 /* */
Werner Lemberg026bd172000-05-30 05:13:30 +0000100 FT_EXPORT_FUNC( void ) FT_SetTraceLevel( FT_Trace component,
101 char level )
David Turnerd2b1f351999-12-16 23:11:37 +0000102 {
103 if ( component >= trace_max )
104 return;
105
106 /* if component is `trace_any', then change _all_ levels at once */
107 if ( component == trace_any )
108 {
109 int n;
110
111
112 for ( n = trace_any; n < trace_max; n++ )
113 ft_trace_levels[n] = level;
114 }
115 else /* otherwise, only change individual component */
116 ft_trace_levels[component] = level;
117 }
118
119#endif /* FT_DEBUG_LEVEL_TRACE */
120
121#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
122
123
124/* END */