[base] Add trace level to logging output.

Some practical debugging work has shown that displaying level X of
an `FT_TRACEX` macro in the output of `FT2_DEBUG="...  -v"` would be
very helpful to find out which trace level should be selected.  As
an example, we now get output like

```
[ttobjs:2]    TTF driver
[ttobjs:2]      SFNT driver
[sfobjs:2]      not a font using the SFNT container format
[t1objs:2]    Type 1 driver
[stream:7]    FT_Stream_EnterFrame: 14 bytes
```

* include/freetype/internal/ftdebug.h (FT_LOGGING_TAGX): New macro.
(FT_LOG): Use it to add the trace level to the logging tag.

* include/freetype/internal/fttrace.h (FT_MAX_TRACE_LEVEL_LENGTH):
Adjust.

* docs/DEBUG: Updated.
This commit is contained in:
Werner Lemberg 2021-06-25 09:19:51 +02:00
parent 1e0cef9e72
commit ff40776591
4 changed files with 37 additions and 6 deletions

View File

@ -1,3 +1,28 @@
2021-06-25 Werner Lemberg <wl@gnu.org>
[base] Add trace level to logging output.
Some practical debugging work has shown that displaying level X of
an `FT_TRACEX` macro in the output of `FT2_DEBUG="... -v"` would be
very helpful to find out which trace level should be selected. As
an example, we now get output like
```
[ttobjs:2] TTF driver
[ttobjs:2] SFNT driver
[sfobjs:2] not a font using the SFNT container format
[t1objs:2] Type 1 driver
[stream:7] FT_Stream_EnterFrame: 14 bytes
```
* include/freetype/internal/ftdebug.h (FT_LOGGING_TAGX): New macro.
(FT_LOG): Use it to add the trace level to the logging tag.
* include/freetype/internal/fttrace.h (FT_MAX_TRACE_LEVEL_LENGTH):
Adjust.
* docs/DEBUG: Updated.
2021-06-24 Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth, raster] Fix up and align error codes.

View File

@ -168,7 +168,7 @@ behaviour of FreeType at runtime.
If `FT_DEBUG_LOGGING' is defined, two more options are available.
* -v: Print also the name of FreeType's component from which the
current log is produced.
current log is produced, together with the tracing level.
* -t: Print also the time.
@ -176,7 +176,7 @@ behaviour of FreeType at runtime.
FT2_DEBUG="any:7 memory:5 -vt"
=> [20:32:02:44969 ttload] table directory loaded
=> [20:32:02:44969 ttload:2] table directory loaded
FT2_DEBUG="any:7 memory:5 -t"
@ -184,7 +184,7 @@ behaviour of FreeType at runtime.
FT2_DEBUG="any:7 memory:5 -v"
=> [ttload] table directory loaded
=> [ttload:2] table directory loaded
FT_LOGGING_FILE

View File

@ -114,11 +114,16 @@ FT_BEGIN_HEADER
#define FT_LOGGING_TAG( x ) FT_LOGGING_TAG_( x )
#define FT_LOGGING_TAG_( x ) #x
/* we need two macros to convert the component and the trace level */
/* to a string that combines them */
#define FT_LOGGING_TAGX( x, y ) FT_LOGGING_TAGX_( x, y )
#define FT_LOGGING_TAGX_( x, y ) #x ":" #y
#define FT_LOG( level, varformat ) \
do \
{ \
const char* dlg_tag = FT_LOGGING_TAG( FT_COMPONENT ); \
const char* dlg_tag = FT_LOGGING_TAGX( FT_COMPONENT, level ); \
\
\
ft_add_tag( dlg_tag ); \

View File

@ -19,8 +19,9 @@
/* definitions of trace levels for FreeType 2 */
/* the maximum string length (if the argument to `FT_TRACE_DEF` */
/* gets used as a string) */
#define FT_MAX_TRACE_LEVEL_LENGTH 9
/* gets used as a string) plus one charachter for ':' plus */
/* another one for the trace level */
#define FT_MAX_TRACE_LEVEL_LENGTH (9 + 1 + 1)
/* the first level must always be `trace_any' */
FT_TRACE_DEF( any )