ngs icon indicating copy to clipboard operation
ngs copied to clipboard

Support nesting in log()

Open ilyash-b opened this issue 3 years ago • 3 comments

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

ilyash-b avatar Sep 16 '21 13:09 ilyash-b

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

ilyash avatar Sep 17 '21 18:09 ilyash

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 avatar Sep 18 '21 18:09 ilyash

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

ilyash avatar Sep 18 '21 18:09 ilyash