eliottree icon indicating copy to clipboard operation
eliottree copied to clipboard

Be able to paginate the output of the tree

Open RoyLarson opened this issue 3 years ago • 1 comments

The purpose of this pull request is to allow the logs to be viewed as chunks. This is useful for long running tasks.

(eliot_tree) λ eliot-tree test.log -l 0 --chunk-size 10
82df7cd8-68b4-415c-ae30-e57f545142b4
└── start_fib/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.016s
    ├── FIB/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.003s
    │   ├── n: 10
    │   ├── FIB/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.003s
    │   │   ├── n: 9
    │   │   ├── FIB/2/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.003s
    │   │   │   ├── n: 8
    │   │   │   ├── FIB/2/2/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.003s
    │   │   │   │   ├── n: 7
Press any key to continue or 'X' to exit or 'T' for next task:

    │   │   │   │   ├── FIB/2/2/2/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.001s
    │   │   │   │   │   ├── n: 6
    │   │   │   │   │   ├── FIB/2/2/2/2/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.001s
    │   │   │   │   │   │   ├── n: 5
    │   │   │   │   │   │   ├── FIB/2/2/2/2/2/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.001s
    │   │   │   │   │   │   │   ├── n: 4
    │   │   │   │   │   │   │   ├── FIB/2/2/2/2/2/2/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.000s
    │   │   │   │   │   │   │   │   ├── n: 3
    │   │   │   │   │   │   │   │   ├── FIB/2/2/2/2/2/2/2/2/2/1 ⇒ started 2020-08-21 15:16:13Z ⧖ 0.000s
    │   │   │   │   │   │   │   │   │   ├── n: 2
Press any key to continue or 'X' to exit or 'T' for next task:

to make the log for the example I ran the code below several times

from pathlib import Path
from eliot import log_call, to_file, log_message, start_task, start_action
to_file(Path("test.log").open("ab+"))

@log_call(action_type="FIB", include_args=['n'], include_result=True)
def fib(n):
    if n==1 or n==0:
        return n
    return n+fib(n-1)

def main(n):
    with start_task(action_type="start_fib") as task:
        n = fib(n)
        task.log(message_type='result', n=n)
    print(n)

if __name__=='__main__':
    main(30)


This change is Reviewable

RoyLarson avatar Aug 21 '20 15:08 RoyLarson

Any update on other changes you would like?

RoyLarson avatar Jan 18 '21 22:01 RoyLarson