IDEMPIERE-638 Check log level before calling logging method / s_log.finest+finer

This commit is contained in:
Richard Morales 2013-02-22 15:43:26 -05:00
parent f364522dd5
commit b5102829f1
7 changed files with 41 additions and 42 deletions

View File

@ -76,7 +76,7 @@ public class MArchive extends X_AD_Archive {
if (list.size() == 0) if (list.size() == 0)
s_log.fine(sql.toString()); s_log.fine(sql.toString());
else else
s_log.finer(sql.toString()); if (s_log.isLoggable(Level.FINER)) s_log.finer(sql.toString());
// //
MArchive[] retValue = new MArchive[list.size()]; MArchive[] retValue = new MArchive[list.size()];
list.toArray(retValue); list.toArray(retValue);

View File

@ -221,7 +221,7 @@ public class MCost extends X_M_Cost
// Standard costs - just Material Costs // Standard costs - just Material Costs
if (MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod)) if (MCostElement.COSTINGMETHOD_StandardCosting.equals(costingMethod))
{ {
s_log.finer("MaterialCosts = " + materialCost); if (s_log.isLoggable(Level.FINER)) s_log.finer("MaterialCosts = " + materialCost);
return materialCost; return materialCost;
} }
if (MCostElement.COSTINGMETHOD_Fifo.equals(costingMethod) if (MCostElement.COSTINGMETHOD_Fifo.equals(costingMethod)
@ -240,7 +240,7 @@ public class MCost extends X_M_Cost
if (costs.signum() == 0) if (costs.signum() == 0)
return null; return null;
s_log.finer("Sum Costs = " + costs); if (s_log.isLoggable(Level.FINER)) s_log.finer("Sum Costs = " + costs);
int precision = as.getCostingPrecision(); int precision = as.getCostingPrecision();
if (percentage.signum() == 0) // no percentages if (percentage.signum() == 0) // no percentages
{ {
@ -254,7 +254,7 @@ public class MCost extends X_M_Cost
costs = costs.add(percentCost); costs = costs.add(percentCost);
if (costs.scale() > precision) if (costs.scale() > precision)
costs = costs.setScale(precision, BigDecimal.ROUND_HALF_UP); costs = costs.setScale(precision, BigDecimal.ROUND_HALF_UP);
s_log.finer("Sum Costs = " + costs + " (Add=" + percentCost + ")"); if (s_log.isLoggable(Level.FINER)) s_log.finer("Sum Costs = " + costs + " (Add=" + percentCost + ")");
return costs; return costs;
} // getCurrentCost } // getCurrentCost
@ -502,7 +502,7 @@ public class MCost extends X_M_Cost
if (retValue != null) if (retValue != null)
{ {
s_log.finer(product.getName() + " = " + retValue); if (s_log.isLoggable(Level.FINER)) s_log.finer(product.getName() + " = " + retValue);
return retValue; return retValue;
} }
return null; return null;
@ -565,7 +565,7 @@ public class MCost extends X_M_Cost
if (retValue != null) if (retValue != null)
{ {
s_log.finer(product.getName() + " = " + retValue); if (s_log.isLoggable(Level.FINER)) s_log.finer(product.getName() + " = " + retValue);
return retValue; return retValue;
} }
return null; return null;
@ -617,7 +617,7 @@ public class MCost extends X_M_Cost
if (retValue != null) if (retValue != null)
{ {
s_log.finer(product.getName() + " = " + retValue); if (s_log.isLoggable(Level.FINER)) s_log.finer(product.getName() + " = " + retValue);
return retValue; return retValue;
} }
return null; return null;
@ -864,7 +864,7 @@ public class MCost extends X_M_Cost
BigDecimal matchQty = rs.getBigDecimal(2); BigDecimal matchQty = rs.getBigDecimal(2);
if (matchQty == null) if (matchQty == null)
{ {
s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty); if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty);
continue; continue;
} }
// Assumption: everything is matched // Assumption: everything is matched
@ -884,7 +884,7 @@ public class MCost extends X_M_Cost
BigDecimal newAmt = averageCurrent.add(averageIncrease); BigDecimal newAmt = averageCurrent.add(averageIncrease);
newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty
+ ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt); + ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt);
} }
} }
@ -900,7 +900,7 @@ public class MCost extends X_M_Cost
// //
if (newAverageAmt != null && newAverageAmt.signum() != 0) if (newAverageAmt != null && newAverageAmt.signum() != 0)
{ {
s_log.finer(product.getName() + " = " + newAverageAmt); if (s_log.isLoggable(Level.FINER)) s_log.finer(product.getName() + " = " + newAverageAmt);
return newAverageAmt; return newAverageAmt;
} }
return null; return null;
@ -958,7 +958,7 @@ public class MCost extends X_M_Cost
BigDecimal matchQty = rs.getBigDecimal(2); BigDecimal matchQty = rs.getBigDecimal(2);
if (matchQty == null) if (matchQty == null)
{ {
s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty); if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty);
continue; continue;
} }
// Assumption: everything is matched // Assumption: everything is matched
@ -980,7 +980,7 @@ public class MCost extends X_M_Cost
BigDecimal newAmt = averageCurrent.add(averageIncrease); BigDecimal newAmt = averageCurrent.add(averageIncrease);
newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAmt = newAmt.setScale(as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP); newAverageAmt = newAmt.divide(newStockQty, as.getCostingPrecision(), BigDecimal.ROUND_HALF_UP);
s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", StockQty=" + newStockQty
+ ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt); + ", Match=" + matchQty + ", Cost=" + cost + ", NewAvg=" + newAverageAmt);
} }
} }
@ -996,7 +996,7 @@ public class MCost extends X_M_Cost
// //
if (newAverageAmt != null && newAverageAmt.signum() != 0) if (newAverageAmt != null && newAverageAmt.signum() != 0)
{ {
s_log.finer(product.getName() + " = " + newAverageAmt); if (s_log.isLoggable(Level.FINER)) s_log.finer(product.getName() + " = " + newAverageAmt);
return newAverageAmt; return newAverageAmt;
} }
return null; return null;
@ -1082,7 +1082,7 @@ public class MCost extends X_M_Cost
QtyCost pp = new QtyCost (movementQty, Env.ZERO); QtyCost pp = new QtyCost (movementQty, Env.ZERO);
fifo.add(pp); fifo.add(pp);
} }
s_log.finer("Movement=" + movementQty + ", Size=" + fifo.size()); if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", Size=" + fifo.size());
continue; continue;
} }
// Assumption: everything is matched // Assumption: everything is matched
@ -1117,7 +1117,7 @@ public class MCost extends X_M_Cost
QtyCost pp = new QtyCost (movementQty, cost); QtyCost pp = new QtyCost (movementQty, cost);
fifo.add(pp); fifo.add(pp);
} }
s_log.finer("Movement=" + movementQty + ", Size=" + fifo.size()); if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", Size=" + fifo.size());
} }
} }
catch (SQLException e) catch (SQLException e)
@ -1135,7 +1135,7 @@ public class MCost extends X_M_Cost
return null; return null;
} }
QtyCost pp = (QtyCost)fifo.get(0); QtyCost pp = (QtyCost)fifo.get(0);
s_log.finer(product.getName() + " = " + pp.Cost); if (s_log.isLoggable(Level.FINER)) s_log.finer(product.getName() + " = " + pp.Cost);
return pp.Cost; return pp.Cost;
} // calculateFiFo } // calculateFiFo
@ -1220,7 +1220,7 @@ public class MCost extends X_M_Cost
QtyCost pp = new QtyCost (movementQty, Env.ZERO); QtyCost pp = new QtyCost (movementQty, Env.ZERO);
lifo.add(pp); lifo.add(pp);
} }
s_log.finer("Movement=" + movementQty + ", Size=" + lifo.size()); if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", Size=" + lifo.size());
continue; continue;
} }
// Assumption: everything is matched // Assumption: everything is matched
@ -1236,7 +1236,7 @@ public class MCost extends X_M_Cost
// //
QtyCost pp = new QtyCost (movementQty, cost); QtyCost pp = new QtyCost (movementQty, cost);
lifo.add(pp); lifo.add(pp);
s_log.finer("Movement=" + movementQty + ", Size=" + lifo.size()); if (s_log.isLoggable(Level.FINER)) s_log.finer("Movement=" + movementQty + ", Size=" + lifo.size());
} }
} }
catch (SQLException e) catch (SQLException e)
@ -1254,7 +1254,7 @@ public class MCost extends X_M_Cost
return null; return null;
} }
QtyCost pp = (QtyCost)lifo.get(lifo.size()-1); QtyCost pp = (QtyCost)lifo.get(lifo.size()-1);
s_log.finer(product.getName() + " = " + pp.Cost); if (s_log.isLoggable(Level.FINER)) s_log.finer(product.getName() + " = " + pp.Cost);
return pp.Cost; return pp.Cost;
} // calculateLiFo } // calculateLiFo

