You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VConsole.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client;
  5. import java.util.Set;
  6. import com.google.gwt.core.client.GWT;
  7. /**
  8. * A helper class to do some client side logging.
  9. * <p>
  10. * This class replaces previously used loggin style:
  11. * ApplicationConnection.getConsole().log("foo").
  12. * <p>
  13. * The default widgetset provides three modes for debugging:
  14. * <ul>
  15. * <li>NullConsole (Default, displays no errors at all)
  16. * <li>VDebugConsole ( Enabled by appending ?debug to url. Displays a floating
  17. * console in the browser and also prints to browsers internal console (builtin
  18. * or Firebug) and GWT's development mode console if available.)
  19. * <li>VDebugConsole in quiet mode (Enabled by appending ?debug=quiet. Same as
  20. * previous but without the console floating over application).
  21. * </ul>
  22. * <p>
  23. * Implementations can be customized with GWT deferred binding by overriding
  24. * NullConsole.class or VDebugConsole.class. This way developer can for example
  25. * build mechanism to send client side logging data to a server.
  26. * <p>
  27. * Note that logging in client side is not fully optimized away even in
  28. * production mode. Use logging moderately in production code to keep the size
  29. * of client side engine small. An exception is {@link GWT#log(String)} style
  30. * logging, which is available only in GWT development mode, but optimized away
  31. * when compiled to web mode.
  32. *
  33. *
  34. * TODO improve javadocs of individual methods
  35. *
  36. */
  37. public class VConsole {
  38. private static Console impl;
  39. /**
  40. * Used by ApplicationConfiguration to initialize VConsole.
  41. *
  42. * @param console
  43. */
  44. static void setImplementation(Console console) {
  45. impl = console;
  46. }
  47. /**
  48. * Used by ApplicationConnection to support deprecated getConsole() api.
  49. */
  50. static Console getImplementation() {
  51. return impl;
  52. }
  53. public static void log(String msg) {
  54. impl.log(msg);
  55. }
  56. public static void log(Throwable e) {
  57. impl.log(e);
  58. }
  59. public static void error(Throwable e) {
  60. impl.error(e);
  61. }
  62. public static void error(String msg) {
  63. impl.error(msg);
  64. }
  65. public static void printObject(Object msg) {
  66. impl.printObject(msg);
  67. }
  68. public static void dirUIDL(ValueMap u, ApplicationConfiguration cnf) {
  69. impl.dirUIDL(u, cnf);
  70. }
  71. public static void printLayoutProblems(ValueMap meta,
  72. ApplicationConnection applicationConnection,
  73. Set<VPaintableWidget> zeroHeightComponents,
  74. Set<VPaintableWidget> zeroWidthComponents) {
  75. impl.printLayoutProblems(meta, applicationConnection,
  76. zeroHeightComponents, zeroWidthComponents);
  77. }
  78. }