A sample for logging
Review at http://gwt-code-reviews.appspot.com/641801
Review by: fredsa@google.com
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@8284 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/eclipse/samples/LogExample/LogExample.gwtc.launch b/eclipse/samples/LogExample/LogExample.gwtc.launch
new file mode 100644
index 0000000..35b73b9
--- /dev/null
+++ b/eclipse/samples/LogExample/LogExample.gwtc.launch
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="LogExample" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/LogExample/core/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/super" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-dev/core/super" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="LogExample"/> </runtimeClasspathEntry> "/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.Compiler"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="com.google.gwt.sample.logexample.LogExample"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="LogExample"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Xmx256M -Dgwt.devjar=${gwt_devjar}"/>
+</launchConfiguration>
diff --git a/eclipse/samples/LogExample/LogExample.launch b/eclipse/samples/LogExample/LogExample.launch
new file mode 100644
index 0000000..eb9f19b
--- /dev/null
+++ b/eclipse/samples/LogExample/LogExample.launch
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="LogExample" path="1" type="4"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/LogExample/core/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/src" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-user/core/super" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry internalArchive="/gwt-dev/core/super" path="3" type="2"/> "/>
+<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="LogExample"/> </runtimeClasspathEntry> "/>
+</listAttribute>
+<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.HostedMode"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-startupUrl LogExample.html com.google.gwt.sample.logexample.LogExample"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="LogExample"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Xmx256M -Dgwt.devjar=${gwt_devjar}"/>
+</launchConfiguration>
diff --git a/eclipse/samples/LogExample/war/LogExample.css b/eclipse/samples/LogExample/war/LogExample.css
new file mode 100644
index 0000000..8a563eb
--- /dev/null
+++ b/eclipse/samples/LogExample/war/LogExample.css
@@ -0,0 +1,38 @@
+h1 {
+ font-size: 2em;
+ font-weight: bold;
+ color: #777777;
+ margin: 40px 0px 70px;
+ text-align: center;
+}
+
+.centered {
+ text-align: center;
+}
+
+.oneArea {
+ width: 800px;
+ border-color: #777777;
+ border-width: 1px;
+ border-style: solid;
+ padding: 5px;
+}
+
+.oneLoggerController {
+ text-align: center;
+ border-color: #777777;
+ border-width: 1px;
+ border-style: solid;
+ width: 175px;
+ margin: 5px;
+ padding: 5px;
+}
+
+.customLogScrollPanel {
+ border-color: #777777;
+ border-width: 1px;
+ border-style: solid;
+ width: 700px;
+ height: 100px;
+}
+
diff --git a/eclipse/samples/LogExample/war/LogExample.html b/eclipse/samples/LogExample/war/LogExample.html
new file mode 100644
index 0000000..b21ab40
--- /dev/null
+++ b/eclipse/samples/LogExample/war/LogExample.html
@@ -0,0 +1,21 @@
+<!doctype html>
+
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <link type="text/css" rel="stylesheet" href="LogExample.css">
+
+ <title>Logging Example</title>
+ <script type="text/javascript" language="javascript"
+ src="logexample/logexample.nocache.js"></script>
+ </head>
+
+ <body>
+ <noscript>
+ <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
+ Your web browser must have JavaScript enabled
+ in order for this application to display correctly.
+ </div>
+ </noscript>
+ </body>
+</html>
diff --git a/samples/logexample/build.xml b/samples/logexample/build.xml
new file mode 100755
index 0000000..0c4168f
--- /dev/null
+++ b/samples/logexample/build.xml
@@ -0,0 +1,5 @@
+<project name="logexample" default="build" basedir=".">
+ <property name="sample.root" value="logexample" />
+ <property name="sample.module" value="LogExample" />
+ <import file="../common.ant.xml" />
+</project>
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/COPYING b/samples/logexample/src/com/google/gwt/sample/logexample/COPYING
new file mode 100644
index 0000000..d9a10c0
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/COPYING
@@ -0,0 +1,176 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/LogExample.gwt.xml b/samples/logexample/src/com/google/gwt/sample/logexample/LogExample.gwt.xml
new file mode 100644
index 0000000..91838ad
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/LogExample.gwt.xml
@@ -0,0 +1,36 @@
+<!-- -->
+<!-- Copyright 2007 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- may obtain a copy of the License at -->
+<!-- -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
+<!-- -->
+<!-- Unless required by applicable law or agreed to in writing, software -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -->
+<!-- implied. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<module rename-to="logexample">
+ <inherits name="com.google.gwt.user.User"/>
+ <inherits name="com.google.gwt.logging.Logging"/>
+ <entry-point class="com.google.gwt.sample.logexample.client.LogExample"/>
+
+ <!-- Specify the paths for translatable code -->
+ <source path='client'/>
+ <source path='shared'/>
+
+ <!-- Disable the firebug handler as an example -->
+ <set-property name="gwt.logging.firebugHandler" value="DISABLED" />
+
+ <!-- Try uncommenting some of the following to configure logging further
+ <set-property name="gwt.logging.enabled" value="FALSE"/>
+ <set-property name="gwt.logging.logLevel" value="FINE"/>
+ <set-property name="gwt.logging.consoleHandler" value="DISABLED" />
+ <set-property name="gwt.logging.developmentModeHandler" value="DISABLED" />
+ <set-property name="gwt.logging.popupHandler" value="DISABLED" />
+ <set-property name="gwt.logging.systemHandler" value="DISABLED" />
+ -->
+
+</module>
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/CustomLogArea.java b/samples/logexample/src/com/google/gwt/sample/logexample/client/CustomLogArea.java
new file mode 100644
index 0000000..10e005b
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/CustomLogArea.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.logging.client.HasWidgetsLogHandler;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Panel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+import java.util.logging.Logger;
+
+/**
+ * An example of a custom logging area using the HasWidgetsLogHandler.
+ */
+public class CustomLogArea {
+ interface MyUiBinder extends UiBinder<HTMLPanel, CustomLogArea> { }
+ private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
+ @UiField VerticalPanel customLogArea;
+ private Panel panel;
+
+ public CustomLogArea(Logger logger) {
+ panel = uiBinder.createAndBindUi(this);
+
+ // An example of adding our own custom logging area. Since VerticalPanel
+ // extends HasWidgets, and handles multiple class to add(widget) gracefully
+ // then we simply create a new HasWidgetsLogHandler with it, and add that
+ // handler to a logger. In this case, we added it to a particular logger in
+ // order to demonstrate how the logger hierarchy works, but adding it to the
+ // root logger would be fine.
+ logger.addHandler(new HasWidgetsLogHandler(customLogArea));
+ }
+
+ public Panel getPanel() {
+ return panel;
+ }
+}
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/CustomLogArea.ui.xml b/samples/logexample/src/com/google/gwt/sample/logexample/client/CustomLogArea.ui.xml
new file mode 100644
index 0000000..5ec1c93
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/CustomLogArea.ui.xml
@@ -0,0 +1,13 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel styleName='oneArea'>
+ Any existing GWT widget on the page which implements HasWidgets and allows
+ multiple add() calls can be used by the HasWidgetsLogHandler. Here we've
+ created a HasWidgetsLogHandler with a VerticalPanel and added it to the
+ Child logger (so you will only see messages from the Child logger appear
+ here).
+ <g:ScrollPanel styleName='customLogScrollPanel'>
+ <g:VerticalPanel ui:field='customLogArea' styleName='customLogArea'/>
+ </g:ScrollPanel>
+ </g:HTMLPanel>
+</ui:UiBinder>
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/HandlerController.java b/samples/logexample/src/com/google/gwt/sample/logexample/client/HandlerController.java
new file mode 100644
index 0000000..dea60ed
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/HandlerController.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.logical.shared.ValueChangeEvent;
+import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.logging.client.ConsoleLogHandler;
+import com.google.gwt.logging.client.DevelopmentModeLogHandler;
+import com.google.gwt.logging.client.FirebugLogHandler;
+import com.google.gwt.logging.client.HasWidgetsLogHandler;
+import com.google.gwt.logging.client.SystemLogHandler;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Panel;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Handler;
+import java.util.logging.Logger;
+
+/**
+ * A section allowing the user to enable and disable the different handlers
+ * attached to the Root Logger.
+ */
+public class HandlerController {
+ private class CheckboxHandler implements ValueChangeHandler<Boolean> {
+ private CheckBox checkbox;
+ private Handler handler;
+
+ public CheckboxHandler(CheckBox checkbox, Handler handler) {
+ this.checkbox = checkbox;
+ this.handler = handler;
+ }
+
+ public void onValueChange(ValueChangeEvent<Boolean> event) {
+ if (checkbox.getValue()) {
+ logger.addHandler(handler);
+ } else {
+ logger.removeHandler(handler);
+ }
+ }
+ }
+
+ interface MyUiBinder extends UiBinder<HTMLPanel, HandlerController> { }
+
+ private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
+ @UiField CheckBox consoleCheckbox;
+ @UiField CheckBox devmodeCheckbox;
+ @UiField CheckBox firebugCheckbox;
+ @UiField CheckBox popupCheckbox;
+ @UiField CheckBox remoteCheckbox;
+ @UiField CheckBox systemCheckbox;
+ private Map<String, Handler> handlers;
+ private Logger logger;
+ private Panel panel;
+
+ public HandlerController(final Logger logger) {
+ this.logger = logger;
+ panel = uiBinder.createAndBindUi(this);
+
+ Handler[] handlersArray = logger.getHandlers();
+ handlers = new HashMap<String, Handler>();
+ if (handlersArray != null) {
+ for (Handler h : handlersArray) {
+ handlers.put(h.getClass().getName(), h);
+ }
+ }
+ setupHandler(SystemLogHandler.class.getName(), systemCheckbox);
+ setupHandler(ConsoleLogHandler.class.getName(), consoleCheckbox);
+ setupHandler(DevelopmentModeLogHandler.class.getName(), devmodeCheckbox);
+ setupHandler(FirebugLogHandler.class.getName(), firebugCheckbox);
+ setupHandler(HasWidgetsLogHandler.class.getName(), popupCheckbox);
+ }
+
+ public Panel getPanel() {
+ return panel;
+ }
+
+ void setupHandler(String name, CheckBox checkbox) {
+ Handler h = handlers.get(name);
+ if (h == null) {
+ checkbox.setEnabled(false);
+ } else {
+ checkbox.setValue(true);
+ checkbox.addValueChangeHandler(new CheckboxHandler(checkbox, h));
+ }
+ }
+}
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/HandlerController.ui.xml b/samples/logexample/src/com/google/gwt/sample/logexample/client/HandlerController.ui.xml
new file mode 100644
index 0000000..9dc9421
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/HandlerController.ui.xml
@@ -0,0 +1,18 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel styleName='oneArea'>
+ The Root Logger comes with a set of handlers added by default. You can
+ configure which handlers are added in the gwt.xml file, and you can also
+ add/remove them programatically. Below, we have greyed out any handlers
+ which are not being added due to gwt.xml file configuration, and
+ checking/unchecking boxes will add/remove them programatically.
+ <br/>
+ <g:CheckBox ui:field='systemCheckbox'> System Handler </g:CheckBox>
+ <g:CheckBox ui:field='consoleCheckbox'> Console Handler </g:CheckBox>
+ <g:CheckBox ui:field='devmodeCheckbox'> Dev Mode Handler </g:CheckBox>
+ <br/>
+ <g:CheckBox ui:field='firebugCheckbox'> Firebug Handler </g:CheckBox>
+ <g:CheckBox ui:field='popupCheckbox'> Popup Handler </g:CheckBox>
+ <g:CheckBox ui:field='remoteCheckbox'> Remote Handler </g:CheckBox>
+ </g:HTMLPanel>
+</ui:UiBinder>
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/LogExample.java b/samples/logexample/src/com/google/gwt/sample/logexample/client/LogExample.java
new file mode 100644
index 0000000..826e0a3
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/LogExample.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.client;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.logging.client.HasWidgetsLogHandler;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.SimplePanel;
+
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+/**
+ * A page to help users understand logging in GWT.
+ */
+public class LogExample implements EntryPoint {
+ interface MyUiBinder extends UiBinder<HTMLPanel, LogExample> { }
+ private static Logger childLogger = Logger.getLogger("ParentLogger.Child");
+ private static Logger parentLogger = Logger.getLogger("ParentLogger");
+ private static Logger rootLogger = Logger.getLogger("");
+ private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
+ @UiField SimplePanel customLogArea;
+ @UiField SimplePanel handlerControls;
+ @UiField SimplePanel loggerControls;
+ @UiField SimplePanel logOnServerButton;
+
+ public void onModuleLoad() {
+ HTMLPanel p = uiBinder.createAndBindUi(this);
+ RootPanel.get().add(p);
+
+ loggerControls.setWidget(new LoggerController(
+ rootLogger, parentLogger, childLogger).getPanel());
+ handlerControls.setWidget(new HandlerController(rootLogger).getPanel());
+ logOnServerButton.setWidget(new ServerLoggingArea().getPanel());
+ customLogArea.setWidget(new CustomLogArea(childLogger).getPanel());
+
+ // This is kind of hacky, but we want the user to see this explanation
+ // in the popup when the page starts up, so we pull out the popup handler
+ // and publish a message directly to it. Most applications should not need
+ // to do this.
+ Handler[] handlers = Logger.getLogger("").getHandlers();
+ for (Handler h : handlers) {
+ if (h instanceof HasWidgetsLogHandler) {
+ String msg = "This popup can be resized, moved and minimized";
+ h.publish(new LogRecord(Level.SEVERE, msg));
+ }
+ }
+ }
+}
+
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/LogExample.ui.xml b/samples/logexample/src/com/google/gwt/sample/logexample/client/LogExample.ui.xml
new file mode 100644
index 0000000..e281a4d
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/LogExample.ui.xml
@@ -0,0 +1,12 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel>
+ <div align='center'>
+ <h1>Logging Example</h1>
+ <g:SimplePanel ui:field="loggerControls"/><br/><br/>
+ <g:SimplePanel ui:field="customLogArea"/><br/><br/>
+ <g:SimplePanel ui:field="handlerControls"/><br/><br/>
+ <g:SimplePanel ui:field="logOnServerButton"/><br/><br/>
+ </div>
+ </g:HTMLPanel>
+</ui:UiBinder>
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/LoggerController.java b/samples/logexample/src/com/google/gwt/sample/logexample/client/LoggerController.java
new file mode 100644
index 0000000..6b2dfcf
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/LoggerController.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Panel;
+import com.google.gwt.user.client.ui.SimplePanel;
+
+import java.util.logging.Logger;
+
+/**
+ * A section explaining how to set logger levels and containing controllers
+ * for 3 specific loggers.
+ */
+public class LoggerController {
+ interface MyUiBinder extends UiBinder<HTMLPanel, LoggerController> { }
+ private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
+ @UiField SimplePanel childControls;
+ @UiField SimplePanel parentControls;
+ @UiField SimplePanel rootControls;
+ private Panel panel;
+
+ public LoggerController(Logger rootLogger, Logger parentLogger,
+ Logger childLogger) {
+ panel = uiBinder.createAndBindUi(this);
+ rootControls.setWidget(new OneLoggerController(rootLogger).getPanel());
+ parentControls.setWidget(new OneLoggerController(parentLogger).getPanel());
+ childControls.setWidget(new OneLoggerController(childLogger).getPanel());
+ }
+
+ public Panel getPanel() {
+ return panel;
+ }
+}
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/LoggerController.ui.xml b/samples/logexample/src/com/google/gwt/sample/logexample/client/LoggerController.ui.xml
new file mode 100644
index 0000000..0d3f0e0
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/LoggerController.ui.xml
@@ -0,0 +1,14 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel styleName='oneArea'>
+ You can set the default logging level by setting the "logLevel" url parameter
+ (e.g. logLevel=FINE). You can also configure various aspects in the gwt.xml
+ file, and programatically. Use the controls below to programmatically change
+ the levels of the 3 loggers, and to log messages to them.
+ <g:HorizontalPanel>
+ <g:SimplePanel ui:field="rootControls"/>
+ <g:SimplePanel ui:field="parentControls"/>
+ <g:SimplePanel ui:field="childControls"/>
+ </g:HorizontalPanel>
+ </g:HTMLPanel>
+</ui:UiBinder>
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/OneLoggerController.java b/samples/logexample/src/com/google/gwt/sample/logexample/client/OneLoggerController.java
new file mode 100644
index 0000000..1e2ec19
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/OneLoggerController.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.SpanElement;
+import com.google.gwt.event.dom.client.ChangeEvent;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.Panel;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A section allowing the user to change the level of a logger and log messages
+ * to that logger.
+ */
+public class OneLoggerController {
+ interface MyUiBinder extends UiBinder<HTMLPanel, OneLoggerController> { }
+ private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
+ @UiField ListBox levelTextBox;
+ @UiField SpanElement loggerName;
+ @UiField ListBox logTextBox;
+ private Logger logger;
+ private Panel panel;
+
+ public OneLoggerController(Logger logger) {
+ this.logger = logger;
+ panel = uiBinder.createAndBindUi(this);
+ String name = logger.getName();
+ if (name.isEmpty()) {
+ name = "RootLogger";
+ }
+ loggerName.setInnerText(name);
+ addLevelButtons();
+ addLogButtons();
+ }
+
+ public Panel getPanel() {
+ return panel;
+ }
+
+ @UiHandler("levelTextBox")
+ void handleClick(ChangeEvent e) {
+ Level level = Level.parse(levelTextBox.getItemText(
+ levelTextBox.getSelectedIndex()));
+ logger.log(Level.SEVERE,
+ "Setting level to: " + level.getName());
+ logger.setLevel(level);
+ }
+
+ @UiHandler("logButton")
+ void handleLogClick(ClickEvent e) {
+ Level level = Level.parse(logTextBox.getItemText(
+ logTextBox.getSelectedIndex()));
+ logger.log(level, "This is a client log message");
+ }
+
+ private void addLevelButtons() {
+ levelTextBox.addItem("OFF");
+ levelTextBox.addItem("SEVERE");
+ levelTextBox.addItem("WARNING");
+ levelTextBox.addItem("INFO");
+ levelTextBox.addItem("CONFIG");
+ levelTextBox.addItem("FINE");
+ levelTextBox.addItem("FINER");
+ levelTextBox.addItem("FINEST");
+ levelTextBox.addItem("ALL");
+ String currentLevel = this.getLevel(logger);
+ for (int i = 0; i < levelTextBox.getItemCount(); i++) {
+ if (currentLevel.equalsIgnoreCase(levelTextBox.getItemText(i))) {
+ levelTextBox.setSelectedIndex(i);
+ }
+ }
+ }
+
+ private void addLogButtons() {
+ logTextBox.addItem("SEVERE");
+ logTextBox.addItem("WARNING");
+ logTextBox.addItem("INFO");
+ logTextBox.addItem("CONFIG");
+ logTextBox.addItem("FINE");
+ logTextBox.addItem("FINER");
+ logTextBox.addItem("FINEST");
+ String currentLevel = this.getLevel(logger);
+ for (int i = 0; i < logTextBox.getItemCount(); i++) {
+ if (currentLevel.equalsIgnoreCase(logTextBox.getItemText(i))) {
+ logTextBox.setSelectedIndex(i);
+ }
+ }
+ }
+
+ private String getLevel(Logger logger) {
+ if (logger.getLevel() != null) {
+ return logger.getLevel().getName();
+ }
+ return getLevel(logger.getParent());
+ }
+}
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/OneLoggerController.ui.xml b/samples/logexample/src/com/google/gwt/sample/logexample/client/OneLoggerController.ui.xml
new file mode 100644
index 0000000..f60b799
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/OneLoggerController.ui.xml
@@ -0,0 +1,14 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel styleName='oneLoggerController'>
+ <b><span ui:field='loggerName'/></b>
+ <br/>
+ Level is:
+ <g:ListBox ui:field='levelTextBox'/>
+ <br/>
+ Log a message:
+ <br/>
+ <g:ListBox ui:field='logTextBox'/>
+ <g:Button ui:field='logButton'>Log</g:Button>
+ </g:HTMLPanel>
+</ui:UiBinder>
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/ServerLoggingArea.java b/samples/logexample/src/com/google/gwt/sample/logexample/client/ServerLoggingArea.java
new file mode 100644
index 0000000..b3510fc
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/ServerLoggingArea.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.client;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.sample.logexample.shared.LoggingService;
+import com.google.gwt.sample.logexample.shared.LoggingServiceAsync;
+import com.google.gwt.sample.logexample.shared.SharedLoggingLibrary;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Panel;
+
+import java.util.logging.Level;
+
+/**
+ * A section allowing the user to experiment with server side logging and
+ * shared library logging when it is called from server vs client side code.
+ */
+public class ServerLoggingArea {
+ interface MyUiBinder extends UiBinder<HTMLPanel, ServerLoggingArea> { }
+ private static MyUiBinder uiBinder = GWT.create(MyUiBinder.class);
+ private final LoggingServiceAsync loggingService =
+ GWT.create(LoggingService.class);
+
+ private Panel panel;
+
+ public ServerLoggingArea() {
+ panel = uiBinder.createAndBindUi(this);
+ }
+
+ public Panel getPanel() {
+ return panel;
+ }
+
+ @UiHandler("clientSharedLogButton")
+ void handleLogClick(ClickEvent e) {
+ SharedLoggingLibrary.logUsingSharedLibrary(Level.SEVERE,
+ "Message logged by client side code");
+ }
+
+ @UiHandler("serverSharedLogButton")
+ void handleServerHaredLogButton(ClickEvent e) {
+ loggingService.logOnServerUsingSharedLibrary(Level.SEVERE.toString(),
+ "Message logged by server side code", new AsyncCallback<Void>() {
+
+ public void onFailure(Throwable caught) {
+ Window.alert("Logging on server failed");
+ }
+
+ public void onSuccess(Void result) {
+ }
+ });
+ }
+
+ @UiHandler("serverLogButton")
+ void handleServerLogButton(ClickEvent e) {
+ loggingService.logOnServer(Level.SEVERE.toString(), "server log",
+ new AsyncCallback<Void>() {
+
+ public void onFailure(Throwable caught) {
+ Window.alert("Logging on server failed");
+ }
+
+ public void onSuccess(Void result) {
+ }
+ });
+ }
+}
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/client/ServerLoggingArea.ui.xml b/samples/logexample/src/com/google/gwt/sample/logexample/client/ServerLoggingArea.ui.xml
new file mode 100644
index 0000000..2f008f2
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/client/ServerLoggingArea.ui.xml
@@ -0,0 +1,25 @@
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui'>
+ <g:HTMLPanel styleName='oneArea'>
+ <table><tr><td class='centered'>
+ GWT logging is configured separately from server side logging.
+ Clicking this button will trigger a logging call on the server, which
+ will be output by the loggers and handlers which are set up on the server.
+ <br/>
+ <g:Button ui:field='serverLogButton'>
+ Trigger Server Log
+ </g:Button>
+ </td><td class='centered'>
+ In shared code libraries, the log messages will be handled by the loggers
+ and handlers of the calling code. Clicking these buttons will trigger a
+ shared logging library from the server or client code.
+ <br/>
+ <g:Button ui:field='serverSharedLogButton'>
+ From Server
+ </g:Button>
+ <g:Button ui:field='clientSharedLogButton'>
+ From Client
+ </g:Button>
+ </td></tr></table>
+ </g:HTMLPanel>
+</ui:UiBinder>
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/server/LoggingServiceImpl.java b/samples/logexample/src/com/google/gwt/sample/logexample/server/LoggingServiceImpl.java
new file mode 100644
index 0000000..7391cf5
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/server/LoggingServiceImpl.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.sample.logexample.server;
+
+import com.google.gwt.sample.logexample.shared.LoggingService;
+import com.google.gwt.sample.logexample.shared.SharedLoggingLibrary;
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * A simple servlet that responds to requests to log from the server, either
+ * directly, or by calling the shared logging library code.
+ */
+public class LoggingServiceImpl extends RemoteServiceServlet implements
+ LoggingService {
+
+ private static Logger logger = Logger.getLogger("ServerLogger");
+
+ public void logOnServer(String level, String msg)
+ throws IllegalArgumentException {
+ logger.log(Level.parse(level), msg);
+ }
+
+ public void logOnServerUsingSharedLibrary(String level, String msg)
+ throws IllegalArgumentException {
+ SharedLoggingLibrary.logUsingSharedLibrary(Level.parse(level), msg);
+ }
+}
+
+
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/shared/LoggingService.java b/samples/logexample/src/com/google/gwt/sample/logexample/shared/LoggingService.java
new file mode 100644
index 0000000..11c975c
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/shared/LoggingService.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.shared;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+/**
+ * The client side stub for the RPC service.
+ */
+@RemoteServiceRelativePath("log")
+public interface LoggingService extends RemoteService {
+ void logOnServer(String level, String msg) throws IllegalArgumentException;
+ void logOnServerUsingSharedLibrary(String level, String msg)
+ throws IllegalArgumentException;
+}
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/shared/LoggingServiceAsync.java b/samples/logexample/src/com/google/gwt/sample/logexample/shared/LoggingServiceAsync.java
new file mode 100644
index 0000000..337d4f1
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/shared/LoggingServiceAsync.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.shared;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+/**
+ * The async counterpart of <code>LoggingService</code>.
+ */
+public interface LoggingServiceAsync {
+ void logOnServer(String level, String msg, AsyncCallback<Void> callback)
+ throws IllegalArgumentException;
+ void logOnServerUsingSharedLibrary(String level, String msg,
+ AsyncCallback<Void> callback) throws IllegalArgumentException;
+}
\ No newline at end of file
diff --git a/samples/logexample/src/com/google/gwt/sample/logexample/shared/SharedLoggingLibrary.java b/samples/logexample/src/com/google/gwt/sample/logexample/shared/SharedLoggingLibrary.java
new file mode 100644
index 0000000..c78a240
--- /dev/null
+++ b/samples/logexample/src/com/google/gwt/sample/logexample/shared/SharedLoggingLibrary.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.sample.logexample.shared;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Shared code which does a simple logging call. Used to demonstrate how
+ * shared code will log to different handlers depending on whether it is called
+ * from server or client side code.
+ */
+public class SharedLoggingLibrary {
+ private static Logger logger = Logger.getLogger("SharedLibraryLogger");
+
+ public static void logUsingSharedLibrary(Level level, String msg) {
+ logger.log(level, msg);
+ }
+}
diff --git a/samples/logexample/war/LogExample.css b/samples/logexample/war/LogExample.css
new file mode 100644
index 0000000..8a563eb
--- /dev/null
+++ b/samples/logexample/war/LogExample.css
@@ -0,0 +1,38 @@
+h1 {
+ font-size: 2em;
+ font-weight: bold;
+ color: #777777;
+ margin: 40px 0px 70px;
+ text-align: center;
+}
+
+.centered {
+ text-align: center;
+}
+
+.oneArea {
+ width: 800px;
+ border-color: #777777;
+ border-width: 1px;
+ border-style: solid;
+ padding: 5px;
+}
+
+.oneLoggerController {
+ text-align: center;
+ border-color: #777777;
+ border-width: 1px;
+ border-style: solid;
+ width: 175px;
+ margin: 5px;
+ padding: 5px;
+}
+
+.customLogScrollPanel {
+ border-color: #777777;
+ border-width: 1px;
+ border-style: solid;
+ width: 700px;
+ height: 100px;
+}
+
diff --git a/samples/logexample/war/LogExample.html b/samples/logexample/war/LogExample.html
new file mode 100644
index 0000000..b21ab40
--- /dev/null
+++ b/samples/logexample/war/LogExample.html
@@ -0,0 +1,21 @@
+<!doctype html>
+
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <link type="text/css" rel="stylesheet" href="LogExample.css">
+
+ <title>Logging Example</title>
+ <script type="text/javascript" language="javascript"
+ src="logexample/logexample.nocache.js"></script>
+ </head>
+
+ <body>
+ <noscript>
+ <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
+ Your web browser must have JavaScript enabled
+ in order for this application to display correctly.
+ </div>
+ </noscript>
+ </body>
+</html>
diff --git a/samples/logexample/war/favicon.ico b/samples/logexample/war/favicon.ico
new file mode 100644
index 0000000..d7ccc73
--- /dev/null
+++ b/samples/logexample/war/favicon.ico
Binary files differ