Added public APIs to set new/default trace level, started working on Callback function
This commit is contained in:
parent
f7c5ed5f24
commit
1d6ffcc77a
|
@ -1,3 +1,28 @@
|
|||
2020-07-02 Priyesh Kumar <priyeshkkumar@gmail.com>
|
||||
|
||||
* Fixed some code layout
|
||||
|
||||
* Added a new header- `include/freetype/ftlogging.h` for public APIs to
|
||||
use when using logging:
|
||||
1. FT_Trace_Set_Level(): Used to change trace level of components at
|
||||
runtime.
|
||||
2. FT_Trace_Set_Default_Level(): Used to set the default value of trace
|
||||
level(which is supplied by env FT2_DEBUG)
|
||||
|
||||
* include/freetype/internal/ftdebug.h:
|
||||
1. Added dlg support for FT_ERROR, now error messages are also written
|
||||
on file if FT_LOGGING is enabled.
|
||||
2. Changed `ft_debug_init()`: now it takes an argument of type const
|
||||
char* which is used to specify trace level.
|
||||
|
||||
* src/base/ftobjs.c: Changed `ft_debug_init()`, now it passes an argument
|
||||
to define trace level.
|
||||
|
||||
* src/base/ftdebug.c: Added definitions of public APIs
|
||||
`FT_Trace_Set_Default_Level()` and `FT_Trace_Set_Level()`
|
||||
|
||||
* Strated working on Callback.
|
||||
|
||||
2020-06-30 Priyesh Kumar <priyeshkkumar@gmail.com>
|
||||
|
||||
* Adding new line at end of file
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
#include FT_CONFIG_CONFIG_H
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* If FT_LOGGING is enabled, user can change the trace level at run time
|
||||
* using the function `FT_Trace_Set_Level()` by passing the desired trace
|
||||
* level as an argument.
|
||||
* User can also set the default trace level which is supplied by
|
||||
* environment variable `FT2_DEBUG`
|
||||
*
|
||||
*/
|
||||
|
||||
typedef void
|
||||
(*ft_ouput_handler)( const char* string );
|
||||
|
||||
FT_EXPORT( void )
|
||||
FT_Trace_Set_Level( const char* level );
|
||||
|
||||
FT_EXPORT( void )
|
||||
FT_Trace_Set_Default_Level( void );
|
||||
|
||||
FT_EXPORT( void )
|
||||
FT_Trace_Set_Output( ft_ouput_handler handler );
|
||||
|
||||
FT_EXPORT( void )
|
||||
FT_Trace_Set_Default_Output();
|
||||
|
||||
FT_END_HEADER
|
|
@ -29,11 +29,18 @@
|
|||
#include FT_CONFIG_CONFIG_H
|
||||
#include <freetype/freetype.h>
|
||||
|
||||
/* Additional include files for supporting logging in FreeType using */
|
||||
/* external logging library ~ src/dlg */
|
||||
/* */
|
||||
/**************************************************************************
|
||||
*
|
||||
* Additional include files for supporting logging in FreeType using
|
||||
* external logging library ~ src/dlg and freetype/ftlogging.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
#include <../src/dlg/include/dlg/dlg.h>
|
||||
#include <../src/dlg/include/dlg/output.h>
|
||||
#include <freetype/ftlogging.h>
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
@ -104,6 +111,8 @@ FT_BEGIN_HEADER
|
|||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
static ft_ouput_handler freetype_output_handler = NULL;
|
||||
|
||||
#undef FT_Log
|
||||
#define FT_Log dlg_trace
|
||||
|
||||
|
@ -117,7 +126,7 @@ FT_BEGIN_HEADER
|
|||
*/
|
||||
|
||||
FT_BASE( void )
|
||||
ft_freetype_output_handler( const struct dlg_origin* origin,
|
||||
ft_default_output_handler( const struct dlg_origin* origin,
|
||||
const char* string, void* data );
|
||||
|
||||
#else
|
||||
|
@ -247,8 +256,22 @@ FT_BEGIN_HEADER
|
|||
|
||||
#ifdef FT_DEBUG_LEVEL_ERROR
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
#define FT_ERROR( varformat ) \
|
||||
do \
|
||||
{ \
|
||||
dlg_add_tag( "error_log", NULL ); \
|
||||
dlg_trace varformat; \
|
||||
dlg_remove_tag( "error_log", NULL ); \
|
||||
} while ( 0 )
|
||||
|
||||
#else
|
||||
|
||||
#define FT_ERROR( varformat ) FT_Message varformat
|
||||
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
#else /* !FT_DEBUG_LEVEL_ERROR */
|
||||
|
||||
#define FT_ERROR( varformat ) do { } while ( 0 ) /* nothing */
|
||||
|
@ -318,7 +341,7 @@ FT_BEGIN_HEADER
|
|||
|
||||
|
||||
FT_BASE( void )
|
||||
ft_debug_init( void );
|
||||
ft_debug_init( const char* level );
|
||||
|
||||
#ifdef FT_LOGGING
|
||||
|
||||
|
|
|
@ -193,9 +193,9 @@
|
|||
* runtime errors), and 7 means _very_ verbose.
|
||||
*/
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
ft_debug_init( const char* level )
|
||||
{
|
||||
const char* ft2_debug = ft_getenv( "FT2_DEBUG" );
|
||||
const char* ft2_debug = level;
|
||||
|
||||
|
||||
if ( ft2_debug )
|
||||
|
@ -274,7 +274,7 @@
|
|||
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
ft_debug_init( void )
|
||||
ft_debug_init( const char* level )
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
@ -337,10 +337,10 @@
|
|||
ft_logging_init( void )
|
||||
{
|
||||
fileptr = fopen( "freetype2.log", "w" );
|
||||
ft_debug_init();
|
||||
FT_Trace_Set_Default_Level();
|
||||
|
||||
/* We need to set the default FreeType specific dlg's output handler */
|
||||
dlg_set_handler( &ft_freetype_output_handler, NULL );
|
||||
dlg_set_handler( &ft_default_output_handler, NULL );
|
||||
}
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
|
@ -349,15 +349,14 @@
|
|||
fclose( fileptr );
|
||||
}
|
||||
|
||||
FT_BASE_DEF( void )
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* TODO:
|
||||
* 1. Add support for priniting FT_COMPONENT
|
||||
*
|
||||
*/
|
||||
ft_freetype_output_handler( const struct dlg_origin* origin,
|
||||
*/
|
||||
FT_BASE_DEF( void )
|
||||
ft_default_output_handler( const struct dlg_origin* origin,
|
||||
const char* string, void* data )
|
||||
{
|
||||
unsigned int features = dlg_output_threadsafe /*| dlg_output_tags*/ ;
|
||||
|
@ -365,6 +364,41 @@
|
|||
dlg_default_output_styles );
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Level( const char* level )
|
||||
{
|
||||
ft_debug_init( level );
|
||||
}
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Default_Level( void )
|
||||
{
|
||||
ft_debug_init( ft_getenv( "FT2_DEBUG" ) );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Output( ft_ouput_handler handler )
|
||||
{
|
||||
freetype_output_handler = handler;
|
||||
}
|
||||
|
||||
FT_EXPORT_DEF( void )
|
||||
FT_Trace_Set_Default_Output()
|
||||
{
|
||||
freetype_output_handler = NULL;
|
||||
}
|
||||
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
/* END */
|
||||
|
|
|
@ -5276,7 +5276,7 @@
|
|||
#ifndef FT_LOGGING
|
||||
#ifdef FT_DEBUG_LEVEL_ERROR
|
||||
/* init debugging support */
|
||||
ft_debug_init();
|
||||
ft_debug_init( ft_getenv( "FT2_DEBUG" ) );
|
||||
#endif /* FT_DEBUG_LEVEL_ERROR */
|
||||
#endif /* FT_LOGGING */
|
||||
|
||||
|
|
Loading…
Reference in New Issue