test-console-server-logging.sjs 819 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. function handleRequest(request, response)
  6. {
  7. var page = "<!DOCTYPE html><html>" +
  8. "<head><meta charset='utf-8'></head>" +
  9. "<body><p>hello world!</p></body>" +
  10. "</html>";
  11. var data = {
  12. "version": "4.1.0",
  13. "columns": ["log", "backtrace", "type"],
  14. "rows": [[
  15. ["values: %s %o %i %f %s","string",{"a":10,"___class_name":"Object"},123,1.12, "\u2713"],
  16. "C:\\src\\www\\serverlogging\\test7.php:4:1",
  17. ""
  18. ]]
  19. };
  20. // Put log into headers.
  21. var value = b64EncodeUnicode(JSON.stringify(data));
  22. response.setHeader("X-ChromeLogger-Data", value, false);
  23. response.write(page);
  24. }
  25. function b64EncodeUnicode(str) {
  26. return btoa(unescape(encodeURIComponent(str)));
  27. }