jsconsole.nim 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2012 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. ## Wrapper for the `console` object for the `JavaScript backend
  10. ## <backends.html#backends-the-javascript-target>`_.
  11. when not defined(js) and not defined(Nimdoc):
  12. {.error: "This module only works on the JavaScript platform".}
  13. type Console* = ref object of RootObj
  14. proc log*(console: Console) {.importcpp, varargs.}
  15. ## https://developer.mozilla.org/docs/Web/API/Console/log
  16. proc debug*(console: Console) {.importcpp, varargs.}
  17. ## https://developer.mozilla.org/docs/Web/API/Console/debug
  18. proc info*(console: Console) {.importcpp, varargs.}
  19. ## https://developer.mozilla.org/docs/Web/API/Console/info
  20. proc error*(console: Console) {.importcpp, varargs.}
  21. ## https://developer.mozilla.org/docs/Web/API/Console/error
  22. template exception*(console: Console, args: varargs[untyped]) =
  23. ## Alias for `console.error()`.
  24. error(console, args)
  25. proc trace*(console: Console) {.importcpp, varargs.}
  26. ## https://developer.mozilla.org/docs/Web/API/Console/trace
  27. proc warn*(console: Console) {.importcpp, varargs.}
  28. ## https://developer.mozilla.org/docs/Web/API/Console/warn
  29. proc clear*(console: Console) {.importcpp, varargs.}
  30. ## https://developer.mozilla.org/docs/Web/API/Console/clear
  31. proc count*(console: Console, label = "".cstring) {.importcpp.}
  32. ## https://developer.mozilla.org/docs/Web/API/Console/count
  33. proc countReset*(console: Console, label = "".cstring) {.importcpp.}
  34. ## https://developer.mozilla.org/docs/Web/API/Console/countReset
  35. proc group*(console: Console, label = "".cstring) {.importcpp.}
  36. ## https://developer.mozilla.org/docs/Web/API/Console/group
  37. proc groupCollapsed*(console: Console, label = "".cstring) {.importcpp.}
  38. ## https://developer.mozilla.org/en-US/docs/Web/API/Console/groupCollapsed
  39. proc groupEnd*(console: Console) {.importcpp.}
  40. ## https://developer.mozilla.org/docs/Web/API/Console/groupEnd
  41. proc time*(console: Console, label = "".cstring) {.importcpp.}
  42. ## https://developer.mozilla.org/docs/Web/API/Console/time
  43. proc timeEnd*(console: Console, label = "".cstring) {.importcpp.}
  44. ## https://developer.mozilla.org/docs/Web/API/Console/timeEnd
  45. proc timeLog*(console: Console, label = "".cstring) {.importcpp.}
  46. ## https://developer.mozilla.org/docs/Web/API/Console/timeLog
  47. proc table*(console: Console) {.importcpp, varargs.}
  48. ## https://developer.mozilla.org/docs/Web/API/Console/table
  49. var console* {.importc, nodecl.}: Console