@@ -7,10 +7,10 @@ namespace logger {
77 static constexpr const char * DASHES = " ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------" ;
88
99 static constexpr const bool LOG_ENABLED = false ;
10- static constexpr const int LOG_EVENT_LEN = 30 ;
11- static constexpr const int LOG_BUFFER_LEN = 20 ;
12- static constexpr const int LOG_DETAIL_LEN = 50 ;
13- static constexpr const int LOG_INDEX_LEN = 10 ;
10+ static constexpr const int LOG_EVENT_LEN = 20 ;
11+ static constexpr const int LOG_BUFFER_LEN = 10 ;
12+ static constexpr const int LOG_SMALL_BUFFER_LEN = 10 ;
13+ static constexpr const int LOG_INDEX_LEN = 5 ;
1414
1515 static int log_depth; // Not threadsafe. Log only.
1616
@@ -28,8 +28,8 @@ namespace logger {
2828 if (LOG_ENABLED) {
2929 log_depth = 0 ;
3030 printf (" \n " );
31- printf (" | %-*s | %-*s | %*s | %*s | %*s | % -*s | %-*s | %-*s |\n " , LOG_EVENT_LEN, " Event" , LOG_BUFFER_LEN, " Buffer" , 4 , " Curr " , 4 , " Next" , 5 , " Next#" , 5 , " Tape# " , LOG_DETAIL_LEN, " Detail " , LOG_INDEX_LEN, " index " );
32- printf (" |%.*s|%.*s|%.*s|%.*s|%.*s|%.*s|%.*s|%.*s| \n " , LOG_EVENT_LEN+2 , DASHES, LOG_BUFFER_LEN+2 , DASHES, 4 +2 , DASHES, 4 + 2 , DASHES, 5 + 2 , DASHES, 5 + 2 , DASHES, LOG_DETAIL_LEN+ 2 , DASHES, LOG_INDEX_LEN +2 , DASHES);
31+ printf (" | %-*s | %-*s | %-*s | %-*s | Detail |\n " , LOG_EVENT_LEN, " Event" , LOG_BUFFER_LEN, " Buffer" , LOG_SMALL_BUFFER_LEN , " Next" , 5 , " Next#" );
32+ printf (" |%.*s|%.*s|%.*s|%.*s|--------| \n " , LOG_EVENT_LEN+2 , DASHES, LOG_BUFFER_LEN+2 , DASHES, LOG_SMALL_BUFFER_LEN +2 , DASHES, 5 +2 , DASHES);
3333 }
3434 }
3535
@@ -44,22 +44,35 @@ namespace logger {
4444 static really_inline void log_line (S &structurals, const char *title_prefix, const char *title, const char *detail) {
4545 if (LOG_ENABLED) {
4646 printf (" | %*s%s%-*s " , log_depth*2 , " " , title_prefix, LOG_EVENT_LEN - log_depth*2 - int (strlen (title_prefix)), title);
47+ auto current_index = structurals.at_beginning () ? nullptr : structurals.next_structural -1 ;
48+ auto next_index = structurals.next_structural ;
49+ auto current = current_index ? &structurals.buf [*current_index] : (const uint8_t *)" " ;
50+ auto next = &structurals.buf [*next_index];
4751 {
4852 // Print the next N characters in the buffer.
4953 printf (" | " );
5054 // Otherwise, print the characters starting from the buffer position.
5155 // Print spaces for unprintable or newline characters.
5256 for (int i=0 ;i<LOG_BUFFER_LEN;i++) {
53- printf (" %c" , printable_char (structurals. current () [i]));
57+ printf (" %c" , printable_char (current[i]));
5458 }
5559 printf (" " );
60+ // Print the next N characters in the buffer.
61+ printf (" | " );
62+ // Otherwise, print the characters starting from the buffer position.
63+ // Print spaces for unprintable or newline characters.
64+ for (int i=0 ;i<LOG_SMALL_BUFFER_LEN;i++) {
65+ printf (" %c" , printable_char (next[i]));
66+ }
67+ printf (" " );
68+ }
69+ if (current_index) {
70+ printf (" | %*u " , LOG_INDEX_LEN, *current_index);
71+ } else {
72+ printf (" | %-*s " , LOG_INDEX_LEN, " " );
5673 }
57- printf (" | %c " , printable_char (structurals.current_char ()));
58- printf (" | %c " , printable_char (structurals.peek_next_char ()));
59- printf (" | %5u " , structurals.parser .structural_indexes [*(structurals.current_structural +1 )]);
60- printf (" | %5u " , structurals.next_tape_index ());
61- printf (" | %-*s " , LOG_DETAIL_LEN, detail);
62- printf (" | %*u " , LOG_INDEX_LEN, *structurals.current_structural );
74+ // printf("| %*u ", LOG_INDEX_LEN, structurals.next_tape_index());
75+ printf (" | %-s " , detail);
6376 printf (" |\n " );
6477 }
6578 }
0 commit comments