Skip to content

Commit 1ba511b

Browse files
committed
Fix first entry and exit field rendering
1 parent daf3593 commit 1ba511b

11 files changed

+121
-109
lines changed

examples/basic.stdout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainbasic::hierarchical-example
2-
1:main version=0.1
1+
1:main┬─┬─ basic::hierarchical-example
2+
1:main│ └─ version=0.1
33
1:main└┬─┬─ basic::hierarchical-example
44
1:main │ └─ version=0.1
55
1:main └┬─┬─ basic::server
@@ -88,5 +88,5 @@
8888
1:main │ └─ port=8080
8989
1:main┌┴┬─ basic::hierarchical-example
9090
1:main│ └─ version=0.1
91-
1:mainbasic::hierarchical-example
92-
1:main version=0.1
91+
1:main┴┬─ basic::hierarchical-example
92+
1:main └─ version=0.1

examples/basic_non_verbose.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainbasic_non_verbose::hierarchical-example
2-
1:main version=0.1
1+
1:main┬─┬─ basic_non_verbose::hierarchical-example
2+
1:main│ └─ version=0.1
33
1:main└─┬─┬─ basic_non_verbose::server
44
1:main │ ├─ host="localhost"
55
1:main │ └─ port=8080

examples/basic_verbose_entry.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainbasic_verbose_entry::hierarchical-example
2-
1:main version=0.1
1+
1:main┬─┬─ basic_verbose_entry::hierarchical-example
2+
1:main│ └─ version=0.1
33
1:main└┬─┬─ basic_verbose_entry::hierarchical-example
44
1:main │ └─ version=0.1
55
1:main └┬─┬─ basic_verbose_entry::server

examples/basic_verbose_exit.stdout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainbasic_verbose_exit::hierarchical-example
2-
1:main version=0.1
1+
1:main┬─┬─ basic_verbose_exit::hierarchical-example
2+
1:main│ └─ version=0.1
33
1:main└─┬─┬─ basic_verbose_exit::server
44
1:main │ ├─ host="localhost"
55
1:main │ └─ port=8080
@@ -71,5 +71,5 @@
7171
1:main │ └─ port=8080
7272
1:main┌┴┬─ basic_verbose_exit::hierarchical-example
7373
1:main│ └─ version=0.1
74-
1:mainbasic_verbose_exit::hierarchical-example
75-
1:main version=0.1
74+
1:main┴┬─ basic_verbose_exit::hierarchical-example
75+
1:main └─ version=0.1

examples/concurrent.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainconcurrent::hierarchical-example
2-
1:main version=0.1
1+
1:main┬───┬─── concurrent::hierarchical-example
2+
1:main│ └─ version=0.1
33
1:main└───┬───┬─── concurrent::server
44
1:main │ ├─ host="localhost"
55
1:main │ └─ port=8080

examples/concurrent_eager.stdout

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
1:mainconcurrent_eager::spawn_fut
2-
1:main key="a"
3-
1:mainconcurrent_eager::spawn_fut
4-
1:main key="b"
5-
1:mainconcurrent_eager::spawn_fut
6-
1:main key="a"
1+
1:main┬───┬─── concurrent_eager::spawn_fut
2+
1:main│ └─ key="a"
3+
1:main┬───┬─── concurrent_eager::spawn_fut
4+
1:main│ └─ key="b"
5+
1:main┬───┬─── concurrent_eager::spawn_fut
6+
1:main│ └─ key="a"
77
1:main└───┐concurrent_eager::a
8-
1:mainconcurrent_eager::spawn_fut
9-
1:main key="b"
8+
1:main┬───┬─── concurrent_eager::spawn_fut
9+
1:main│ └─ key="b"
1010
1:main└───┐concurrent_eager::b
11-
1:mainconcurrent_eager::spawn_fut
12-
1:main key="a"
11+
1:main┬───┬─── concurrent_eager::spawn_fut
12+
1:main│ └─ key="a"
1313
1:main└───┐concurrent_eager::a
1414
1:main ├─── INFO concurrent_eager a
1515
1:main┌───┘
16-
1:mainconcurrent_eager::spawn_fut
17-
1:main key="b"
16+
1:main┬───┬─── concurrent_eager::spawn_fut
17+
1:main│ └─ key="b"
1818
1:main└───┐concurrent_eager::b
1919
1:main ├─── INFO concurrent_eager b
2020
1:main┌───┘

