Minimal 'console' binding
Duktape doesn't provide a
console binding (for example
by default because it would be a portability issue for some targets. Instead,
an application should provide its own
console binding. This directory
contains an example binding:
duk_console.cto list of C sources to compile.
duk_console.his in the include path.
Include the extra header in calling code and initialize the bindings:
#include "duktape.h" #include "duk_console.h" /* After initializing the Duktape heap or when creating a new * thread with a new global environment: */ duk_console_init(ctx, 0 /*flags*/);
DUK_CONSOLE_PROXY_WRAPPERto enable a Proxy wrapper for the console object. The wrapper allows all undefined methods (for example,
console.foo) to be handled as no-ops instead of throwing an error. See
duk_console.hfor full flags list.
After these steps,
consolewill be registered to the global object and is ready to use.
By default the console object will use
stdoutfor log levels up to info, and
stderrfor warning and above. You can change this by providing either