summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPriyesh Kumar <priyeshkkumar@gmail.com>2020-08-31 18:02:23 +0530
committerPriyesh Kumar <priyeshkkumar@gmail.com>2020-08-31 18:02:23 +0530
commit7e6b43edf342ce9561be070a79228b942a28d18f (patch)
treefd8a84c224b691d8bf731295efc592f3c4f9136e
parent526d973e315ea058b02c1662c6c189edd337b22e (diff)
downloadfreetype2-7e6b43edf342ce9561be070a79228b942a28d18f.tar.gz
[base] Fix the vertical alignment of printing of logs.
* src/base/ftdebug.c (ft_log_handler): Updates to print logs after a fixed width for better vertical alignment. * builds/windows/ftdebug.c (ft_log_handler): Updates to print logs after a fixed width for better vertical alignment.
-rw-r--r--builds/windows/ftdebug.c34
-rw-r--r--src/base/ftdebug.c34
2 files changed, 52 insertions, 16 deletions
diff --git a/builds/windows/ftdebug.c b/builds/windows/ftdebug.c
index d698e562c..90451f174 100644
--- a/builds/windows/ftdebug.c
+++ b/builds/windows/ftdebug.c
@@ -449,20 +449,38 @@ FT_Trace_Enable( void )
*/
FT_BASE_DEF( void )
ft_log_handler( const struct dlg_origin* origin,
- const char* string, void* data )
+ const char* string,
+ void* data )
{
( void ) data;
- const char* features ;
+ char* features ;
if( ft_timestamp_flag && ft_component_flag && ft_have_newline_char )
- features = "[%h:%m %t] %c";
+ features = "[%h:%m %t]";
else if( ft_component_flag && ft_have_newline_char)
- features = "[%t] %c";
+ features = "[%t]";
else if( ft_timestamp_flag && ft_have_newline_char )
- features = "[%h:%m] %c";
- else
- features = "%c";
+ features = "[%h:%m]";
+ else
+ features = "";
+
+ long int tag_length = strlen( *origin->tags );
+ long int features_length = strlen( features );
+
+ char* features_ = (char*)malloc( sizeof(char) * (features_length + 18) );
+
+ strcpy( features_, features );
+
+ if( ft_have_newline_char && ( ft_component_flag || ft_timestamp_flag ) )
+ {
+ long int num_of_spaces = 15 - tag_length;
+ int i;
+ for( i = 0; i < num_of_spaces; i++ )
+ strcat( features_, " " );
+ }
+
+ strcat( features_, "%c" );
- dlg_generic_outputf_stream( ft_fileptr, features, origin, string,
+ dlg_generic_outputf_stream( ft_fileptr, (const char*)features_, origin, string,
dlg_default_output_styles, true );
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index 296c5bb9c..b9cf2ecf6 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -438,20 +438,38 @@ else
*/
FT_BASE_DEF( void )
ft_log_handler( const struct dlg_origin* origin,
- const char* string, void* data )
+ const char* string,
+ void* data )
{
( void ) data;
- const char* features ;
+ char* features ;
if( ft_timestamp_flag && ft_component_flag && ft_have_newline_char )
- features = "[%h:%m %t] %c";
+ features = "[%h:%m %t]";
else if( ft_component_flag && ft_have_newline_char)
- features = "[%t] %c";
+ features = "[%t]";
else if( ft_timestamp_flag && ft_have_newline_char )
- features = "[%h:%m] %c";
- else
- features = "%c";
+ features = "[%h:%m]";
+ else
+ features = "";
+
+ long int tag_length = strlen( *origin->tags );
+ long int features_length = strlen( features );
+
+ char features_[ features_length + 18 ];
+
+ strcpy( features_, features );
+
+ if( ft_have_newline_char && ( ft_component_flag || ft_timestamp_flag ) )
+ {
+ long int num_of_spaces = 15 - tag_length;
+ int i;
+ for( i = 0; i < num_of_spaces; i++ )
+ strcat( features_, " " );
+ }
+
+ strcat( features_, "%c" );
- dlg_generic_outputf_stream( ft_fileptr, features, origin, string,
+ dlg_generic_outputf_stream( ft_fileptr, (const char*)features_, origin, string,
dlg_default_output_styles, true );