examples/concurrent_verbose.stdout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainconcurrent_verbose::hierarchical-example
2-
1:main version=0.1
1+
1:main┬───┬─── concurrent_verbose::hierarchical-example
2+
1:main│ └─ version=0.1
33
1:main└───┬───┬─── concurrent_verbose::server
44
1:main │ ├─ host="localhost"
55
1:main │ └─ port=8080
@@ -60,5 +60,5 @@
6060
1:main │ └─ port=8080
6161
1:main┌─┴──┬─── concurrent_verbose::hierarchical-example
6262
1:main │ └─ version=0.1
63-
1:mainconcurrent_verbose::hierarchical-example
64-
1:main version=0.1
63+
1:main┴──┬─── concurrent_verbose::hierarchical-example
64+
1:main └─ version=0.1

examples/deferred.stdout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-> This prints before the span open message
2-
1:mainopen: deferred::hierarchical-example
3-
1:main version=0.1
2+
1:main┬─┬─ open: deferred::hierarchical-example
3+
1:main│ └─ version=0.1
44
1:main└─┬─┬─ open: deferred::server
55
1:main │ ├─ host="localhost"
66
1:main │ └─ port=8080
@@ -77,5 +77,5 @@
7777
1:main │ └─ port=8080
7878
1:main┌┴┬─ post_close: deferred::hierarchical-example
7979
1:main│ └─ version=0.1
80-
1:mainclose(v): deferred::hierarchical-example
81-
1:main version=0.1
80+
1:main┴┬─ close(v): deferred::hierarchical-example
81+
1:main └─ version=0.1

examples/quiet.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainquiet::hierarchical-example
2-
1:main version=0.1
1+
1:main┬─┬─ quiet::hierarchical-example
2+
1:main│ └─ version=0.1
33
1:main└─┬─┬─ quiet::server
44
1:main │ ├─ host="localhost"
55
1:main │ └─ port=8080

examples/wraparound.stdout

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
1:mainwraparound::recurse
2-
1:main i=0
1+
1:main┬─┬─ wraparound::recurse
2+
1:main│ └─ i=0
33
1:main├─ WARN wraparound boop
44
1:main└─┬─┬─ wraparound::recurse
55
1:main │ └─ i=1
@@ -14,8 +14,8 @@
1414
1:main │ └─ i=4
1515
1:main────────┘
1616
1:main WARN wraparound boop
17-
1:mainwraparound::recurse
18-
1:main i=5
17+
1:main┬─┬─ wraparound::recurse
18+
1:main│ └─ i=5
1919
1:main├─ WARN wraparound boop
2020
1:main└─┬─┬─ wraparound::recurse
2121
1:main │ └─ i=6
@@ -30,8 +30,8 @@
3030
1:main │ └─ i=9
3131
1:main────────┘
3232
1:main WARN wraparound boop
33-
1:mainwraparound::recurse
34-
1:main i=10
33+
1:main┬─┬─ wraparound::recurse
34+
1:main│ └─ i=10
3535
1:main├─ WARN wraparound boop
3636
1:main└─┬─┬─ wraparound::recurse
3737
1:main │ └─ i=11
@@ -46,8 +46,8 @@
4646
1:main │ └─ i=14
4747
1:main────────┘
4848
1:main WARN wraparound boop
49-
1:mainwraparound::recurse
50-
1:main i=15
49+
1:main┬─┬─ wraparound::recurse
50+
1:main│ └─ i=15
5151
1:main├─ WARN wraparound boop
5252
1:main└─┬─┬─ wraparound::recurse
5353
1:main │ └─ i=16
@@ -62,8 +62,8 @@
6262
1:main │ └─ i=19
6363
1:main────────┘
6464
1:main WARN wraparound boop
65-
1:mainwraparound::recurse
66-
1:main i=20
65+
1:main┬─┬─ wraparound::recurse
66+
1:main│ └─ i=20
6767
1:main├─ WARN wraparound boop
6868
1:main└─┬─┬─ wraparound::recurse
6969
1:main │ └─ i=21

