Implemented altocumulus’s answer from (javascript - D3 console.log in a function chain - Stack Overflow)
…in a notebook:
Works in the notebook but when I import it into a notebook and try to use one of the functions I get nothing. No errors and no output.
Don’t know if it is of interest but originally I had coded his object exactly from StackOverflow but received errors, his comment about wrapping the object in parens fixed it…
That’s some peculiarity of Observable’s code. The first code block chokes on an “Unexpected Token” and, if you look closely at the top right corner of that code block, you’ll see some icon resembling a magic wand which has a tooltip reading “Objects need to be parenthesized to differentiate them from blocks”. To make it work, simply wrap your logger object in parentheses like so:
logger = ({ log() { }, /****/ });
. – altocumulus [22 hours ago]