001/* 002 * GWTEventService 003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt) 004 * 005 * This is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as 007 * published by the Free Software Foundation; either version 3 of 008 * the License, or (at your option) any later version. 009 * Other licensing for GWTEventService may also be possible on request. 010 * Please view the license.txt of the project for more information. 011 * 012 * This software is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * You should have received a copy of the GNU Lesser General Public 018 * License along with this software; if not, write to the Free 019 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 020 * 02110-1301 USA, or see the FSF site: http://www.fsf.org. 021 */ 022package de.novanic.eventservice.client.logger; 023 024import com.google.gwt.core.client.GWT; 025 026/** 027 * This {@link de.novanic.eventservice.client.logger.ClientLogger} uses {@link com.google.gwt.core.client.GWT#log(String, Throwable)} 028 * to log client messages. 029 * {@link de.novanic.eventservice.client.logger.ClientLogger} can be used to log at the server side. 030 * 031 * @author sstrohschein 032 * <br>Date: 14.08.2008 033 * <br>Time: 21:19:21 034 */ 035public class GWTClientLogger extends AbstractClientLogger 036{ 037 private static final String CLIENT_PREFIX = "Client: "; 038 private static final String CLIENT_ERROR_PREFIX = "Client-Error: "; 039 040 protected GWTClientLogger() {} 041 042 /** 043 * Logs messages at the info level. 044 * @param aMessage message to log 045 */ 046 public void log_internal(String aMessage) { 047 log(aMessage, CLIENT_PREFIX, null); 048 } 049 050 /** 051 * Logs messages at the error level. 052 * @param aMessage message to log 053 */ 054 public void error_internal(String aMessage) { 055 log(aMessage, CLIENT_ERROR_PREFIX, null); 056 } 057 058 /** 059 * Logs messages at the error level. 060 * @param aMessage message to log 061 * @param aThrowable throwable to log 062 */ 063 public void error_internal(String aMessage, Throwable aThrowable) { 064 log(aMessage, CLIENT_ERROR_PREFIX, aThrowable); 065 } 066 067 /** 068 * Logs a message with a prefix and a throwable. 069 * @param aMessage message to log 070 * @param aPrefix prefix (the message will be appended to the prefix) 071 * @param aThrowable throwable to log 072 */ 073 private static void log(String aMessage, String aPrefix, Throwable aThrowable) { 074 GWT.log(aPrefix + aMessage, aThrowable); 075 } 076}