From d605d00dca9485bcd79f5b801abe34d3d0d6ae39 Mon Sep 17 00:00:00 2001 From: Paul Hoadley Date: Thu, 21 Apr 2016 14:18:53 +0930 Subject: [PATCH] Adds log warning to parseTemplatedStringWithObject(). Mike Schrag wrote in a comment here, long ago: "Should we warn here? This is awfully quiet..." Yes it is, and yes we should. I am tired of scratching my head at unmodified templates. Adding a LOG.warn() here seems like the least we should do. (Also changes 'log' to 'LOG' by convention for a public static final variable.) --- .../foundation/ERXSimpleTemplateParser.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXSimpleTemplateParser.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXSimpleTemplateParser.java index ba105c19a48..27cb89ea096 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXSimpleTemplateParser.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXSimpleTemplateParser.java @@ -35,7 +35,7 @@ public class ERXSimpleTemplateParser { public static final String DEFAULT_DELIMITER = "@@"; /** logging support */ - private static final Logger log = LoggerFactory.getLogger(ERXSimpleTemplateParser.class); + private static final Logger LOG = LoggerFactory.getLogger(ERXSimpleTemplateParser.class); /** holds a reference to the shared instance of the parser */ private static ERXSimpleTemplateParser _sharedInstance; @@ -108,7 +108,7 @@ public NSArray keysInTemplate(String template, String delimiter) { } NSArray components = NSArray.componentsSeparatedByString(template, delimiter); if (! isLoggingDisabled) { - log.debug("Components: {}", components); + LOG.debug("Components: {}", components); } boolean deriveElement = false; // if the template starts with delim, the first component will be a zero-length string for (Enumeration e = components.objectEnumerator(); e.hasMoreElements();) { @@ -174,14 +174,14 @@ public String parseTemplateWithObject(String template, String delimiter, Object delimiter = DEFAULT_DELIMITER; } if (! isLoggingDisabled) { - log.debug("Parsing template: {} with delimiter: {} object: {}",template, delimiter, object); - log.debug("Template: {}", template); - log.debug("Delim: {}", delimiter); - log.debug("otherObject: {}", otherObject); + LOG.debug("Parsing template: {} with delimiter: {} object: {}",template, delimiter, object); + LOG.debug("Template: {}", template); + LOG.debug("Delim: {}", delimiter); + LOG.debug("otherObject: {}", otherObject); } NSArray components = NSArray.componentsSeparatedByString(template, delimiter); if (! isLoggingDisabled) { - log.debug("Components: {}", components); + LOG.debug("Components: {}", components); } boolean deriveElement = false; // if the template starts with delim, the first component will be a zero-length string StringBuilder sb = new StringBuilder(); @@ -194,11 +194,11 @@ public String parseTemplateWithObject(String template, String delimiter, Object for (Enumeration e = components.objectEnumerator(); e.hasMoreElements();) { String element = (String)e.nextElement(); if(!isLoggingDisabled) { - log.debug("Processing Element: {}", element); + LOG.debug("Processing Element: {}", element); } if(deriveElement) { if(!isLoggingDisabled) { - log.debug("Deriving value ..."); + LOG.debug("Deriving value ..."); } if(element.length() == 0) { throw new IllegalArgumentException("\"\" is not a valid keypath in template: " + template); @@ -209,7 +209,7 @@ public String parseTemplateWithObject(String template, String delimiter, Object if(o != null && result == _undefinedKeyLabel) { try { if(!isLoggingDisabled) { - log.debug("calling valueForKeyPath({}, {})", o, element); + LOG.debug("calling valueForKeyPath({}, {})", o, element); } result = doGetValue(element, o); // For just in case the above doesn't throw an exception when the @@ -229,7 +229,7 @@ public String parseTemplateWithObject(String template, String delimiter, Object } if(result == _undefinedKeyLabel) { if (!isLoggingDisabled) { - log.debug("Could not find a value for '{}' of template, '{}' in either the object or extra data.", element, template); + LOG.debug("Could not find a value for '{}' of template, '{}' in either the object or extra data.", element, template); } } sb.append(result.toString()); @@ -241,7 +241,7 @@ public String parseTemplateWithObject(String template, String delimiter, Object deriveElement = true; } if(!isLoggingDisabled) { - log.debug("Buffer: {}", sb); + LOG.debug("Buffer: {}", sb); } } return sb.toString(); @@ -295,8 +295,8 @@ public static String parseTemplatedStringWithObject(String templateString, Objec convertedValue = new ERXSimpleTemplateParser("ERXSystem:KEY_NOT_FOUND").parseTemplateWithObject(convertedValue, DEFAULT_DELIMITER, templateObject, WOApplication.application()); } - // MS: Should we warn here? This is awfully quiet ... if (convertedValue.indexOf("ERXSystem:KEY_NOT_FOUND") > -1) { + LOG.warn("Not all keys in templateString were present in templateObject, returning unmodified templateString."); return templateString; // not all keys are present }