From f733d07118014a1adb43da922ad39cc926b58c7e Mon Sep 17 00:00:00 2001 From: Sami Vaarala Date: Fri, 13 May 2016 03:51:00 +0300 Subject: [PATCH] Add DUK_CMDLINE_LOGGING_SUPPORT to 'duk' tool --- examples/cmdline/duk_cmdline.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/cmdline/duk_cmdline.c b/examples/cmdline/duk_cmdline.c index 7b0e68fc..ac69980e 100644 --- a/examples/cmdline/duk_cmdline.c +++ b/examples/cmdline/duk_cmdline.c @@ -1,12 +1,20 @@ /* * Command line execution tool. Useful for test cases and manual testing. * - * To enable print()/alert() bindings, define DUK_CMDLINE_PRINTALERT_SUPPORT. - * To enable console.log() etc, define DUK_CMDLINE_CONSOLE_SUPPORT. + * Optional features: * - * To enable linenoise and other fancy stuff, compile with -DDUK_CMDLINE_FANCY. - * It is not the default to maximize portability. You can also compile in - * support for example allocators, grep for DUK_CMDLINE_*. + * - To enable print()/alert() bindings, define DUK_CMDLINE_PRINTALERT_SUPPORT + * and add extras/print-alert/duk_print_alert.c to compilation. + * + * - To enable console.log() etc, define DUK_CMDLINE_CONSOLE_SUPPORT + * and add extras/console/duk_console.c to compilation. + * + * - To enable Duktape.Logger, define DUK_CMDLINE_LOGGING_SUPPORT + * and add extras/logging/duk_logging.c to compilation. + * + * - To enable linenoise and other fancy stuff, compile with -DDUK_CMDLINE_FANCY. + * It is not the default to maximize portability. You can also compile in + * support for example allocators, grep for DUK_CMDLINE_*. */ /* Helper define to enable a feature set; can also use separate defines. */ @@ -49,6 +57,9 @@ #if defined(DUK_CMDLINE_CONSOLE_SUPPORT) #include "duk_console.h" #endif +#if defined(DUK_CMDLINE_LOGGING_SUPPORT) +#include "duk_logging.h" +#endif #if defined(DUK_CMDLINE_FILEIO) #include #endif @@ -1109,6 +1120,11 @@ static duk_context *create_duktape_heap(int alloc_provider, int debugger, int aj duk_console_init(ctx, DUK_CONSOLE_PROXY_WRAPPER /*flags*/); #endif + /* Register Duktape.Logger (removed in Duktape 2.x). */ +#if defined(DUK_CMDLINE_LOGGING_SUPPORT) + duk_logging_init(ctx, 0 /*flags*/); +#endif + #if defined(DUK_CMDLINE_FILEIO) duk_push_c_function(ctx, fileio_read_file, 1 /*nargs*/); duk_put_global_string(ctx, "readFile");