2 * Copyright (C) 2011 Openismus GmbH
4 * This file is part of GWT-Glom.
6 * GWT-Glom is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
11 * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with GWT-Glom. If not, see <http://www.gnu.org/licenses/>.
20 package org.glom.web.server;
22 import org.apache.commons.lang3.StringUtils;
25 * A class that wraps methods in com.allen_sauer.gwt.log.client.Log to add the calling method name from the servlet to
31 public static void fatal(final String message, final Throwable e) {
32 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + StringUtils.defaultString(message), e);
35 public static void fatal(final String message) {
36 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + StringUtils.defaultString(message));
39 public static void fatal(final String documentID, final String tableName, final String message, final Throwable e) {
40 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
41 + StringUtils.defaultString(message), e);
44 public static void fatal(final String documentID, final String tableName, final String message) {
45 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
46 + StringUtils.defaultString(message));
49 public static void fatal(final String documentID, final String message, final Throwable e) {
50 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message), e);
53 public static void fatal(final String documentID, final String message) {
54 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message));
58 public static void error(final String message, final Throwable e) {
59 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + StringUtils.defaultString(message), e);
62 public static void error(final String message) {
63 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + StringUtils.defaultString(message));
66 public static void error(final String documentID, final String tableName, final String message, final Throwable e) {
67 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
68 + StringUtils.defaultString(message), e);
71 public static void error(final String documentID, final String tableName, final String message) {
72 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
73 + StringUtils.defaultString(message));
76 public static void error(final String documentID, final String message, final Throwable e) {
77 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message), e);
80 public static void error(final String documentID, final String message) {
81 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message));
85 public static void warn(final String message, final Throwable e) {
86 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + StringUtils.defaultString(message), e);
89 public static void warn(final String message) {
90 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + StringUtils.defaultString(message));
93 public static void warn(final String documentID, final String tableName, final String message, final Throwable e) {
94 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
95 + StringUtils.defaultString(message), e);
98 public static void warn(final String documentID, final String tableName, final String message) {
99 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
100 + StringUtils.defaultString(message));
103 public static void warn(final String documentID, final String message, final Throwable e) {
104 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message), e);
107 public static void warn(final String documentID, final String message) {
108 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message));
112 public static void info(final String message, final Throwable e) {
113 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + StringUtils.defaultString(message), e);
116 public static void info(final String message) {
117 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + StringUtils.defaultString(message));
120 public static void info(final String documentID, final String tableName, final String message, final Throwable e) {
121 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
122 + StringUtils.defaultString(message), e);
125 public static void info(final String documentID, final String tableName, final String message) {
126 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + StringUtils.defaultString(documentID) + " - " + StringUtils.defaultString(tableName) + ": "
127 + StringUtils.defaultString(message));
130 public static void info(final String documentID, final String message, final Throwable e) {
131 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message), e);
134 public static void info(final String documentID, final String message) {
135 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + StringUtils.defaultString(documentID) + ": " + StringUtils.defaultString(message));
139 private static String getServletMethodName() {
140 final StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
141 if (stackTraces.length > 3 && "org.glom.web.server.OnlineGlomServiceImpl".equals(stackTraces[3].getClassName())) {
142 return stackTraces[3].getMethodName() + " - ";