blob: f2a223755eba4a11c3c6702463b72c1a7d358e41 [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/* */
Werner Lemberg4e6dd852000-06-05 05:26:15 +000010/* This file is part of the FreeType project, and may only be used, */
11/* modified, and distributed under the terms of the FreeType project */
David Turnerd2b1f351999-12-16 23:11:37 +000012/* 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
Werner Lembergcc069be2000-12-08 16:17:16 +000043
44#include <ft2build.h>
45#include FT_INTERNAL_DEBUG_H
46
David Turnerd2b1f351999-12-16 23:11:37 +000047
48#ifdef FT_DEBUG_LEVEL_TRACE
49 char ft_trace_levels[trace_max];
50#endif
51
52
53#if defined( FT_DEBUG_LEVEL_ERROR ) || defined( FT_DEBUG_LEVEL_TRACE )
54
55
56#include <stdarg.h>
57#include <stdlib.h>
58#include <string.h>
59
60
David Turner76a5f622000-11-04 01:55:49 +000061 FT_EXPORT_DEF( void ) FT_Message( const char* fmt, ... )
David Turnerd2b1f351999-12-16 23:11:37 +000062 {
63 va_list ap;
64
65
66 va_start( ap, fmt );
67 vprintf( fmt, ap );
68 va_end( ap );
69 }
70
71
David Turner76a5f622000-11-04 01:55:49 +000072 FT_EXPORT_DEF( void ) FT_Panic( const char* fmt, ... )
David Turnerd2b1f351999-12-16 23:11:37 +000073 {
74 va_list ap;
75
76
77 va_start( ap, fmt );
78 vprintf( fmt, ap );
79 va_end( ap );
80
81 exit( EXIT_FAILURE );
82 }
83
84
85#ifdef FT_DEBUG_LEVEL_TRACE
86
David Turner76a5f622000-11-04 01:55:49 +000087 FT_EXPORT_DEF( void ) FT_SetTraceLevel( FT_Trace component,
88 char level )
David Turnerd2b1f351999-12-16 23:11:37 +000089 {
90 if ( component >= trace_max )
91 return;
92
Werner Lembergdeb4e982000-06-29 03:14:25 +000093 /* if component is `trace_any', change _all_ levels at once */
David Turnerd2b1f351999-12-16 23:11:37 +000094 if ( component == trace_any )
95 {
96 int n;
97
98
99 for ( n = trace_any; n < trace_max; n++ )
100 ft_trace_levels[n] = level;
101 }
102 else /* otherwise, only change individual component */
103 ft_trace_levels[component] = level;
104 }
105
106#endif /* FT_DEBUG_LEVEL_TRACE */
107
108#endif /* FT_DEBUG_LEVEL_TRACE || FT_DEBUG_LEVEL_ERROR */
109
Werner Lemberg63408a12000-12-13 23:44:37 +0000110
111 /* ANSI C doesn't allow empty files, so we insert a dummy symbol */
David Turner170c0d42000-12-13 19:55:11 +0000112 extern const int ft_debug_dummy;
David Turnerd2b1f351999-12-16 23:11:37 +0000113
Werner Lemberg63408a12000-12-13 23:44:37 +0000114
David Turnerd2b1f351999-12-16 23:11:37 +0000115/* END */