ngs-lang / ngs

Next Generation Shell (NGS)
https://ngs-lang.org/
GNU General Public License v3.0
1.46k stars 41 forks source link

Support nesting in log() #480

Open ilyash-b opened 3 years ago

ilyash-b commented 3 years ago

Requirements

ilyash commented 3 years ago

Maybe: log("Processing file X", ??? log("processing line Y") ???), where ??? stands for undecided syntax

ilyash commented 3 years ago

Maybe without introducing new syntax:

log("reading file X", F(log) {
    # Nested:
    log("reading line 1")
    ...
})

This can automatically add "start" and "end" for the section. Maybe also let know about exception if it occurs in the callback. Sample output:

... reading file X - start
...
... [reading file X] reading line 1
...
... reading file X - end

Likely, debug() and other functions need similar functionality, maybe a generic facility should be developed.

ilyash commented 3 years ago

TODO: Think about integration with different facilities and methods, similar to $(log: ....)