src/format.rs

Lines changed: 75 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -335,29 +335,12 @@ fn indent_block_with_lines(
335335

336336
if lines.is_empty() {
337337
return;
338-
} else if indent_spaces == 0 {
339-
for line in lines {
340-
buf.push_str(prefix);
341-
// The first indent is special, we only need to print open/close and nothing else
342-
if indent == 0 {
343-
match style {
344-
SpanMode::Open { .. } => buf.push_str(LINE_OPEN),
345-
SpanMode::Retrace { .. } => buf.push_str(LINE_OPEN),
346-
SpanMode::Close { .. } => buf.push_str(LINE_CLOSE),
347-
SpanMode::PreOpen { .. } | SpanMode::PostClose => {}
348-
SpanMode::Event => {}
349-
}
350-
}
351-
buf.push_str(line);
352-
buf.push('\n');
353-
}
354-
return;
355338
}
356339

357340
let mut s = String::with_capacity(indent_spaces + prefix.len());
358341
s.push_str(prefix);
359342

360-
for _ in 0..(indent_spaces - indent_amount) {
343+
for _ in 0..indent_spaces.saturating_sub(indent_amount) {
361344
s.push(' ');
362345
}
363346

@@ -388,9 +371,11 @@ fn indent_block_with_lines(
388371
}
389372
}
390373
SpanMode::Open { verbose: false } | SpanMode::Retrace { verbose: false } => {
391-
buf.push(LINE_OPEN2);
392-
for _ in 1..indent_amount {
393-
buf.push_str(LINE_HORIZ);
374+
if indent_spaces != 0 {
375+
buf.push(LINE_OPEN2);
376+
for _ in 1..indent_amount {
377+
buf.push_str(LINE_HORIZ);
378+
}
394379
}
395380
if lines.len() > 1 {
396381
buf.push_str(ARGS_BRANCH);
@@ -401,25 +386,30 @@ fn indent_block_with_lines(
401386
for _ in 1..indent_amount {
402387
buf.push_str(LINE_HORIZ);
403388
}
404-
buf.push_str(" ");
405-
for _ in 0..indent_amount {
406-
s.push(' ');
389+
buf.push(' ');
390+
391+
if indent_spaces != 0 {
392+
for _ in 0..indent_amount {
393+
s.push(' ');
394+
}
407395
}
408396
} else {
409397
buf.push_str(LINE_OPEN);
410398
}
411399
}
412400
SpanMode::Open { verbose: true } | SpanMode::Retrace { verbose: true } => {
413-
buf.push(' ');
414-
for _ in 1..(indent_amount / 2) {
401+
if indent_spaces != 0 {
415402
buf.push(' ');
416-
}
417-
// We don't have the space for fancy rendering at single space indent.
418-
if indent_amount > 1 {
419-
buf.push(LINE_OPEN2);
420-
}
421-
for _ in (indent_amount / 2)..(indent_amount - 1) {
422-
buf.push_str(LINE_HORIZ);
403+
for _ in 1..(indent_amount / 2) {
404+
buf.push(' ');
405+
}
406+
// We don't have the space for fancy rendering at single space indent.
407+
if indent_amount > 1 {
408+
buf.push(LINE_OPEN2);
409+
}
410+
for _ in (indent_amount / 2)..(indent_amount - 1) {
411+
buf.push_str(LINE_HORIZ);
412+
}
423413
}
424414
// We don't have the space for fancy rendering at single space indent.
425415
if indent_amount > 1 {
@@ -432,9 +422,11 @@ fn indent_block_with_lines(
432422
for _ in 1..indent_amount {
433423
buf.push_str(LINE_HORIZ);
434424
}
435-
buf.push_str(" ");
436-
for _ in 0..indent_amount {
437-
s.push(' ');
425+
buf.push(' ');
426+
if indent_spaces != 0 {
427+
for _ in 0..indent_amount {
428+
s.push(' ');
429+
}
438430
}
439431
} else {
440432
buf.push_str(LINE_OPEN);
@@ -444,23 +436,27 @@ fn indent_block_with_lines(
444436
}
445437
}
446438
SpanMode::Close { verbose: false } => {
447-
buf.push(LINE_CLOSE2);
448-
for _ in 1..indent_amount {
449-
buf.push_str(LINE_HORIZ);
439+
if indent_spaces != 0 {
440+
buf.push(LINE_CLOSE2);
441+
for _ in 1..indent_amount {
442+
buf.push_str(LINE_HORIZ);
443+
}
450444
}
451445
buf.push_str(LINE_CLOSE);
452446
}
453447
SpanMode::Close { verbose: true } => {
454-
buf.push(' ');
455-
for _ in 1..(indent_amount / 2) {
448+
if indent_spaces != 0 {
456449
buf.push(' ');
457-
}
458-
// We don't have the space for fancy rendering at single space indent.
459-
if indent_amount > 1 {
460-
buf.push(LINE_CLOSE2);
461-
}
462-
for _ in (indent_amount / 2)..(indent_amount - 1) {
463-
buf.push_str(LINE_HORIZ);
450+
for _ in 1..(indent_amount / 2) {
451+
buf.push(' ');
452+
}
453+
// We don't have the space for fancy rendering at single space indent.
454+
if indent_amount > 1 {
455+
buf.push(LINE_CLOSE2);
456+
}
457+
for _ in (indent_amount / 2)..(indent_amount - 1) {
458+
buf.push_str(LINE_HORIZ);
459+
}
464460
}
465461
// We don't have the space for fancy rendering at single space indent.
466462
if indent_amount > 1 {
@@ -473,9 +469,12 @@ fn indent_block_with_lines(
473469
for _ in 1..indent_amount {
474470
buf.push_str(LINE_HORIZ);
475471
}
476-
buf.push_str(" ");
477-
for _ in 0..indent_amount - 1 {
478-
s.push(' ');
472+
buf.push(' ');
473+
474+
if indent_spaces != 0 {
475+
for _ in 0..indent_amount - 1 {
476+
s.push(' ');
477+
}
479478
}
480479
} else {
481480
buf.push_str(LINE_CLOSE);
@@ -507,31 +506,44 @@ fn indent_block_with_lines(
507506
}
508507
}
509508
SpanMode::Event => {
510-
buf.push_str(LINE_BRANCH);
509+
if indent_spaces != 0 {
510+
buf.push_str(LINE_BRANCH);
511+
}
511512
if lines.len() > 1 {
512-
for _ in 0..(indent_amount - 1) {
513-
buf.push_str(LINE_HORIZ);
513+
if indent_spaces != 0 {
514+
for _ in 0..(indent_amount - 1) {
515+
buf.push_str(LINE_HORIZ);
516+
}
514517
}
515518
buf.push_str(ARGS_BRANCH);
516519
}
517520

518-
// add `indent_amount - 1` horizontal lines before the span/event
519-
for _ in 0..(indent_amount - 1) {
520-
buf.push_str(LINE_HORIZ);
521+
if indent_spaces != 0 {
522+
// add `indent_amount - 1` horizontal lines before the span/event
523+
for _ in 0..(indent_amount - 1) {
524+
buf.push_str(LINE_HORIZ);
525+
}
521526
}
522527
}
523528
}
524529
buf.push_str(lines[0]);
525530
buf.push('\n');
526531

527-
// add the rest of the indentation, since we don't want to draw horizontal lines
528-
// for subsequent lines
529-
for i in 0..indent_amount {
530-
if i % indent_amount == 0 {
531-
s.push_str(LINE_VERT);
532-
} else {
532+
match style {
533+
SpanMode::Close { verbose: true } if indent_spaces == 0 => {
533534
s.push(' ');
534535
}
536+
_ => {
537+
// add the rest of the indentation, since we don't want to draw horizontal lines
538+
// for subsequent lines
539+
for i in 0..indent_amount {
540+
if i % indent_amount == 0 {
541+
s.push_str(LINE_VERT);
542+
} else {
543+
s.push(' ');
544+
}
545+
}
546+
}
535547
}
536548

537549
// add all of the actual content, with each line preceded by the indent string

0 commit comments

Comments
 (0)