|
|
@ -17,17 +17,21 @@ static const duk_uint8_t duk__log_level_strings[] = { |
|
|
|
/* Constructor */ |
|
|
|
duk_ret_t duk_bi_logger_constructor(duk_context *ctx) { |
|
|
|
duk_hthread *thr = (duk_hthread *) ctx; |
|
|
|
duk_int_t nargs; /* FIXME: type */ |
|
|
|
|
|
|
|
/* Calling as a non-constructor is not meaningful. */ |
|
|
|
if (!duk_is_constructor_call(ctx)) { |
|
|
|
return DUK_RET_TYPE_ERROR; |
|
|
|
} |
|
|
|
|
|
|
|
nargs = duk_get_top(ctx); |
|
|
|
duk_set_top(ctx, 1); |
|
|
|
|
|
|
|
duk_push_this(ctx); |
|
|
|
|
|
|
|
/* [ name this ] */ |
|
|
|
|
|
|
|
if (duk_is_undefined(ctx, 0)) { |
|
|
|
if (nargs == 0) { |
|
|
|
/* Automatic defaulting of logger name from caller. */ |
|
|
|
if (thr->callstack_top >= 2) { |
|
|
|
duk_activation *act_caller = thr->callstack + thr->callstack_top - 2; |
|
|
|