IDEMPIERE-638 Check log level before calling logging method / logger.info+fine

This commit is contained in:
Richard Morales 2013-02-22 17:17:40 -05:00
parent 427e8e08f2
commit 74d197cb57
12 changed files with 34 additions and 36 deletions

View File

@ -13,6 +13,8 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.exceptions; package org.adempiere.exceptions;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -68,7 +70,7 @@ public class PORelationException extends AdempiereException {
public static void throwWrongKeyColumnCount(final PO po) { public static void throwWrongKeyColumnCount(final PO po) {
logger.fine("Invoked with po " + po); if (logger.isLoggable(Level.FINE)) logger.fine("Invoked with po " + po);
final Object[] msgParams = new Object[] { po.toString(), final Object[] msgParams = new Object[] { po.toString(),
po.get_KeyColumns().length }; po.get_KeyColumns().length };

View File

@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.PORelationException; import org.adempiere.exceptions.PORelationException;
@ -143,7 +144,7 @@ public class MRelationType extends X_AD_RelationType implements IZoomProvider {
final List<MRelationType> result = evalResultSet(po, windowId, rs); final List<MRelationType> result = evalResultSet(po, windowId, rs);
logger.info("There are " + result.size() + " matching types for " if (logger.isLoggable(Level.INFO)) logger.info("There are " + result.size() + " matching types for "
+ po); + po);
return result; return result;
@ -294,7 +295,7 @@ public class MRelationType extends X_AD_RelationType implements IZoomProvider {
parsedWhere, po.get_TrxName()).first(); parsedWhere, po.get_TrxName()).first();
final boolean match = result != null; final boolean match = result != null;
logger.fine("whereClause='" + parsedWhere + "' matches po='" + po if (logger.isLoggable(Level.FINE)) logger.fine("whereClause='" + parsedWhere + "' matches po='" + po
+ "':" + match); + "':" + match);
return match; return match;
} }
@ -328,7 +329,7 @@ public class MRelationType extends X_AD_RelationType implements IZoomProvider {
final String parsedWhere = Env.parseContext(privateCtx, -1, where, final String parsedWhere = Env.parseContext(privateCtx, -1, where,
false); false);
logger.fine("whereClause='" + where + "'; parsedWhere='" + parsedWhere if (logger.isLoggable(Level.FINE)) logger.fine("whereClause='" + where + "'; parsedWhere='" + parsedWhere
+ "'"); + "'");
return parsedWhere; return parsedWhere;

View File

@ -95,7 +95,7 @@ public class ZoomInfoFactory {
if (alreadySeen.add(zoomInfo.destinationDisplay)) { if (alreadySeen.add(zoomInfo.destinationDisplay)) {
logger.fine("Adding zoomInfo " + zoomInfo); if (logger.isLoggable(Level.FINE)) logger.fine("Adding zoomInfo " + zoomInfo);
result.add(zoomInfo); result.add(zoomInfo);
} }
} }
@ -107,13 +107,13 @@ public class ZoomInfoFactory {
if (alreadySeen.add(zoomInfo.destinationDisplay)) { if (alreadySeen.add(zoomInfo.destinationDisplay)) {
logger.fine("Adding zoomInfo " + zoomInfo + " from " if (logger.isLoggable(Level.FINE)) logger.fine("Adding zoomInfo " + zoomInfo + " from "
+ GenericZoomProvider.class.getSimpleName()); + GenericZoomProvider.class.getSimpleName());
result.add(zoomInfo); result.add(zoomInfo);
} else { } else {
logger.fine("Skipping zoomInfo " + zoomInfo + " from " if (logger.isLoggable(Level.FINE)) logger.fine("Skipping zoomInfo " + zoomInfo + " from "
+ GenericZoomProvider.class.getSimpleName() + GenericZoomProvider.class.getSimpleName()
+ " because there is already one for destination '" + " because there is already one for destination '"
+ zoomInfo.destinationDisplay + "'"); + zoomInfo.destinationDisplay + "'");

View File

@ -13,7 +13,6 @@ import org.compiere.process.DocAction;
import org.compiere.process.DocumentEngine; import org.compiere.process.DocumentEngine;
import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfo;
import org.compiere.process.ProjectClose; import org.compiere.process.ProjectClose;
import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;

View File

@ -35,7 +35,7 @@ public class PipoDictionaryService implements IDictionaryService {
X_AD_Package_Imp_Proc adPackageImp = new X_AD_Package_Imp_Proc(Env.getCtx(), X_AD_Package_Imp_Proc adPackageImp = new X_AD_Package_Imp_Proc(Env.getCtx(),
0, trxName); 0, trxName);
File zipFilepath = packageFile; File zipFilepath = packageFile;
logger.info("zipFilepath->" + zipFilepath); if (logger.isLoggable(Level.INFO)) logger.info("zipFilepath->" + zipFilepath);
String parentDir = Zipper.getParentDir(zipFilepath); String parentDir = Zipper.getParentDir(zipFilepath);
File targetDir = new File(System.getProperty("java.io.tmpdir")); File targetDir = new File(System.getProperty("java.io.tmpdir"));
Zipper.unpackFile(zipFilepath, targetDir); Zipper.unpackFile(zipFilepath, targetDir);
@ -43,7 +43,7 @@ public class PipoDictionaryService implements IDictionaryService {
String dict_file = targetDir + File.separator + parentDir + File.separator String dict_file = targetDir + File.separator + parentDir + File.separator
+ "dict" + File.separator + "PackOut.xml"; + "dict" + File.separator + "PackOut.xml";
logger.info("dict file->" + dict_file); if (logger.isLoggable(Level.INFO)) logger.info("dict file->" + dict_file);
// call XML Handler // call XML Handler
String msg = packIn.importXML(dict_file, Env.getCtx(), trxName); String msg = packIn.importXML(dict_file, Env.getCtx(), trxName);
@ -54,7 +54,7 @@ public class PipoDictionaryService implements IDictionaryService {
adPackageImp.saveEx(); adPackageImp.saveEx();
Trx.get(trxName, false).commit(); Trx.get(trxName, false).commit();
logger.info("commit " + trxName); if (logger.isLoggable(Level.INFO)) logger.info("commit " + trxName);
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.SEVERE, "importXML:", e); logger.log(Level.SEVERE, "importXML:", e);
throw e; throw e;

View File

@ -25,12 +25,10 @@ public class AdempiereActivator implements BundleActivator {
@Override @Override
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
this.context = context; this.context = context;
if (logger.isLoggable(Level.INFO)) if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " starting...");
logger.info(getName() + " " + getVersion() + " starting...");
installPackage(); installPackage();
start(); start();
if (logger.isLoggable(Level.INFO)) if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + getVersion() + " ready.");
logger.info(getName() + " " + getVersion() + " ready.");
} }
public String getName() { public String getName() {
@ -80,11 +78,9 @@ public class AdempiereActivator implements BundleActivator {
if (pkg == null) { if (pkg == null) {
packIn(trxName); packIn(trxName);
install(); install();
if (logger.isLoggable(Level.INFO)) if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + version + " installed.");
logger.info(getName() + " " + version + " installed.");
} else { } else {
if (logger.isLoggable(Level.INFO)) if (logger.isLoggable(Level.INFO)) logger.info(getName() + " " + version + " was installed: "
logger.info(getName() + " " + version + " was installed: "
+ pkg.getCreated()); + pkg.getCreated());
} }
Trx.get(trxName, false).commit(); Trx.get(trxName, false).commit();
@ -136,7 +132,7 @@ public class AdempiereActivator implements BundleActivator {
@Override @Override
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
stop(); stop();
logger.info(context.getBundle().getSymbolicName() + " " if (logger.isLoggable(Level.INFO)) logger.info(context.getBundle().getSymbolicName() + " "
+ context.getBundle().getHeaders().get("Bundle-Version") + context.getBundle().getHeaders().get("Bundle-Version")
+ " stopped."); + " stopped.");
} }

View File

@ -98,7 +98,7 @@ public class AZoomAcross
windowID)) { windowID)) {
if (zoomInfo.query.getRecordCount() == 0) { if (zoomInfo.query.getRecordCount() == 0) {
logger.fine("No target records for destination " if (logger.isLoggable(Level.FINE)) logger.fine("No target records for destination "
+ zoomInfo.destinationDisplay); + zoomInfo.destinationDisplay);
continue; continue;
} }
@ -116,7 +116,7 @@ public class AZoomAcross
final int AD_Window_ID = zoomInfo.windowId; final int AD_Window_ID = zoomInfo.windowId;
final MQuery query = zoomInfo.query; final MQuery query = zoomInfo.query;
logger.info("AD_Window_ID=" + AD_Window_ID if (logger.isLoggable(Level.INFO)) logger.info("AD_Window_ID=" + AD_Window_ID
+ " - " + query); + " - " + query);
AWindow frame = new AWindow(null); AWindow frame = new AWindow(null);

View File

@ -877,7 +877,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
public void onAttachment() public void onAttachment()
{ {
int record_ID = adTabbox.getSelectedGridTab().getRecord_ID(); int record_ID = adTabbox.getSelectedGridTab().getRecord_ID();
logger.info("Record_ID=" + record_ID); if (logger.isLoggable(Level.INFO)) logger.info("Record_ID=" + record_ID);
if (record_ID == -1) // No Key if (record_ID == -1) // No Key
{ {
@ -910,7 +910,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
public void onChat() public void onChat()
{ {
int recordId = adTabbox.getSelectedGridTab().getRecord_ID(); int recordId = adTabbox.getSelectedGridTab().getRecord_ID();
logger.info("Record_ID=" + recordId); if (logger.isLoggable(Level.INFO)) logger.info("Record_ID=" + recordId);
if (recordId== -1) // No Key if (recordId== -1) // No Key
{ {
@ -1244,8 +1244,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (!detailTab) if (!detailTab)
{ {
String dbInfo = e.getMessage(); String dbInfo = e.getMessage();
if (logger.isLoggable(Level.INFO)) if (logger.isLoggable(Level.INFO)) logger.info(dbInfo);
logger.info(dbInfo);
if (adTabbox.getSelectedGridTab() != null && adTabbox.getSelectedGridTab().isQueryActive()) if (adTabbox.getSelectedGridTab() != null && adTabbox.getSelectedGridTab().isQueryActive())
dbInfo = "[ " + dbInfo + " ]"; dbInfo = "[ " + dbInfo + " ]";
breadCrumb.setStatusDB(dbInfo, e); breadCrumb.setStatusDB(dbInfo, e);
@ -2086,7 +2085,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
{ {
Listitem li = iter.next(); Listitem li = iter.next();
if(li != null) if(li != null)
logger.fine((String) li.getValue()); if (logger.isLoggable(Level.FINE)) logger.fine((String) li.getValue());
} }
} }
@ -2325,7 +2324,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
return; return;
} }
logger.info(wButton.toString()); if (logger.isLoggable(Level.INFO)) logger.info(wButton.toString());
final String col = wButton.getColumnName(); final String col = wButton.getColumnName();

View File

@ -149,8 +149,7 @@ public abstract class ADForm extends Window implements EventListener<Event>
} }
else else
{ {
if (logger.isLoggable(Level.INFO)) if (logger.isLoggable(Level.INFO)) logger.info("AD_Form_ID=" + adFormID + " - Class=" + formName);
logger.info("AD_Form_ID=" + adFormID + " - Class=" + formName);
form = Extensions.getForm(formName); form = Extensions.getForm(formName);
if (form != null) if (form != null)

View File

@ -19,6 +19,7 @@ import java.math.BigInteger;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.AdempiereException;
import org.adempiere.util.Callback; import org.adempiere.util.Callback;
@ -445,7 +446,7 @@ public class ResetPasswordPanel extends Window implements EventListener<Event>
user.saveEx(); user.saveEx();
if (sendEmail(user, newPassword)) if (sendEmail(user, newPassword))
logger.fine(user.getEMail()); if (logger.isLoggable(Level.FINE)) logger.fine(user.getEMail());
else else
{ {
if (errorMsg.length() > 0) if (errorMsg.length() > 0)

View File

@ -111,7 +111,7 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
return; return;
} }
logger.fine("DocStatus=" + DocStatus if (logger.isLoggable(Level.FINE)) logger.fine("DocStatus=" + DocStatus
+ ", DocAction=" + DocAction + ", OrderType=" + OrderType + ", DocAction=" + DocAction + ", OrderType=" + OrderType
+ ", IsSOTrx=" + IsSOTrx + ", Processing=" + Processing + ", IsSOTrx=" + IsSOTrx + ", Processing=" + Processing
+ ", AD_Table_ID=" +gridTab.getAD_Table_ID() + ", Record_ID=" + gridTab.getRecord_ID()); + ", AD_Table_ID=" +gridTab.getAD_Table_ID() + ", Record_ID=" + gridTab.getRecord_ID());
@ -164,7 +164,7 @@ public class WDocActionPanel extends Window implements EventListener<Event>, Dia
if(doctypeId==null || doctypeId.intValue()==0){ if(doctypeId==null || doctypeId.intValue()==0){
doctypeId = (Integer)gridTab.getValue("C_DocTypeTarget_ID"); doctypeId = (Integer)gridTab.getValue("C_DocTypeTarget_ID");
} }
logger.fine("get doctype: " + doctypeId); if (logger.isLoggable(Level.FINE)) logger.fine("get doctype: " + doctypeId);
if (doctypeId != null) { if (doctypeId != null) {
index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()), index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()),
Env.getAD_Role_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx()),

View File

@ -18,6 +18,7 @@
package org.adempiere.webui.window; package org.adempiere.webui.window;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level;
import org.compiere.util.CLogMgt; import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -119,7 +120,7 @@ public class FDialog
Properties ctx = Env.getCtx(); Properties ctx = Env.getCtx();
StringBuffer out = null; StringBuffer out = null;
logger.info(adMessage + " - " + message); if (logger.isLoggable(Level.INFO)) logger.info(adMessage + " - " + message);
out = constructMessage(adMessage, message); out = constructMessage(adMessage, message);
@ -216,7 +217,7 @@ public class FDialog
Properties ctx = Env.getCtx(); Properties ctx = Env.getCtx();
StringBuffer out = new StringBuffer(); StringBuffer out = new StringBuffer();
logger.info(adMessage + " - " + message); if (logger.isLoggable(Level.INFO)) logger.info(adMessage + " - " + message);
if (CLogMgt.isLevelFinest()) if (CLogMgt.isLevelFinest())
{ {
@ -347,7 +348,7 @@ public class FDialog
StringBuffer out = new StringBuffer(); StringBuffer out = new StringBuffer();
logger.info(adMessage + " - " + message); if (logger.isLoggable(Level.INFO)) logger.info(adMessage + " - " + message);
if (CLogMgt.isLevelFinest()) if (CLogMgt.isLevelFinest())
{ {