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 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * Copyright 2000-2018 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.client;
  17. import java.util.logging.Level;
  18. import java.util.logging.Logger;
  19. import com.google.gwt.logging.client.LogConfiguration;
  20. import com.vaadin.client.debug.internal.VDebugWindow;
  21. /**
  22. * A helper class to do some client side logging.
  23. *
  24. * @deprecated as of 7.1, use {@link Logger} from java.util.logging instead.
  25. */
  26. @Deprecated
  27. public class VConsole {
  28. private static VDebugWindow impl;
  29. /**
  30. * Used by ApplicationConfiguration to initialize VConsole.
  31. *
  32. * @param console
  33. */
  34. static void setImplementation(VDebugWindow console) {
  35. impl = console;
  36. }
  37. public static void log(String msg) {
  38. if (LogConfiguration.loggingIsEnabled(Level.INFO)) {
  39. // Check for null, so no NullPointerException is generated when
  40. // formatting (#12588)
  41. getLogger().log(Level.INFO, msg == null ? "null" : msg);
  42. }
  43. }
  44. public static void log(Throwable e) {
  45. if (LogConfiguration.loggingIsEnabled(Level.INFO)) {
  46. // Check for null, so no NullPointerException is generated when
  47. // formatting (#12588)
  48. getLogger().log(Level.INFO,
  49. e.getMessage() == null ? "" : e.getMessage(), e);
  50. }
  51. }
  52. public static void error(Throwable e) {
  53. if (LogConfiguration.loggingIsEnabled(Level.SEVERE)) {
  54. // Check for null, so no NullPointerException is generated when
  55. // formatting (#12588)
  56. getLogger().log(Level.SEVERE,
  57. e.getMessage() == null ? "" : e.getMessage(), e);
  58. }
  59. }
  60. public static void error(String msg) {
  61. if (LogConfiguration.loggingIsEnabled(Level.SEVERE)) {
  62. // Check for null, so no NullPointerException is generated when
  63. // formatting (#12588)
  64. getLogger().log(Level.SEVERE, msg == null ? "null" : msg);
  65. }
  66. }
  67. public static void printObject(Object msg) {
  68. String str;
  69. if (msg == null) {
  70. str = "null";
  71. } else {
  72. str = msg.toString();
  73. }
  74. log(str);
  75. }
  76. public static void dirUIDL(ValueMap u, ApplicationConnection client) {
  77. if (impl != null) {
  78. impl.uidl(client, u);
  79. }
  80. }
  81. public static void printLayoutProblems(ValueMap meta,
  82. ApplicationConnection applicationConnection) {
  83. if (impl != null) {
  84. impl.meta(applicationConnection, meta);
  85. }
  86. }
  87. private static Logger getLogger() {
  88. return Logger.getLogger(VConsole.class.getName());
  89. }
  90. }