ngs
ngs copied to clipboard
Support nesting in log()
Requirements
- Handle situation where called code also does logging. It should be at top level, disregarding of "your" state. This probably rules out dynamic scope implementation (which does not exist in NGS anyway). Edit: not so sure anymore
- Should be easy to use
- Should align well and integrate well with other facilities in the language
Maybe: log("Processing file X", ??? log("processing line Y") ???)
, where ???
stands for undecided syntax
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.
TODO: Think about integration with different facilities and methods, similar to $(log: ....)