David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | /* */ |
| 3 | /* ftdebug.c */ |
| 4 | /* */ |
| 5 | /* Debugging and logging component (body). */ |
| 6 | /* */ |
Werner Lemberg | f993b6a | 2000-01-08 17:10:33 +0000 | [diff] [blame] | 7 | /* Copyright 1996-2000 by */ |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 8 | /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 | /* */ |
Werner Lemberg | 4e6dd85 | 2000-06-05 05:26:15 +0000 | [diff] [blame] | 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 */ |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 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 Lemberg | 9a754ce | 2000-06-02 21:31:32 +0000 | [diff] [blame] | 19 | /*************************************************************************/ |
| 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 Turner | efce08d | 2000-05-11 18:23:52 +0000 | [diff] [blame] | 44 | #include <freetype/internal/ftdebug.h> |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 45 | |
| 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 Lemberg | 026bd17 | 2000-05-30 05:13:30 +0000 | [diff] [blame] | 59 | FT_EXPORT_FUNC( void ) FT_Message( const char* fmt, ... ) |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 60 | { |
| 61 | va_list ap; |
| 62 | |
| 63 | |
| 64 | va_start( ap, fmt ); |
| 65 | vprintf( fmt, ap ); |
| 66 | va_end( ap ); |
| 67 | } |
| 68 | |
| 69 | |
Werner Lemberg | 026bd17 | 2000-05-30 05:13:30 +0000 | [diff] [blame] | 70 | FT_EXPORT_FUNC( void ) FT_Panic( const char* fmt, ... ) |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 71 | { |
| 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 Lemberg | f993b6a | 2000-01-08 17:10:33 +0000 | [diff] [blame] | 85 | |
| 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 Lemberg | 026bd17 | 2000-05-30 05:13:30 +0000 | [diff] [blame] | 100 | FT_EXPORT_FUNC( void ) FT_SetTraceLevel( FT_Trace component, |
| 101 | char level ) |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 102 | { |
| 103 | if ( component >= trace_max ) |
| 104 | return; |
| 105 | |
Werner Lemberg | deb4e98 | 2000-06-29 03:14:25 +0000 | [diff] [blame^] | 106 | /* if component is `trace_any', change _all_ levels at once */ |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 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 */ |