diff options
author | Mikael Grankvist <mgrankvi@vaadin.com> | 2013-01-08 09:07:53 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-02-28 09:26:27 +0000 |
commit | aa42551d80088583a2063a596dc1099b669ee9cb (patch) | |
tree | ac864874fe645606dbbf9ea95793ea0da82b7e6e | |
parent | 51fcdd88c1928c7c2537827e1a224fe171d492a9 (diff) | |
download | vaadin-framework-aa42551d80088583a2063a596dc1099b669ee9cb.tar.gz vaadin-framework-aa42551d80088583a2063a596dc1099b669ee9cb.zip |
(#10563) Logging now uses parameters.
Change-Id: Icc807cc2eb391fb0118800383fc93d1e23b04570
15 files changed, 198 insertions, 161 deletions
diff --git a/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java b/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java index 90877c47c8..34024f1616 100644 --- a/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java +++ b/client-compiler/src/com/vaadin/server/widgetsetutils/ClassPathExplorer.java @@ -239,7 +239,7 @@ public class ClassPathExplorer { classpath = classpath.substring(0, classpath.length() - 1); } - getLogger().fine("Classpath: " + classpath); + getLogger().log(Level.FINE, "Classpath: {0}", classpath); String[] split = classpath.split(pathSep); for (int i = 0; i < split.length; i++) { diff --git a/server/src/com/vaadin/data/util/AbstractProperty.java b/server/src/com/vaadin/data/util/AbstractProperty.java index 9eafca6051..499421a8b4 100644 --- a/server/src/com/vaadin/data/util/AbstractProperty.java +++ b/server/src/com/vaadin/data/util/AbstractProperty.java @@ -18,6 +18,7 @@ package com.vaadin.data.util; import java.util.Collection; import java.util.Collections; import java.util.LinkedList; +import java.util.logging.Level; import java.util.logging.Logger; import com.vaadin.data.Property; @@ -81,11 +82,11 @@ public abstract class AbstractProperty<T> implements Property<T>, @Override public String toString() { getLogger() - .warning( - "You are using Property.toString() instead of getValue() to get the value for a " - + getClass().getSimpleName() - + ". This will not be supported starting from Vaadin 7.1 " - + "(your debugger might call toString() and cause this message to appear)."); + .log(Level.WARNING, + "You are using Property.toString() instead of getValue() to get the value for a {0}." + + "This will not be supported starting from Vaadin 7.1 " + + "(your debugger might call toString() and cause this message to appear).", + getClass().getSimpleName()); T v = getValue(); if (v == null) { return null; diff --git a/server/src/com/vaadin/data/util/IndexedContainer.java b/server/src/com/vaadin/data/util/IndexedContainer.java index 306f9cf23b..1df4dd9bfb 100644 --- a/server/src/com/vaadin/data/util/IndexedContainer.java +++ b/server/src/com/vaadin/data/util/IndexedContainer.java @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.logging.Level; import java.util.logging.Logger; import com.vaadin.data.Container; @@ -966,11 +967,11 @@ public class IndexedContainer extends @Override public String toString() { getLogger() - .warning( - "You are using IndexedContainerProperty.toString() instead of getValue() to get the value for a " - + getClass().getSimpleName() - + ". This will not be supported starting from Vaadin 7.1 " - + "(your debugger might call toString() and cause this message to appear)."); + .log(Level.WARNING, + "You are using IndexedContainerProperty.toString() instead of getValue() to get the value for a {0}." + + " This will not be supported starting from Vaadin 7.1 " + + "(your debugger might call toString() and cause this message to appear).", + getClass().getSimpleName()); Object v = getValue(); if (v == null) { return null; diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java index 785c7b22af..378372d044 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java @@ -18,6 +18,7 @@ package com.vaadin.data.util.sqlcontainer; import java.sql.Date; import java.sql.Time; import java.sql.Timestamp; +import java.util.logging.Level; import java.util.logging.Logger; import com.vaadin.data.Property; @@ -264,11 +265,11 @@ final public class ColumnProperty implements Property { @Override public String toString() { getLogger() - .warning( - "You are using ColumnProperty.toString() instead of getValue() to get the value for a " - + getClass().getSimpleName() - + ". This will not be supported starting from Vaadin 7.1 " - + "(your debugger might call toString() and cause this message to appear)."); + .log(Level.WARNING, + "You are using ColumnProperty.toString() instead of getValue() to get the value for a {0}. " + + "This will not be supported starting from Vaadin 7.1 (your debugger might call toString() " + + "and cause this message to appear).", + getClass().getSimpleName()); Object v = getValue(); if (v == null) { return null; diff --git a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java index 4d60a8cc17..63e4b3362c 100644 --- a/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java +++ b/server/src/com/vaadin/data/util/sqlcontainer/query/TableQuery.java @@ -610,8 +610,10 @@ public class TableQuery implements QueryDelegate, @Override public boolean removeRow(RowItem row) throws UnsupportedOperationException, SQLException { - getLogger().log(Level.FINE, "Removing row with id: {0}", - row.getId().getId()[0].toString()); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log(Level.FINE, "Removing row with id: {0}", + row.getId().getId()[0]); + } if (executeUpdate(sqlGenerator.generateDeleteQuery(getTableName(), primaryKeyColumns, versionColumn, row)) == 1) { return true; diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java index cd7279e601..17bbbda737 100644 --- a/server/src/com/vaadin/server/AbstractCommunicationManager.java +++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java @@ -791,10 +791,8 @@ public abstract class AbstractCommunicationManager implements Serializable { dirtyVisibleConnectors .addAll(getDirtyVisibleConnectors(uiConnectorTracker)); - getLogger().log( - Level.FINE, - "Found " + dirtyVisibleConnectors.size() - + " dirty connectors to paint"); + getLogger().log(Level.FINE, "Found {0} dirty connectors to paint", + dirtyVisibleConnectors.size()); for (ClientConnector connector : dirtyVisibleConnectors) { boolean initialized = uiConnectorTracker .isClientSideInitialized(connector); @@ -1226,10 +1224,10 @@ public abstract class AbstractCommunicationManager implements Serializable { null, stateType, uI.getConnectorTracker()); diffState = encodeResult.getEncodedValue(); } catch (Exception e) { - getLogger().log( - Level.WARNING, - "Error creating reference object for state of type " - + stateType.getName()); + getLogger() + .log(Level.WARNING, + "Error creating reference object for state of type {0}", + stateType.getName()); } } EncodeResult encodeResult = JsonCodec.encode(state, diffState, @@ -1276,10 +1274,10 @@ public abstract class AbstractCommunicationManager implements Serializable { if (publishedFileContexts.containsKey(name)) { Class<?> oldContext = publishedFileContexts.get(name); if (oldContext != context) { - getLogger().warning( - name + " published by both " + context + " and " - + oldContext + ". File from " + oldContext - + " will be used."); + getLogger() + .log(Level.WARNING, + "{0} published by both {1} and {2}. File from {2} will be used.", + new Object[] { name, context, oldContext }); } } else { publishedFileContexts.put(name, context); @@ -1312,9 +1310,13 @@ public abstract class AbstractCommunicationManager implements Serializable { } sortByHierarchy((List) legacyComponents); for (LegacyComponent c : legacyComponents) { - getLogger().fine( - "Painting LegacyComponent " + c.getClass().getName() + "@" - + Integer.toHexString(c.hashCode())); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log( + Level.FINE, + "Painting LegacyComponent {0}@{1}", + new Object[] { c.getClass().getName(), + Integer.toHexString(c.hashCode()) }); + } paintTarget.startTag("change"); final String pid = c.getConnectorId(); paintTarget.addAttribute("pid", pid); @@ -1705,9 +1707,9 @@ public abstract class AbstractCommunicationManager implements Serializable { } } } catch (JSONException e) { - getLogger().warning( - "Unable to parse RPC call from the client: " - + e.getMessage()); + getLogger().log(Level.WARNING, + "Unable to parse RPC call from the client: {0}", + e.getMessage()); // TODO or return success = false? throw new RuntimeException(e); } @@ -1853,11 +1855,11 @@ public abstract class AbstractCommunicationManager implements Serializable { * corresponding to the received method invocation has been * registered. */ - getLogger().warning( - "Ignoring RPC call to " + interfaceName + "." + methodName - + " in connector " + connector.getClass().getName() - + "(" + connectorId - + ") as no RPC implementation is regsitered"); + getLogger() + .log(Level.WARNING, + "Ignoring RPC call to {0}.{1} in connector {2} ({3}) as no RPC implementation is regsitered", + new Object[] { interfaceName, methodName, + connector.getClass().getName(), connectorId }); return null; } @@ -2056,9 +2058,8 @@ public abstract class AbstractCommunicationManager implements Serializable { DateFormat dateFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT, l); if (!(dateFormat instanceof SimpleDateFormat)) { - getLogger().warning( - "Unable to get default date pattern for locale " - + l.toString()); + getLogger().log(Level.WARNING, + "Unable to get default date pattern for locale {0}", l); dateFormat = new SimpleDateFormat(); } final String df = ((SimpleDateFormat) dateFormat).toPattern(); @@ -2218,8 +2219,10 @@ public abstract class AbstractCommunicationManager implements Serializable { if (id == null) { id = nextTypeKey++; typeToKey.put(class1, id); - getLogger().log(Level.FINE, - "Mapping " + class1.getName() + " to " + id); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log(Level.FINE, "Mapping {0} to {1}", + new Object[] { class1.getName(), id }); + } } return id.toString(); } @@ -2434,11 +2437,12 @@ public abstract class AbstractCommunicationManager implements Serializable { reinitUI(retainedUI, request); return retainedUI; } else { - getLogger().info( - "Not using retained UI in " + windowName - + " because retained UI was of type " - + retainedUI.getClass() + " but " + uiClass - + " is expected for the request."); + getLogger().log( + Level.INFO, + "Not using retained UI in {0} because retained UI was of type {1}" + + " but {2} is expected for the request.", + new Object[] { windowName, retainedUI.getClass(), + uiClass }); } } } @@ -2469,9 +2473,10 @@ public abstract class AbstractCommunicationManager implements Serializable { if (vaadinService.preserveUIOnRefresh(provider, event)) { // Remember this UI if (windowName == null) { - getLogger().warning( - "There is no window.name available for UI " + uiClass - + " that should be preserved."); + getLogger() + .log(Level.WARNING, + "There is no window.name available for UI {0} that should be preserved.", + uiClass); } else { session.getPreserveOnRefreshUIs().put(windowName, uiId); } @@ -2523,7 +2528,7 @@ public abstract class AbstractCommunicationManager implements Serializable { writeUidlResponse(request, true, pWriter, uI, false); pWriter.print("}"); String initialUIDL = sWriter.toString(); - getLogger().log(Level.FINE, "Initial UIDL:" + initialUIDL); + getLogger().log(Level.FINE, "Initial UIDL:{0}", initialUIDL); return initialUIDL; } @@ -2554,9 +2559,9 @@ public abstract class AbstractCommunicationManager implements Serializable { // Security check: avoid accidentally serving from the UI of the // classpath instead of relative to the context class if (fileName.startsWith("/")) { - getLogger().warning( - "Published file request starting with / rejected: " - + fileName); + getLogger().log(Level.WARNING, + "Published file request starting with / rejected: {0}", + fileName); response.sendError(HttpServletResponse.SC_NOT_FOUND, fileName); return; } @@ -2570,9 +2575,10 @@ public abstract class AbstractCommunicationManager implements Serializable { // Security check: don't serve resource if the name hasn't been // registered in the map if (context == null) { - getLogger().warning( - "Rejecting published file request for file that has not been published: " - + fileName); + getLogger() + .log(Level.WARNING, + "Rejecting published file request for file that has not been published: {0}", + fileName); response.sendError(HttpServletResponse.SC_NOT_FOUND, fileName); return; } @@ -2580,12 +2586,14 @@ public abstract class AbstractCommunicationManager implements Serializable { // Resolve file relative to the location of the context class InputStream in = context.getResourceAsStream(fileName); if (in == null) { - getLogger().warning( - fileName + " published by " + context.getName() - + " not found. Verify that the file " - + context.getPackage().getName().replace('.', '/') - + '/' + fileName - + " is available on the classpath."); + getLogger() + .log(Level.WARNING, + "{0} published by {1} not found. Verify that the file {2}/{3} is available on the classpath.", + new Object[] { + fileName, + context.getName(), + context.getPackage().getName() + .replace('.', '/'), fileName }); response.sendError(HttpServletResponse.SC_NOT_FOUND, fileName); return; } diff --git a/server/src/com/vaadin/server/DragAndDropService.java b/server/src/com/vaadin/server/DragAndDropService.java index a3690cf040..5a54b5ae3a 100644 --- a/server/src/com/vaadin/server/DragAndDropService.java +++ b/server/src/com/vaadin/server/DragAndDropService.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.logging.Level; import java.util.logging.Logger; import org.json.JSONException; @@ -97,9 +98,9 @@ public class DragAndDropService implements VariableOwner, ClientConnector { DropHandler dropHandler = (dropTarget).getDropHandler(); if (dropHandler == null) { // No dropHandler returned so no drop can be performed. - getLogger().fine( - "DropTarget.getDropHandler() returned null for owner: " - + dropTarget); + getLogger().log(Level.FINE, + "DropTarget.getDropHandler() returned null for owner: {0}", + dropTarget); return; } diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java index 140ed54828..0d2063d446 100644 --- a/server/src/com/vaadin/server/GAEVaadinServlet.java +++ b/server/src/com/vaadin/server/GAEVaadinServlet.java @@ -272,7 +272,8 @@ public class GAEVaadinServlet extends VaadinServlet { ds.put(entity); } catch (DeadlineExceededException e) { - getLogger().warning("DeadlineExceeded for " + session.getId()); + getLogger().log(Level.WARNING, "DeadlineExceeded for {0}", + session.getId()); sendDeadlineExceededNotification(request, response); } catch (NotSerializableException e) { getLogger().log(Level.SEVERE, "Not serializable!", e); @@ -421,9 +422,10 @@ public class GAEVaadinServlet extends VaadinServlet { List<Entity> entities = pq.asList(Builder .withLimit(CLEANUP_LIMIT)); if (entities != null) { - getLogger().info( - "Vaadin cleanup deleting " + entities.size() - + " expired Vaadin sessions."); + getLogger() + .log(Level.INFO, + "Vaadin cleanup deleting {0} expired Vaadin sessions.", + entities.size()); List<Key> keys = new ArrayList<Key>(); for (Entity e : entities) { keys.add(e.getKey()); @@ -441,9 +443,10 @@ public class GAEVaadinServlet extends VaadinServlet { List<Entity> entities = pq.asList(Builder .withLimit(CLEANUP_LIMIT)); if (entities != null) { - getLogger().info( - "Vaadin cleanup deleting " + entities.size() - + " expired appengine sessions."); + getLogger() + .log(Level.INFO, + "Vaadin cleanup deleting {0} expired appengine sessions.", + entities.size()); List<Key> keys = new ArrayList<Key>(); for (Entity e : entities) { keys.add(e.getKey()); diff --git a/server/src/com/vaadin/server/JsonPaintTarget.java b/server/src/com/vaadin/server/JsonPaintTarget.java index 12d2c93272..11bfb33fe1 100644 --- a/server/src/com/vaadin/server/JsonPaintTarget.java +++ b/server/src/com/vaadin/server/JsonPaintTarget.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.Stack; import java.util.Vector; +import java.util.logging.Level; import java.util.logging.Logger; import com.vaadin.ui.Alignment; @@ -663,9 +664,13 @@ public class JsonPaintTarget implements PaintTarget { throws PaintException { boolean topLevelPaintable = openPaintables.isEmpty(); - getLogger().fine( - "startPaintable for " + connector.getClass().getName() + "@" - + Integer.toHexString(connector.hashCode())); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log( + Level.FINE, + "startPaintable for {0}@{1}", + new Object[] { connector.getClass().getName(), + Integer.toHexString(connector.hashCode()) }); + } startTag(tagName, true); openPaintables.push(connector); @@ -687,9 +692,13 @@ public class JsonPaintTarget implements PaintTarget { @Override public void endPaintable(Component paintable) throws PaintException { - getLogger().fine( - "endPaintable for " + paintable.getClass().getName() + "@" - + Integer.toHexString(paintable.hashCode())); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log( + Level.FINE, + "endPaintable for {0}@{1}", + new Object[] { paintable.getClass().getName(), + Integer.toHexString(paintable.hashCode()) }); + } ClientConnector openPaintable = openPaintables.peek(); if (paintable != openPaintable) { diff --git a/server/src/com/vaadin/server/ServerRpcManager.java b/server/src/com/vaadin/server/ServerRpcManager.java index d712eafe37..ec25ce83ca 100644 --- a/server/src/com/vaadin/server/ServerRpcManager.java +++ b/server/src/com/vaadin/server/ServerRpcManager.java @@ -119,11 +119,9 @@ public class ServerRpcManager<T extends ServerRpc> implements Serializable { } else { getLogger() .log(Level.WARNING, - "RPC call received for RpcTarget " - + target.getClass().getName() - + " (" - + invocation.getConnectorId() - + ") but the target has not registered any RPC interfaces"); + "RPC call received for RpcTarget {0} ({1}) but the target has not registered any RPC interfaces", + new Object[] { target.getClass().getName(), + invocation.getConnectorId() }); } } diff --git a/server/src/com/vaadin/server/VaadinPortlet.java b/server/src/com/vaadin/server/VaadinPortlet.java index e13a64682e..b4a2390fa5 100644 --- a/server/src/com/vaadin/server/VaadinPortlet.java +++ b/server/src/com/vaadin/server/VaadinPortlet.java @@ -28,6 +28,7 @@ import java.security.GeneralSecurityException; import java.util.Enumeration; import java.util.Map; import java.util.Properties; +import java.util.logging.Level; import java.util.logging.Logger; import javax.portlet.ActionRequest; @@ -606,9 +607,8 @@ public class VaadinPortlet extends GenericPortlet implements Constants, os.write(buffer, 0, bytes); } } else { - getLogger().info( - "Requested resource [" + resourceID - + "] could not be found"); + getLogger().log(Level.INFO, + "Requested resource [{0}] could not be found", resourceID); response.setProperty(ResourceResponse.HTTP_STATUS_CODE, Integer.toString(HttpServletResponse.SC_NOT_FOUND)); } diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index d35cf74262..ada0fac107 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -25,6 +25,7 @@ import java.net.URL; import java.util.ArrayList; import java.util.HashMap; import java.util.Locale; +import java.util.logging.Level; import java.util.logging.Logger; import javax.portlet.PortletContext; @@ -786,9 +787,8 @@ public abstract class VaadinService implements Serializable { if (!session.isClosing()) { closeSession(session); if (session.getSession() != null) { - getLogger().fine( - "Closing inactive session " - + session.getSession().getId()); + getLogger().log(Level.FINE, "Closing inactive session {0}", + session.getSession().getId()); } } if (session.getSession() != null) { @@ -817,7 +817,8 @@ public abstract class VaadinService implements Serializable { private void removeClosedUIs(VaadinSession session) { for (UI ui : new ArrayList<UI>(session.getUIs())) { if (ui.isClosing()) { - getLogger().finer("Removing closed UI " + ui.getUIId()); + getLogger().log(Level.FINER, "Removing closed UI {0}", + ui.getUIId()); session.removeUI(ui); } } @@ -833,9 +834,9 @@ public abstract class VaadinService implements Serializable { String sessionId = session.getSession().getId(); for (UI ui : session.getUIs()) { if (!isUIActive(ui) && !ui.isClosing()) { - getLogger().fine( - "Closing inactive UI #" + ui.getUIId() + " in session " - + sessionId); + getLogger().log(Level.FINE, + "Closing inactive UI #{0} in session {1}", + new Object[] { ui.getUIId(), sessionId }); ui.close(); } } diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java index b3f9b36a83..4fde870f74 100644 --- a/server/src/com/vaadin/server/VaadinServlet.java +++ b/server/src/com/vaadin/server/VaadinServlet.java @@ -792,10 +792,10 @@ public class VaadinServlet extends HttpServlet implements Constants { } else { // cannot serve requested file getLogger() - .info("Requested resource [" - + filename - + "] not found from filesystem or through class loader." - + " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder."); + .log(Level.INFO, + "Requested resource [{0}] not found from filesystem or through class loader." + + " Add widgetset and/or theme JAR to your classpath or add files to WebContent/VAADIN folder.", + filename); response.setStatus(HttpServletResponse.SC_NOT_FOUND); } return; @@ -805,9 +805,9 @@ public class VaadinServlet extends HttpServlet implements Constants { // directory if (!isAllowedVAADINResourceUrl(request, resourceUrl)) { getLogger() - .info("Requested resource [" - + filename - + "] not accessible in the VAADIN directory or access to it is forbidden."); + .log(Level.INFO, + "Requested resource [{0}] not accessible in the VAADIN directory or access to it is forbidden.", + filename); response.setStatus(HttpServletResponse.SC_FORBIDDEN); return; } @@ -945,9 +945,9 @@ public class VaadinServlet extends HttpServlet implements Constants { // directory if (!isAllowedVAADINResourceUrl(request, scssUrl)) { getLogger() - .info("Requested resource [" - + filename - + "] not accessible in the VAADIN directory or access to it is forbidden."); + .log(Level.INFO, + "Requested resource [{0}] not accessible in the VAADIN directory or access to it is forbidden.", + filename); response.setStatus(HttpServletResponse.SC_FORBIDDEN); // Handled, return true so no further processing is done return true; @@ -968,16 +968,14 @@ public class VaadinServlet extends HttpServlet implements Constants { if (scss == null) { getLogger() - .warning( - "Scss file " - + scssFilename - + " exists but ScssStylesheet was not able to find it"); + .log(Level.WARNING, + "Scss file {0} exists but ScssStylesheet was not able to find it", + scssFilename); return false; } try { - getLogger().fine( - "Compiling " + realFilename + " for request to " - + filename); + getLogger().log(Level.FINE, "Compiling {0} for request to {1}", + new Object[] { realFilename, filename }); scss.compile(); } catch (Exception e) { e.printStackTrace(); @@ -1028,14 +1026,15 @@ public class VaadinServlet extends HttpServlet implements Constants { // loader sees it. if (!resourceUrl.getPath().contains("!/VAADIN/")) { - getLogger().info( - "Blocked attempt to access a JAR entry not starting with /VAADIN/: " - + resourceUrl); + getLogger() + .log(Level.INFO, + "Blocked attempt to access a JAR entry not starting with /VAADIN/: {0}", + resourceUrl); return false; } - getLogger().fine( - "Accepted access to a JAR entry using a class loader: " - + resourceUrl); + getLogger().log(Level.FINE, + "Accepted access to a JAR entry using a class loader: {0}", + resourceUrl); return true; } else { // Some servers such as GlassFish extract files from JARs (file:) @@ -1045,13 +1044,13 @@ public class VaadinServlet extends HttpServlet implements Constants { // "/../" if (!resourceUrl.getPath().contains("/VAADIN/") || resourceUrl.getPath().contains("/../")) { - getLogger().info( - "Blocked attempt to access file: " + resourceUrl); + getLogger().log(Level.INFO, + "Blocked attempt to access file: {0}", resourceUrl); return false; } - getLogger().fine( - "Accepted access to a file using a class loader: " - + resourceUrl); + getLogger().log(Level.FINE, + "Accepted access to a file using a class loader: {0}", + resourceUrl); return true; } } diff --git a/server/src/com/vaadin/ui/AbstractMedia.java b/server/src/com/vaadin/ui/AbstractMedia.java index 55464aeb8d..41677467bb 100644 --- a/server/src/com/vaadin/ui/AbstractMedia.java +++ b/server/src/com/vaadin/ui/AbstractMedia.java @@ -19,6 +19,7 @@ package com.vaadin.ui; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -88,9 +89,9 @@ public abstract class AbstractMedia extends AbstractComponent { int sourceIndex = Integer.parseInt(matcher.group(1)); if (sourceIndex < 0 || sourceIndex >= sources.size()) { - getLogger().warning( - "Requested source index " + sourceIndex - + " is out of bounds"); + getLogger().log(Level.WARNING, + "Requested source index {0} is out of bounds", + sourceIndex); return false; } diff --git a/server/src/com/vaadin/ui/ConnectorTracker.java b/server/src/com/vaadin/ui/ConnectorTracker.java index a888f9f7eb..a229003224 100644 --- a/server/src/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/com/vaadin/ui/ConnectorTracker.java @@ -120,17 +120,23 @@ public class ConnectorTracker implements Serializable { if (previouslyRegistered == null) { connectorIdToConnector.put(connectorId, connector); uninitializedConnectors.add(connector); - getLogger().fine( - "Registered " + connector.getClass().getSimpleName() + " (" - + connectorId + ")"); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log( + Level.FINE, + "Registered {0} ({1})", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); + } } else if (previouslyRegistered != connector) { throw new RuntimeException("A connector with id " + connectorId + " is already registered!"); } else if (!wasUnregistered) { - getLogger().warning( - "An already registered connector was registered again: " - + connector.getClass().getSimpleName() + " (" - + connectorId + ")"); + getLogger() + .log(Level.WARNING, + "An already registered connector was registered again: {0} ({1})", + new Object[] { + connector.getClass().getSimpleName(), + connectorId }); } dirtyConnectors.add(connector); } @@ -149,10 +155,11 @@ public class ConnectorTracker implements Serializable { public void unregisterConnector(ClientConnector connector) { String connectorId = connector.getConnectorId(); if (!connectorIdToConnector.containsKey(connectorId)) { - getLogger().warning( - "Tried to unregister " - + connector.getClass().getSimpleName() + " (" - + connectorId + ") which is not registered"); + getLogger().log( + Level.WARNING, + "Tried to unregister {0} ({1}) which is not registered", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); return; } if (connectorIdToConnector.get(connectorId) != connector) { @@ -163,14 +170,19 @@ public class ConnectorTracker implements Serializable { dirtyConnectors.remove(connector); if (unregisteredConnectors.add(connector)) { - getLogger().fine( - "Unregistered " + connector.getClass().getSimpleName() - + " (" + connectorId + ")"); + if (getLogger().isLoggable(Level.FINE)) { + getLogger().log( + Level.FINE, + "Unregistered {0} ({1})", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); + } } else { - getLogger().warning( - "Unregistered " + connector.getClass().getSimpleName() - + " (" + connectorId - + ") that was already unregistered."); + getLogger().log( + Level.WARNING, + "Unregistered {0} ({1}) that was already unregistered.", + new Object[] { connector.getClass().getSimpleName(), + connectorId }); } } @@ -273,11 +285,11 @@ public class ConnectorTracker implements Serializable { // This code should never be called as cleanup should take place // in detach() + getLogger() - .warning( - "cleanConnectorMap unregistered connector " - + getConnectorAndParentInfo(connector) - + "). This should have been done when the connector was detached."); + .log(Level.WARNING, + "cleanConnectorMap unregistered connector {0}. This should have been done when the connector was detached.", + getConnectorAndParentInfo(connector)); removeFromGlobalResourceHandler(connector); uninitializedConnectors.remove(connector); @@ -288,10 +300,12 @@ public class ConnectorTracker implements Serializable { && !uninitializedConnectors.contains(connector)) { uninitializedConnectors.add(connector); diffStates.remove(connector); - getLogger().fine( - "cleanConnectorMap removed state for " - + getConnectorAndParentInfo(connector) - + " as it is not visible"); + if (getLogger().isLoggable(Level.FINE)) { + getLogger() + .log(Level.FINE, + "cleanConnectorMap removed state for {0} as it is not visible", + getConnectorAndParentInfo(connector)); + } } } @@ -335,9 +349,8 @@ public class ConnectorTracker implements Serializable { if (getLogger().isLoggable(Level.FINE)) { if (!dirtyConnectors.contains(connector)) { - getLogger().fine( - getConnectorAndParentInfo(connector) + " " - + "is now dirty"); + getLogger().log(Level.FINE, "{0} is now dirty", + getConnectorAndParentInfo(connector)); } } @@ -353,9 +366,8 @@ public class ConnectorTracker implements Serializable { public void markClean(ClientConnector connector) { if (getLogger().isLoggable(Level.FINE)) { if (dirtyConnectors.contains(connector)) { - getLogger().fine( - getConnectorAndParentInfo(connector) + " " - + "is no longer dirty"); + getLogger().log(Level.FINE, "{0} is no longer dirty", + getConnectorAndParentInfo(connector)); } } |