Updated js console logging to avoid wrapping into array
This commit is contained in:
parent
25ee55adfc
commit
4c52239394
2 changed files with 10 additions and 19 deletions
|
|
@ -18,22 +18,9 @@ type Console* {.importc.} = ref object of RootObj
|
||||||
proc convertToConsoleLoggable*[T](v: T): RootRef {.importcpp: "#".}
|
proc convertToConsoleLoggable*[T](v: T): RootRef {.importcpp: "#".}
|
||||||
template convertToConsoleLoggable*(v: string): RootRef = cast[RootRef](cstring(v))
|
template convertToConsoleLoggable*(v: string): RootRef = cast[RootRef](cstring(v))
|
||||||
|
|
||||||
proc log*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.log(#)".}
|
proc log*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.log.apply(null, #)".}
|
||||||
proc debug*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.debug(#)".}
|
proc debug*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.debug.apply(null, #)".}
|
||||||
proc info*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.info(#)".}
|
proc info*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.info.apply(null, #)".}
|
||||||
proc error*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.error(#)".}
|
proc error*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.error.apply(null, #)".}
|
||||||
|
|
||||||
{.push importcpp .}
|
|
||||||
|
|
||||||
proc log*[A](console: Console, a: A)
|
|
||||||
proc debug*[A](console: Console, a: A)
|
|
||||||
proc info*[A](console: Console, a: A)
|
|
||||||
proc error*[A](console: Console, a: A)
|
|
||||||
|
|
||||||
{.pop.}
|
|
||||||
proc log*(console: Console, a: string) = console.log(cstring(a))
|
|
||||||
proc debug*(console: Console, a: string) = console.log(cstring(a))
|
|
||||||
proc info*(console: Console, a: string) = console.log(cstring(a))
|
|
||||||
proc error*(console: Console, a: string) = console.log(cstring(a))
|
|
||||||
|
|
||||||
var console* {.importc, nodecl.}: Console
|
var console* {.importc, nodecl.}: Console
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
output: "Hello, console"
|
output: '''Hello, console
|
||||||
|
1 2 3
|
||||||
|
1 'hi' 1.1'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This file tests the JavaScript console
|
# This file tests the JavaScript console
|
||||||
|
|
@ -7,3 +9,5 @@ discard """
|
||||||
import jsconsole
|
import jsconsole
|
||||||
|
|
||||||
console.log("Hello, console")
|
console.log("Hello, console")
|
||||||
|
console.log(1, 2, 3)
|
||||||
|
console.log(1, "hi", 1.1)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue