Reports: Use quickFind.
[online-glom:gwt-glom.git] / src / main / java / org / glom / web / server / Log.java
1 /*
2  * Copyright (C) 2011 Openismus GmbH
3  *
4  * This file is part of GWT-Glom.
5  *
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.
10  *
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
14  * for more details.
15  *
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/>.
18  */
19
20 package org.glom.web.server;
21
22 /**
23  * A class that wraps methods in com.allen_sauer.gwt.log.client.Log to add the calling method name from the servlet to
24  * log messages.
25  */
26 public class Log {
27
28         // Fatal methods
29         public static void fatal(String message, Throwable e) {
30                 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + message, e);
31         }
32
33         public static void fatal(String message) {
34                 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + message);
35         }
36
37         public static void fatal(String documentID, String tableName, String message, Throwable e) {
38                 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + documentID + " - " + tableName + ": "
39                                 + message, e);
40         }
41
42         public static void fatal(String documentID, String tableName, String message) {
43                 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + documentID + " - " + tableName + ": "
44                                 + message);
45         }
46
47         public static void fatal(String documentID, String message, Throwable e) {
48                 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + documentID + ": " + message, e);
49         }
50
51         public static void fatal(String documentID, String message) {
52                 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + documentID + ": " + message);
53         }
54
55         // Error methods
56         public static void error(String message, Throwable e) {
57                 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + message, e);
58         }
59
60         public static void error(String message) {
61                 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + message);
62         }
63
64         public static void error(String documentID, String tableName, String message, Throwable e) {
65                 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + documentID + " - " + tableName + ": "
66                                 + message, e);
67         }
68
69         public static void error(String documentID, String tableName, String message) {
70                 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + documentID + " - " + tableName + ": "
71                                 + message);
72         }
73
74         public static void error(String documentID, String message, Throwable e) {
75                 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + documentID + ": " + message, e);
76         }
77
78         public static void error(String documentID, String message) {
79                 com.allen_sauer.gwt.log.client.Log.error(getServletMethodName() + documentID + ": " + message);
80         }
81
82         // Warning methods
83         public static void warn(String message, Throwable e) {
84                 com.allen_sauer.gwt.log.client.Log.fatal(getServletMethodName() + message, e);
85         }
86
87         public static void warn(String message) {
88                 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + message);
89         }
90
91         public static void warn(String documentID, String tableName, String message, Throwable e) {
92                 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + documentID + " - " + tableName + ": "
93                                 + message, e);
94         }
95
96         public static void warn(String documentID, String tableName, String message) {
97                 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + documentID + " - " + tableName + ": "
98                                 + message);
99         }
100
101         public static void warn(String documentID, String message, Throwable e) {
102                 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + documentID + ": " + message, e);
103         }
104
105         public static void warn(String documentID, String message) {
106                 com.allen_sauer.gwt.log.client.Log.warn(getServletMethodName() + documentID + ": " + message);
107         }
108
109         // Info methods
110         public static void info(String message, Throwable e) {
111                 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + message, e);
112         }
113
114         public static void info(String message) {
115                 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + message);
116         }
117
118         public static void info(String documentID, String tableName, String message, Throwable e) {
119                 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + documentID + " - " + tableName + ": "
120                                 + message, e);
121         }
122
123         public static void info(String documentID, String tableName, String message) {
124                 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + documentID + " - " + tableName + ": "
125                                 + message);
126         }
127
128         public static void info(String documentID, String message, Throwable e) {
129                 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + documentID + ": " + message, e);
130         }
131
132         public static void info(String documentID, String message) {
133                 com.allen_sauer.gwt.log.client.Log.info(getServletMethodName() + documentID + ": " + message);
134         }
135
136         // helper method
137         private static String getServletMethodName() {
138                 StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
139                 if (stackTraces.length > 3 && "org.glom.web.server.OnlineGlomServiceImpl".equals(stackTraces[3].getClassName()))
140                         return stackTraces[3].getMethodName() + " - ";
141                 return "";
142         }
143
144 }