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 | /* */ |
| 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 Turner | efce08d | 2000-05-11 18:23:52 +0000 | [diff] [blame^] | 19 | #include <freetype/internal/ftdebug.h> |
David Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 20 | |
| 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 Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 34 | 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 Lemberg | f993b6a | 2000-01-08 17:10:33 +0000 | [diff] [blame] | 60 | |
| 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 Turner | d2b1f35 | 1999-12-16 23:11:37 +0000 | [diff] [blame] | 75 | 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 */ |