Skip to content

Commit 1f15fd4

Browse files
committed
fix(Console): use buildLogString
1 parent 603a501 commit 1f15fd4

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

NativeScript/runtime/modules/console/Console.cpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -190,34 +190,7 @@ JS_METHOD(Console::Log) {
190190
}
191191
log << ": ";
192192

193-
for (size_t i = initialArg; i < argc; i++) {
194-
napi_valuetype type;
195-
napi_typeof(env, argv[i], &type);
196-
197-
bool hasSymbol = false;
198-
if (type == napi_object || type == napi_function) {
199-
napi_has_property(env, argv[i], symbol, &hasSymbol);
200-
}
201-
202-
napi_value argstr = nullptr;
203-
204-
if (hasSymbol) {
205-
napi_value fn;
206-
napi_get_property(env, argv[i], symbol, &fn);
207-
napi_call_function(env, argv[i], fn, 0, nullptr, &argstr);
208-
} else {
209-
napi_coerce_to_string(env, argv[i], &argstr);
210-
}
211-
212-
size_t length = 0;
213-
napi_get_value_string_utf8(env, argstr, nullptr, 0, &length);
214-
char* strbuf = (char*)malloc(length + 2);
215-
napi_get_value_string_utf8(env, argstr, strbuf, length + 2, &length);
216-
strbuf[length] = i >= (argc - 1) ? '\0' : ' ';
217-
strbuf[length + 1] = '\0';
218-
log << strbuf;
219-
free(strbuf);
220-
}
193+
log << buildLogString(env, cbinfo, initialArg);
221194

222195
log << "\n";
223196

cli_tests/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ console.log(moduleA.a());
66
console.log("performance.now() =", performance.now());
77

88
console.log("processor count", NSProcessInfo.processInfo.processorCount);
9+
10+
console.log({
11+
a: 1,
12+
b: "hello",
13+
world: true,
14+
});

0 commit comments

Comments
 (0)