View File

@ -2,7 +2,6 @@ package org.compiere.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.CallableStatement; import java.sql.CallableStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;

View File

@ -21,6 +21,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Level;
import static org.compiere.model.SystemIDs.*; import static org.compiere.model.SystemIDs.*;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -44,7 +46,7 @@ public class MEntityType extends X_AD_EntityType
/** /**
* *
*/ */
private static final long serialVersionUID = 8906219523978497906L; private static final long serialVersionUID = 4670009709141738924L;
/** /**
* Get Entity Types * Get Entity Types
@ -61,7 +63,7 @@ public class MEntityType extends X_AD_EntityType
.list(); .list();
s_entityTypes = new MEntityType[list.size()]; s_entityTypes = new MEntityType[list.size()];
list.toArray(s_entityTypes); list.toArray(s_entityTypes);
s_log.finer("# " + s_entityTypes.length); if (s_log.isLoggable(Level.FINER)) s_log.finer("# " + s_entityTypes.length);
return s_entityTypes; return s_entityTypes;
} // getEntityTypes } // getEntityTypes
@ -99,7 +101,7 @@ public class MEntityType extends X_AD_EntityType
list.add(s); list.add(s);
retValue[i] = s; retValue[i] = s;
} }
s_log.finer(list.toString()); if (s_log.isLoggable(Level.FINER)) s_log.finer(list.toString());
return retValue; return retValue;
} // getEntityTypeStrings } // getEntityTypeStrings
@ -130,7 +132,7 @@ public class MEntityType extends X_AD_EntityType
} }
String[] retValue = new String[list.size()]; String[] retValue = new String[list.size()];
list.toArray(retValue); list.toArray(retValue);
s_log.finer(list.toString()); if (s_log.isLoggable(Level.FINER)) s_log.finer(list.toString());
return retValue; return retValue;
} // getClathpaths } // getClathpaths
@ -162,7 +164,7 @@ public class MEntityType extends X_AD_EntityType
} }
String[] retValue = new String[list.size()]; String[] retValue = new String[list.size()];
list.toArray(retValue); list.toArray(retValue);
s_log.finer(list.toString()); if (s_log.isLoggable(Level.FINER)) s_log.finer(list.toString());
return retValue; return retValue;
} // getModelPackages } // getModelPackages

View File

@ -367,8 +367,7 @@ public class MLookupFactory
MLookupInfo retValue = (MLookupInfo)s_cacheRefTable.get(key.toString()); MLookupInfo retValue = (MLookupInfo)s_cacheRefTable.get(key.toString());
if (retValue != null) if (retValue != null)
{ {
if (s_log.isLoggable(Level.FINEST)) if (s_log.isLoggable(Level.FINEST)) s_log.finest("Cache: " + retValue);
s_log.finest("Cache: " + retValue);
return retValue.cloneIt(); return retValue.cloneIt();
} }
// //
@ -556,8 +555,7 @@ public class MLookupFactory
else else
realSQL.append(" ORDER BY 3"); realSQL.append(" ORDER BY 3");
if (s_log.isLoggable(Level.FINEST)) if (s_log.isLoggable(Level.FINEST)) s_log.finest("AD_Reference_Value_ID=" + AD_Reference_Value_ID + " - " + realSQL);
s_log.finest("AD_Reference_Value_ID=" + AD_Reference_Value_ID + " - " + realSQL);
if (overrideZoomWindow > 0) if (overrideZoomWindow > 0)
{ {
ZoomWindow = overrideZoomWindow; ZoomWindow = overrideZoomWindow;

View File

@ -548,7 +548,7 @@ public class MSequence extends X_AD_Sequence
if (suffix != null && suffix.length() > 0) if (suffix != null && suffix.length() > 0)
doc.append(Env.parseVariable(suffix, po, trxName, false)); doc.append(Env.parseVariable(suffix, po, trxName, false));
String documentNo = doc.toString(); String documentNo = doc.toString();
s_log.finer (documentNo + " (" + incrementNo + ")" if (s_log.isLoggable(Level.FINER)) s_log.finer (documentNo + " (" + incrementNo + ")"
+ " - Sequence=" + AD_Sequence_ID + " [" + trx + "]"); + " - Sequence=" + AD_Sequence_ID + " [" + trx + "]");
return documentNo; return documentNo;
} }
@ -596,7 +596,7 @@ public class MSequence extends X_AD_Sequence
MDocType dt = MDocType.get (Env.getCtx(), C_DocType_ID); // wrong for SERVER, but r/o MDocType dt = MDocType.get (Env.getCtx(), C_DocType_ID); // wrong for SERVER, but r/o
if (dt != null && !dt.isDocNoControlled()) if (dt != null && !dt.isDocNoControlled())
{ {
s_log.finer("DocType_ID=" + C_DocType_ID + " Not DocNo controlled"); if (s_log.isLoggable(Level.FINER)) s_log.finer("DocType_ID=" + C_DocType_ID + " Not DocNo controlled");
return null; return null;
} }
if (definite && ! dt.isOverwriteSeqOnComplete()) { if (definite && ! dt.isOverwriteSeqOnComplete()) {

View File

@ -28,10 +28,10 @@ import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
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.exceptions.DBException; import org.adempiere.exceptions.DBException;
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;
@ -120,7 +120,7 @@ public class SetGetUtil
{ {
for (SetGetModel model : models) for (SetGetModel model : models)
{ {
if(CLogMgt.isLevelFinest()) s_log.finest("Model: " + model); if (s_log.isLoggable(Level.FINEST)) s_log.finest("Model: " + model);
if (rs.next()) if (rs.next())
{ {
if (columnNames == null) if (columnNames == null)
@ -149,12 +149,12 @@ public class SetGetUtil
} }
// //
ok = model.set_AttrValue(columnName, obj); ok = model.set_AttrValue(columnName, obj);
if (CLogMgt.isLevelFinest()) s_log.finest("columnName=" + columnName + ", value=[" + obj + "][" + (obj != null ? obj.getClass().getName() : "null") + "], ok=" + ok); if (s_log.isLoggable(Level.FINEST)) s_log.finest("columnName=" + columnName + ", value=[" + obj + "][" + (obj != null ? obj.getClass().getName() : "null") + "], ok=" + ok);
} }
} }
else else
{ {
s_log.finest("@NoResult@"); if (s_log.isLoggable(Level.FINEST)) s_log.finest("@NoResult@");
break; break;
} }
} }
@ -234,7 +234,7 @@ public class SetGetUtil
String[] includeFields, String[] excludeFields, String[] includeFields, String[] excludeFields,
boolean trackOnlyChanges) boolean trackOnlyChanges)
{ {
if (CLogMgt.isLevelFinest()) if (s_log.isLoggable(Level.FINEST))
{ {
s_log.finest("Entering: From=" + from+ " - To=" + to); s_log.finest("Entering: From=" + from+ " - To=" + to);
// s_log.finest("includeFields=" + ARHIPAC.toString(includeFields)); // s_log.finest("includeFields=" + ARHIPAC.toString(includeFields));
@ -243,7 +243,7 @@ public class SetGetUtil
// //
if (to == null || from == null) if (to == null || from == null)
{ {
if (CLogMgt.isLevelFinest()) if (s_log.isLoggable(Level.FINEST))
{ {
s_log.finest("Leaving: to == null || from == null"); s_log.finest("Leaving: to == null || from == null");
Thread.dumpStack(); Thread.dumpStack();
@ -308,19 +308,19 @@ public class SetGetUtil
//- //-
if (isExcluded) if (isExcluded)
{ {
if (CLogMgt.isLevelFinest()) s_log.finest("Field " + colName + " [SKIP:excluded]"); if (s_log.isLoggable(Level.FINEST)) s_log.finest("Field " + colName + " [SKIP:excluded]");
continue; continue;
} }
int idx_to = to.get_ColumnIndex(colName); int idx_to = to.get_ColumnIndex(colName);
if (idx_to < 0) if (idx_to < 0)
{ {
if (CLogMgt.isLevelFinest()) s_log.finest("Field " + colName + " [SKIP:idx_to < 0]"); if (s_log.isLoggable(Level.FINEST)) s_log.finest("Field " + colName + " [SKIP:idx_to < 0]");
continue; continue;
} }
if (to.p_info.isVirtualColumn(idx_to) || to.p_info.isKey(idx_to)) if (to.p_info.isVirtualColumn(idx_to) || to.p_info.isKey(idx_to))
{ // KeyColumn { // KeyColumn
if (CLogMgt.isLevelFinest()) s_log.finest("Field " + colName + " [SKIP:virtual or key]"); if (s_log.isLoggable(Level.FINEST)) s_log.finest("Field " + colName + " [SKIP:virtual or key]");
continue; continue;
} }
@ -331,10 +331,10 @@ public class SetGetUtil
{ {
copiedFields++; copiedFields++;
} }
if (CLogMgt.isLevelFinest()) s_log.finest("Field " + colName + "=[" + value + "], idx=" + idx_from + "->" + idx_to); if (s_log.isLoggable(Level.FINEST)) s_log.finest("Field " + colName + "=[" + value + "], idx=" + idx_from + "->" + idx_to);
} }
// //
if (CLogMgt.isLevelFinest()) s_log.finest("Leaving: to=" + to); if (s_log.isLoggable(Level.FINEST)) s_log.finest("Leaving: to=" + to);
return copiedFields; return copiedFields;
} // copyValues } // copyValues