IDEMPIERE-638 Check log level before calling logging method

This commit is contained in:
Carlos Ruiz 2013-03-15 16:16:28 -05:00
parent c5f92ffdf7
commit b167a4c7df
10 changed files with 69 additions and 83 deletions

View File

@ -37,7 +37,6 @@ import javax.swing.JOptionPane;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.adempiere.util.GenerateModel;
import org.compiere.util.CLogger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -55,7 +54,7 @@ import org.w3c.dom.NodeList;
*/
public class AddressLookup implements AddressLookupInterface {
/** The logger. */
private static CLogger log = CLogger.getCLogger(GenerateModel.class);
private static CLogger log = CLogger.getCLogger(AddressLookup.class);
/**
* The access code which is used along with clientID to authenticate the

View File

@ -25,7 +25,7 @@ import org.compiere.util.CLogger;
*/
public class DefaultPaymentProcessorFactory implements IPaymentProcessorFactory {
private final static CLogger s_log = CLogger.getCLogger(IPaymentProcessorFactory.class);
private final static CLogger s_log = CLogger.getCLogger(DefaultPaymentProcessorFactory.class);
/**
* default constructor

View File

@ -142,7 +142,7 @@ public class GridTable extends AbstractTableModel
m_virtual = virtual;
} // MTable
private static CLogger log = CLogger.getCLogger(GridTable.class.getName());
private static CLogger log = CLogger.getCLogger(GridTable.class);
private Properties m_ctx;
private int m_AD_Table_ID;
private String m_tableName = "";

View File

@ -89,6 +89,9 @@ public final class Env
private static List<IEnvEventListener> eventListeners = new ArrayList<IEnvEventListener>();
/** Logger */
private static CLogger log = CLogger.getCLogger(Env.class);
/**
* @param provider
* @deprecated
@ -245,7 +248,7 @@ public final class Env
{
if (ctx == null || context == null)
return;
getLogger().finer("Context " + context + "==" + value);
if (log.isLoggable(Level.FINER)) log.finer("Context " + context + "==" + value);
//
if (value == null || value.length() == 0)
ctx.remove(context);
@ -253,10 +256,6 @@ public final class Env
ctx.setProperty(context, value);
} // setContext
private static CLogger getLogger() {
return CLogger.getCLogger(Env.class.getName());
}
/**
* Set Global Context to Value
* @param ctx context
@ -270,7 +269,7 @@ public final class Env
if (value == null)
{
ctx.remove(context);
getLogger().finer("Context " + context + "==" + value);
if (log.isLoggable(Level.FINER)) log.finer("Context " + context + "==" + value);
}
else
{ // JDBC Format 2005-05-09 00:00:00.0
@ -284,7 +283,7 @@ public final class Env
//stringValue = stringValue.substring(0, stringValue.indexOf("."));
// KTU
ctx.setProperty(context, stringValue);
getLogger().finer("Context " + context + "==" + stringValue);
if (log.isLoggable(Level.FINER)) log.finer("Context " + context + "==" + stringValue);
}
} // setContext
@ -298,7 +297,7 @@ public final class Env
{
if (ctx == null || context == null)
return;
getLogger().finer("Context " + context + "==" + value);
if (log.isLoggable(Level.FINER)) log.finer("Context " + context + "==" + value);
//
ctx.setProperty(context, String.valueOf(value));
} // setContext
@ -325,8 +324,7 @@ public final class Env
{
if (ctx == null || context == null)
return;
if (getLogger().isLoggable(Level.FINER))
getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
if (log.isLoggable(Level.FINER)) log.finer("Context("+WindowNo+") " + context + "==" + value);
//
if (value == null || value.equals(""))
ctx.remove(WindowNo+"|"+context);
@ -348,8 +346,7 @@ public final class Env
if (value == null)
{
ctx.remove(WindowNo+"|"+context);
if (getLogger().isLoggable(Level.FINER))
getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
if (log.isLoggable(Level.FINER)) log.finer("Context("+WindowNo+") " + context + "==" + value);
}
else
{ // JDBC Format 2005-05-09 00:00:00.0
@ -363,8 +360,7 @@ public final class Env
//stringValue = stringValue.substring(0, stringValue.indexOf("."));
// KTU
ctx.setProperty(WindowNo+"|"+context, stringValue);
if (getLogger().isLoggable(Level.FINER))
getLogger().finer("Context("+WindowNo+") " + context + "==" + stringValue);
if (log.isLoggable(Level.FINER)) log.finer("Context("+WindowNo+") " + context + "==" + stringValue);
}
} // setContext
@ -379,8 +375,7 @@ public final class Env
{
if (ctx == null || context == null)
return;
if (getLogger().isLoggable(Level.FINER))
getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
if (log.isLoggable(Level.FINER)) log.finer("Context("+WindowNo+") " + context + "==" + value);
//
ctx.setProperty(WindowNo+"|"+context, String.valueOf(value));
} // setContext
@ -425,8 +420,7 @@ public final class Env
{
if (ctx == null || context == null)
return;
if (getLogger().isLoggable(Level.FINEST))
getLogger().finest("Context("+WindowNo+","+TabNo+") " + context + "==" + value);
if (log.isLoggable(Level.FINEST)) log.finest("Context("+WindowNo+","+TabNo+") " + context + "==" + value);
//
if (value == null)
if (context.endsWith("_ID"))
@ -643,7 +637,7 @@ public final class Env
}
catch (NumberFormatException e)
{
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
log.log(Level.SEVERE, "(" + context + ") = " + s, e);
}
return 0;
} // getContextAsInt
@ -667,7 +661,7 @@ public final class Env
}
catch (NumberFormatException e)
{
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
log.log(Level.SEVERE, "(" + context + ") = " + s, e);
}
return 0;
} // getContextAsInt
@ -692,7 +686,7 @@ public final class Env
}
catch (NumberFormatException e)
{
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
log.log(Level.SEVERE, "(" + context + ") = " + s, e);
}
return 0;
} // getContextAsInt
@ -717,7 +711,7 @@ public final class Env
}
catch (NumberFormatException e)
{
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
log.log(Level.SEVERE, "(" + context + ") = " + s, e);
}
return 0;
} // getContextAsInt
@ -853,7 +847,7 @@ public final class Env
{
if (!"#date".equalsIgnoreCase(context))
{
getLogger().log(Level.WARNING, "No value for: " + context);
log.log(Level.WARNING, "No value for: " + context);
}
return new Timestamp(System.currentTimeMillis());
}
@ -1109,7 +1103,7 @@ public final class Env
}
catch (SQLException e)
{
getLogger().log(Level.SEVERE, "", e);
log.log(Level.SEVERE, "", e);
}
finally {
DB.close(rs, pstmt);
@ -1138,7 +1132,7 @@ public final class Env
}
catch (SQLException e)
{
getLogger().log(Level.SEVERE, "", e);
log.log(Level.SEVERE, "", e);
}
finally {
DB.close(rs, pstmt);
@ -1182,7 +1176,7 @@ public final class Env
}
catch (SQLException e)
{
getLogger().log(Level.SEVERE, "", e);
log.log(Level.SEVERE, "", e);
}
finally {
DB.close(rs, pstmt);
@ -1194,7 +1188,7 @@ public final class Env
// No Language - set to System
if (AD_Languages.size() == 0)
{
getLogger().warning ("NO System Language - Set to Base " + Language.getBaseAD_Language());
log.warning ("NO System Language - Set to Base " + Language.getBaseAD_Language());
language.setAD_Language(Language.getBaseAD_Language());
return;
}
@ -1207,7 +1201,7 @@ public final class Env
String langCompare = language.getAD_Language().substring(0, 2);
if (lang.equals(langCompare))
{
getLogger().fine("Found similar Language " + AD_Language);
if (log.isLoggable(Level.FINE)) log.fine("Found similar Language " + AD_Language);
language.setAD_Language(AD_Language);
return;
}
@ -1216,7 +1210,7 @@ public final class Env
// We found same language
// if (!"0".equals(Msg.getMsg(AD_Language, "0")))
getLogger().warning ("Not System Language=" + language
log.warning ("Not System Language=" + language
+ " - Set to Base Language " + Language.getBaseAD_Language());
language.setAD_Language(Language.getBaseAD_Language());
} // verifyLanguage
@ -1367,8 +1361,7 @@ public final class Env
int j = inStr.indexOf('@'); // next @
if (j < 0)
{
if (getLogger().isLoggable(Level.INFO))
getLogger().log(Level.INFO, "No second tag: " + inStr);
if (log.isLoggable(Level.INFO)) log.log(Level.INFO, "No second tag: " + inStr);
//not context variable, add back @ and break
outStr.append("@");
break;
@ -1394,7 +1387,7 @@ public final class Env
if (ctxInfo.length() == 0)
{
getLogger().config("No Context Win=" + WindowNo + " for: " + token);
if (log.isLoggable(Level.CONFIG)) log.config("No Context Win=" + WindowNo + " for: " + token);
if (!ignoreUnparsable)
return ""; // token not found
}
@ -1448,7 +1441,7 @@ public final class Env
int j = inStr.indexOf('@'); // next @
if (j < 0)
{
getLogger().log(Level.SEVERE, "No second tag: " + inStr);
log.log(Level.SEVERE, "No second tag: " + inStr);
return ""; // no second tag
}
@ -1580,7 +1573,7 @@ public final class Env
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
if (url == null)
{
getLogger().log(Level.SEVERE, "Not found: " + fileNameInImageDir);
log.log(Level.SEVERE, "Not found: " + fileNameInImageDir);
return null;
}
Toolkit tk = Toolkit.getDefaultToolkit();
@ -1600,7 +1593,7 @@ public final class Env
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
if (url == null)
{
getLogger().log(Level.INFO, "Not found: " + fileNameInImageDir);
if (log.isLoggable(Level.INFO)) log.log(Level.INFO, "Not found: " + fileNameInImageDir);
return null;
}
return new ImageIcon(url);
@ -1625,7 +1618,7 @@ public final class Env
// url = Adempiere.class.getResource("images/" + fileName+".png");
if (url == null)
{
getLogger().log(Level.INFO, "GIF/PNG Not found: " + fileName);
if (log.isLoggable(Level.INFO)) log.log(Level.INFO, "GIF/PNG Not found: " + fileName);
return null;
}
return new ImageIcon(url);
@ -1638,7 +1631,7 @@ public final class Env
*/
public static void startBrowser (String url)
{
getLogger().info(url);
if (log.isLoggable(Level.INFO)) log.info(url);
getContextProvider().showURL(url);
} // startBrowser
@ -1670,16 +1663,16 @@ public final class Env
*/
public static void sleep (int sec)
{
getLogger().info("Start - Seconds=" + sec);
if (log.isLoggable(Level.INFO)) log.info("Start - Seconds=" + sec);
try
{
Thread.sleep(sec*1000);
}
catch (Exception e)
{
getLogger().log(Level.WARNING, "", e);
log.log(Level.WARNING, "", e);
}
getLogger().info("End");
if (log.isLoggable(Level.INFO)) log.info("End");
} // sleep
/**
@ -1723,7 +1716,7 @@ public final class Env
*/
public static GridWindowVO getMWindowVO (int WindowNo, int AD_Window_ID, int AD_Menu_ID)
{
getLogger().config("Window=" + WindowNo + ", AD_Window_ID=" + AD_Window_ID);
if (log.isLoggable(Level.CONFIG)) log.config("Window=" + WindowNo + ", AD_Window_ID=" + AD_Window_ID);
GridWindowVO mWindowVO = null;
if (AD_Window_ID != 0 && Ini.isCacheWindow()) // try cache
{
@ -1731,14 +1724,14 @@ public final class Env
if (mWindowVO != null)
{
mWindowVO = mWindowVO.clone(WindowNo);
getLogger().info("Cached=" + mWindowVO);
if (log.isLoggable(Level.INFO)) log.info("Cached=" + mWindowVO);
}
}
// Create Window Model on Client
if (mWindowVO == null)
{
getLogger().config("create local");
if (log.isLoggable(Level.CONFIG)) log.config("create local");
mWindowVO = GridWindowVO.create (Env.getCtx(), WindowNo, AD_Window_ID, AD_Menu_ID);
if (mWindowVO != null)
s_windowsvo.put(AD_Window_ID, mWindowVO);

View File

@ -58,9 +58,12 @@ import org.compiere.model.ModelValidationEngine;
public final class Ini implements Serializable
{
/**
*
*
*/
private static final long serialVersionUID = 3666529972922769528L;
private static final long serialVersionUID = -8936090051638559660L;
/** Logger */
private static CLogger log = CLogger.getCLogger(Ini.class);
/** Property file name */
public static final String IDEMPIERE_PROPERTY_FILE = "idempiere.properties";
@ -228,10 +231,6 @@ public final class Ini implements Serializable
private static String s_propertyFileName = null;
private static CLogger getLogger() {
return CLogger.getCLogger(Ini.class.getName());
}
/**
* Save INI parameters to disk
* @param tryUserHome get user home first
@ -262,15 +261,15 @@ public final class Ini implements Serializable
}
catch (Exception e)
{
getLogger().log(Level.SEVERE, "Cannot save Properties to " + fileName + " - " + e.toString());
log.log(Level.SEVERE, "Cannot save Properties to " + fileName + " - " + e.toString());
return;
}
catch (Throwable t)
{
getLogger().log(Level.SEVERE, "Cannot save Properties to " + fileName + " - " + t.toString());
log.log(Level.SEVERE, "Cannot save Properties to " + fileName + " - " + t.toString());
return;
}
getLogger().finer(fileName);
if (log.isLoggable(Level.FINER)) log.finer(fileName);
}
} // save
@ -304,7 +303,7 @@ public final class Ini implements Serializable
ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService");
} catch (UnavailableServiceException e) {
ps = null;
getLogger().log(Level.SEVERE, e.toString());
log.log(Level.SEVERE, e.toString());
return false;
}
@ -312,7 +311,7 @@ public final class Ini implements Serializable
try {
fc = ps.get(getCodeBase());
} catch (MalformedURLException e) {
getLogger().log(Level.SEVERE, e.toString());
log.log(Level.SEVERE, e.toString());
return false;
} catch (FileNotFoundException e) {
try {
@ -323,7 +322,7 @@ public final class Ini implements Serializable
}
} catch (IOException e) {
getLogger().log(Level.SEVERE, e.toString());
log.log(Level.SEVERE, e.toString());
return false;
}
@ -337,7 +336,7 @@ public final class Ini implements Serializable
}
catch (Throwable t)
{
getLogger().log(Level.SEVERE, t.toString());
log.log(Level.SEVERE, t.toString());
loadOK = false;
}
if (!loadOK || s_prop.getProperty(P_TODAY, "").equals(""))
@ -364,7 +363,7 @@ public final class Ini implements Serializable
ps = (PersistenceService)ServiceManager.lookup("javax.jnlp.PersistenceService");
} catch (UnavailableServiceException e) {
ps = null;
getLogger().log(Level.SEVERE, e.toString());
log.log(Level.SEVERE, e.toString());
return;
}
@ -377,7 +376,7 @@ public final class Ini implements Serializable
}
catch (Throwable t)
{
getLogger().log(Level.SEVERE, "Cannot save Properties to " + getCodeBase() + " - " + t.toString());
log.log(Level.SEVERE, "Cannot save Properties to " + getCodeBase() + " - " + t.toString());
return;
}
@ -429,22 +428,22 @@ public final class Ini implements Serializable
}
catch (FileNotFoundException e)
{
getLogger().warning(filename + " not found");
log.warning(filename + " not found");
loadOK = false;
}
catch (Exception e)
{
getLogger().log(Level.SEVERE, filename + " - " + e.toString());
log.log(Level.SEVERE, filename + " - " + e.toString());
loadOK = false;
}
catch (Throwable t)
{
getLogger().log(Level.SEVERE, filename + " - " + t.toString());
log.log(Level.SEVERE, filename + " - " + t.toString());
loadOK = false;
}
if (!loadOK || s_prop.getProperty(P_TODAY, "").equals(""))
{
getLogger().config(filename);
if (log.isLoggable(Level.CONFIG)) log.config(filename);
firstTime = true;
}
@ -454,7 +453,7 @@ public final class Ini implements Serializable
if (!loadOK || firstTime)
saveProperties(true);
s_loaded = true;
getLogger().info(filename + " #" + s_prop.size());
if (log.isLoggable(Level.INFO)) log.info(filename + " #" + s_prop.size());
s_propertyFileName = filename;
return firstTime;
@ -491,11 +490,11 @@ public final class Ini implements Serializable
if (!file.delete())
file.deleteOnExit();
s_prop = new Properties();
getLogger().config (fileName);
if (log.isLoggable(Level.CONFIG)) log.config (fileName);
}
catch (Exception e)
{
getLogger().log (Level.WARNING, "Cannot delete Property file", e);
log.log (Level.WARNING, "Cannot delete Property file", e);
}
}
} // deleteProperties
@ -564,7 +563,7 @@ public final class Ini implements Serializable
*/
public static void setProperty (String key, String value)
{
// getLogger().finer(key + "=" + value);
// log.finer(key + "=" + value);
if (s_prop == null)
s_prop = new Properties();
if (key.equals(P_WARNING) || key.equals(P_WARNING_de))
@ -620,7 +619,7 @@ public final class Ini implements Serializable
return "";
//
String value = SecureEngine.decrypt(retStr, 0);
// getLogger().finer(key + "=" + value);
// log.finer(key + "=" + value);
if (value == null)
return "";
return value;

View File

@ -45,7 +45,9 @@ import org.compiere.util.CLogger;
public class DocumentSearch extends AbstractDocumentSearch {
/** the logger */
static CLogger log = CLogger.getCLogger(DocumentSearch.class);
@SuppressWarnings("unused")
private static CLogger log = CLogger.getCLogger(DocumentSearch.class);
@Override
protected boolean openWindow(int windowId, MQuery query) {
final AWindow frame = new AWindow(null);

View File

@ -75,7 +75,7 @@ public class VGenPanel extends CPanel implements ActionListener, ChangeListener,
private FormFrame m_frame;
/** Logger */
private static CLogger log = CLogger.getCLogger(VInOutGen.class);
private static CLogger log = CLogger.getCLogger(VGenPanel.class);
//
private CTabbedPane tabbedPane = new CTabbedPane();

View File

@ -107,7 +107,7 @@ public class CashSubFunctions extends PosQuery implements ActionListener, InputM
private Properties p_ctx;
/** Logger */
private static CLogger log = CLogger.getCLogger(SubCheckout.class);
private static CLogger log = CLogger.getCLogger(CashSubFunctions.class);
/**
* Set up Panel

View File

@ -40,13 +40,6 @@ public class WImageEditor extends WEditor
{
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
private static final CLogger logger;
static
{
logger = CLogger.getCLogger(WImageEditor.class);
}
/** The Image Model */
private MImage m_mImage = null;
@ -139,7 +132,7 @@ public class WImageEditor extends WEditor
try {
img = new AImage(null, data);
} catch (Exception e) {
logger.log(Level.WARNING, e.getLocalizedMessage(), e);
log.log(Level.WARNING, e.getLocalizedMessage(), e);
}
}
getComponent().setContent(img);

View File

@ -27,7 +27,7 @@ import org.eevolution.model.MPPProductBOM;
public class TreeBOM {
public static CLogger log = CLogger.getCLogger(TreeMaintenance.class);
public static CLogger log = CLogger.getCLogger(TreeBOM.class);
public Properties getCtx() {
return Env.getCtx();