Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package de.swm.gwt.client.logging;
 
 
GWT logging handler that writes log messages to local storage. Useful for devices where no Javascript console is available and remote logging is impossible / has side effects.

Author(s):
wimmel.guido copyright (C) 2012, SWM Services GmbH
public class LocalStorageLogHandler extends Handler {
	private static final String LASTLOGMSG_KEY = "localStorageLog.lastMessage";
	private static final String ALLLOGMSG_KEY = "localStorageLog.allMessages";
	private final Storage localStorage;
	}
	public void publish(LogRecord record) {
		if (!isSupported() || !isLoggable(record)) {
			return;
		}
		String msg = getFormatter().format(record);
		log(msg);
	}
	public void flush() {
	}
	public void close() {
	}
	private boolean isSupported() {
		return  != null;
	}
	private void log(String msg) {
		String previousLogMessages = .getItem();
		if (previousLogMessages == null) {
			previousLogMessages = "";
		}
		.setItem(previousLogMessages + msg + "\n");
	}
New to GrepCode? Check out our FAQ X