mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-06 11:54:11 +00:00
Updated js console logging to avoid wrapping into array
This commit is contained in:
@@ -18,22 +18,9 @@ type Console* {.importc.} = ref object of RootObj
|
||||
proc convertToConsoleLoggable*[T](v: T): RootRef {.importcpp: "#".}
|
||||
template convertToConsoleLoggable*(v: string): RootRef = cast[RootRef](cstring(v))
|
||||
|
||||
proc log*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.log(#)".}
|
||||
proc debug*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.debug(#)".}
|
||||
proc info*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.info(#)".}
|
||||
proc error*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.error(#)".}
|
||||
|
||||
{.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))
|
||||
proc log*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.log.apply(null, #)".}
|
||||
proc debug*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.debug.apply(null, #)".}
|
||||
proc info*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.info.apply(null, #)".}
|
||||
proc error*(console: Console, args: varargs[RootRef, convertToConsoleLoggable]) {.importcpp: "#.error.apply(null, #)".}
|
||||
|
||||
var console* {.importc, nodecl.}: Console
|
||||
@@ -1,9 +1,13 @@
|
||||
discard """
|
||||
output: "Hello, console"
|
||||
output: '''Hello, console
|
||||
1 2 3
|
||||
1 'hi' 1.1'''
|
||||
"""
|
||||
|
||||
# This file tests the JavaScript console
|
||||
|
||||
import jsconsole
|
||||
|
||||
console.log("Hello, console")
|
||||
console.log("Hello, console")
|
||||
console.log(1, 2, 3)
|
||||
console.log(1, "hi", 1.1)
|
||||
Reference in New Issue
Block a user