From 4058f36268d4233ae755f7de2ed16c893f649ffa Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 3 Aug 2012 13:59:56 +0200 Subject: Logging and error message clean-up Logger.debug(String) now deprecated so they're easier to spot when left in. --- src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java | 2 +- src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java | 6 +++++- .../lifecycle/instance/predefined/entitycreation/Dependency.java | 2 -- src/main/java/com/c2kernel/lookup/LDAPLookup.java | 6 +++--- src/main/java/com/c2kernel/scripting/Script.java | 6 +++--- src/main/java/com/c2kernel/utils/Logger.java | 7 +++++-- 6 files changed, 17 insertions(+), 12 deletions(-) (limited to 'src/main/java/com/c2kernel') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java b/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java index 27af6b4..190758a 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java @@ -50,7 +50,7 @@ final class JobPusher extends Thread { // push it to the agent org.omg.CORBA.Object agentIOR = nextAgent.getIOR(); Agent thisAgent = AgentHelper.narrow(agentIOR); - Logger.debug("Calling agent "+thisAgent.getSystemKey()+" from "+activity.getPath()); + Logger.msg(7, "Calling agent "+thisAgent.getSystemKey()+" from "+activity.getPath()); thisAgent.refreshJobList(this.activity.getItemEntityPath().getSysKey(), activity.getPath(), stringJobs); } catch (Exception ex) diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java index f6cec33..b1e2211 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java @@ -152,6 +152,10 @@ public abstract class WfVertex extends GraphableVertex private static Script getScript(String name, String version) throws ScriptingEngineException { + if (name == null || name.length() == 0) + throw new ScriptingEngineException("Script name is empty"); + if (version == null || version.length() == 0) + throw new ScriptingEngineException("Script version is empty"); Script script; try { @@ -165,7 +169,7 @@ public abstract class WfVertex extends GraphableVertex script = new Script(name.substring(0, split), name.substring(split + 1)); } else - throw new ScriptingEngineException("Could not find script " + name + " v" + version); + throw new ScriptingEngineException("Could not find script '" + name + "' version '" + version+"'"); } return script; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java index 9cb3894..b3be9d1 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java @@ -10,7 +10,6 @@ import com.c2kernel.property.PropertyDescriptionList; import com.c2kernel.property.PropertyUtility; import com.c2kernel.utils.CastorHashMap; import com.c2kernel.utils.KeyValuePair; -import com.c2kernel.utils.Logger; public class Dependency implements java.io.Serializable { @@ -43,7 +42,6 @@ public class Dependency implements java.io.Serializable { public com.c2kernel.collection.Dependency create() throws MembershipException, ObjectNotFoundException { com.c2kernel.collection.Dependency newDep = isDescription?new com.c2kernel.collection.DependencyDescription(name):new com.c2kernel.collection.Dependency(name); if (itemDescriptionPath != null && itemDescriptionPath.length()>0) { - Logger.debug(itemDescriptionPath); PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey()); StringBuffer classProps = new StringBuffer(); for (PropertyDescription pd : propList.list) { diff --git a/src/main/java/com/c2kernel/lookup/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/LDAPLookup.java index 39744ac..d9f5fd9 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPLookup.java +++ b/src/main/java/com/c2kernel/lookup/LDAPLookup.java @@ -70,13 +70,13 @@ public class LDAPLookup DomainPath.mTypeRoot = "cn=domain,"+props.mLocalPath; mNextKeyManager = new NextKeyManager(this, "cn=last,"+EntityPath.mTypeRoot); - Logger.debug("LDAP.useOldProps="+Gateway.getProperty("LDAP.useOldProps", "false")); + Logger.msg(7, "LDAP.useOldProps="+Gateway.getProperty("LDAP.useOldProps", "false")); if (Gateway.getProperty("LDAP.useOldProps", "false").equals("true")) { - Logger.debug("Using Kernel 2.1 LDAP Property Format"); + Logger.debug(1, "Using Kernel 2.1 LDAP Property Format"); mPropManager = new LegacyLDAPPropertyManager(this); } else { - Logger.debug("Using Kernel 2.2 LDAP Property Format"); + Logger.debug(1, "Using Kernel 2.2 LDAP Property Format"); mPropManager = new LDAPPropertyManager(this); } mRoleManager = new LDAPRoleManager(this, "cn=agent,"+DomainPath.mTypeRoot, EntityPath.mTypeRoot); diff --git a/src/main/java/com/c2kernel/scripting/Script.java b/src/main/java/com/c2kernel/scripting/Script.java index 7e40003..c517291 100644 --- a/src/main/java/com/c2kernel/scripting/Script.java +++ b/src/main/java/com/c2kernel/scripting/Script.java @@ -123,7 +123,7 @@ public class Script } catch (ObjectNotFoundException e) { - throw new ScriptingEngineException("Script "+scriptName+" not found"); + throw new ScriptingEngineException("Script '"+scriptName+"' not found"); } } @@ -200,9 +200,9 @@ public class Script addIncludedInputParam(includeParam.getName(), includeParam.getType()); } } catch (NumberFormatException e) { - throw new ScriptParsingException("Invalid version in imported script "+includeName+"_"+includeVersion); + throw new ScriptParsingException("Invalid version in imported script name:'"+includeName+"', version:'"+includeVersion+"'"); } catch (ScriptingEngineException e) { - throw new ScriptParsingException("Error parsing imported script "+includeName+"_"+includeVersion+": "+e.getMessage()); + throw new ScriptParsingException("Error parsing imported script '"+includeName+"', version '"+includeVersion+"': "+e.getMessage()); } diff --git a/src/main/java/com/c2kernel/utils/Logger.java b/src/main/java/com/c2kernel/utils/Logger.java index e5d5013..2a9ddcb 100644 --- a/src/main/java/com/c2kernel/utils/Logger.java +++ b/src/main/java/com/c2kernel/utils/Logger.java @@ -62,12 +62,15 @@ public class Logger return mHighestLogLevel >= logLevel; } /** - * Use this only for temporary messages while developing/debugging When the code is stable, change calls to debug to - * message/warning/error with an appropriate log level This makes it easier to manage debug calls in the source. + * Use this only for temporary messages while developing/debugging. When the code is stable, change calls to debug to + * message/warning/error with an appropriate log level. Is is marked deprecated to highlight stray calls. This makes + * it easier to manage debug calls in the source. * * @param msg - * the string to write to the console, or log file if specified in cmd line + * @deprecated */ + @Deprecated static public void debug(String msg) { msg("DEBUG : " + msg); -- cgit v1.2.3