* root logger name is now retrieve from context instead of always "".
* log file name at server is prefix by the root logger name from context. * webui will maintain separate log file prefix by "org.adempiere.webui"
This commit is contained in:
parent
970ae6b62a
commit
b4cfb20024
|
@ -51,7 +51,7 @@ import org.compiere.util.Util;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $
|
* @version $Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class Adempiere
|
public final class Adempiere
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ public final class Adempiere
|
||||||
static private Image s_imageLogo;
|
static private Image s_imageLogo;
|
||||||
static private ImageIcon s_imageIcon32;
|
static private ImageIcon s_imageIcon32;
|
||||||
static private ImageIcon s_imageIconLogo;
|
static private ImageIcon s_imageIconLogo;
|
||||||
|
|
||||||
static private final String ONLINE_HELP_URL = "http://www.adempiere.com/wiki/index.php/Manual";
|
static private final String ONLINE_HELP_URL = "http://www.adempiere.com/wiki/index.php/Manual";
|
||||||
|
|
||||||
/** Logging */
|
/** Logging */
|
||||||
|
@ -118,12 +118,12 @@ public final class Adempiere
|
||||||
if (properties.containsKey("IMPLEMENTATION_VERSION"))
|
if (properties.containsKey("IMPLEMENTATION_VERSION"))
|
||||||
s_ImplementationVersion = properties.getProperty("IMPLEMENTATION_VERSION");
|
s_ImplementationVersion = properties.getProperty("IMPLEMENTATION_VERSION");
|
||||||
if (properties.containsKey("IMPLEMENTATION_VENDOR"))
|
if (properties.containsKey("IMPLEMENTATION_VENDOR"))
|
||||||
s_ImplementationVendor = properties.getProperty("IMPLEMENTATION_VENDOR");
|
s_ImplementationVendor = properties.getProperty("IMPLEMENTATION_VENDOR");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Product Name
|
* Get Product Name
|
||||||
* @return Application Name
|
* @return Application Name
|
||||||
|
@ -244,7 +244,7 @@ public final class Adempiere
|
||||||
*/
|
*/
|
||||||
public static String getJavaInfo()
|
public static String getJavaInfo()
|
||||||
{
|
{
|
||||||
return System.getProperty("java.vm.name")
|
return System.getProperty("java.vm.name")
|
||||||
+ " " + System.getProperty("java.vm.version");
|
+ " " + System.getProperty("java.vm.version");
|
||||||
} // getJavaInfo
|
} // getJavaInfo
|
||||||
|
|
||||||
|
@ -254,8 +254,8 @@ public final class Adempiere
|
||||||
*/
|
*/
|
||||||
public static String getOSInfo()
|
public static String getOSInfo()
|
||||||
{
|
{
|
||||||
return System.getProperty("os.name") + " "
|
return System.getProperty("os.name") + " "
|
||||||
+ System.getProperty("os.version") + " "
|
+ System.getProperty("os.version") + " "
|
||||||
+ System.getProperty("sun.os.patch.level");
|
+ System.getProperty("sun.os.patch.level");
|
||||||
} // getJavaInfo
|
} // getJavaInfo
|
||||||
|
|
||||||
|
@ -267,7 +267,7 @@ public final class Adempiere
|
||||||
{
|
{
|
||||||
return "http://" + URL;
|
return "http://" + URL;
|
||||||
} // getURL
|
} // getURL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return URL
|
* @return URL
|
||||||
*/
|
*/
|
||||||
|
@ -425,16 +425,16 @@ public final class Adempiere
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
|
BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
|
||||||
URL url = bs.getCodeBase();
|
URL url = bs.getCodeBase();
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
catch(UnavailableServiceException ue)
|
catch(UnavailableServiceException ue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} // getCodeBase
|
} // getCodeBase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if client is started using web start
|
* @return True if client is started using web start
|
||||||
*/
|
*/
|
||||||
|
@ -488,18 +488,17 @@ public final class Adempiere
|
||||||
|
|
||||||
// System properties
|
// System properties
|
||||||
Ini.loadProperties (false);
|
Ini.loadProperties (false);
|
||||||
|
|
||||||
// Set up Log
|
// Set up Log
|
||||||
CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL));
|
CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL));
|
||||||
if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE)
|
if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE))
|
||||||
&& CLogFile.get(false, null, isClient) == null)
|
CLogMgt.addHandler(new CLogFile(Ini.findAdempiereHome(), true, isClient));
|
||||||
CLogMgt.addHandler(CLogFile.get (true, Ini.findAdempiereHome(), isClient));
|
|
||||||
|
|
||||||
// Set UI
|
// Set UI
|
||||||
if (isClient)
|
if (isClient)
|
||||||
{
|
{
|
||||||
if (CLogMgt.isLevelAll())
|
if (CLogMgt.isLevelAll())
|
||||||
log.log(Level.FINEST, System.getProperties().toString());
|
log.log(Level.FINEST, System.getProperties().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Default Database Connection from Ini
|
// Set Default Database Connection from Ini
|
||||||
|
@ -507,7 +506,7 @@ public final class Adempiere
|
||||||
|
|
||||||
if (isClient) // don't test connection
|
if (isClient) // don't test connection
|
||||||
return false; // need to call
|
return false; // need to call
|
||||||
|
|
||||||
return startupEnvironment(isClient);
|
return startupEnvironment(isClient);
|
||||||
} // startup
|
} // startup
|
||||||
|
|
||||||
|
@ -529,7 +528,7 @@ public final class Adempiere
|
||||||
MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too
|
MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too
|
||||||
if (system == null)
|
if (system == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Initialize main cached Singletons
|
// Initialize main cached Singletons
|
||||||
ModelValidationEngine.get();
|
ModelValidationEngine.get();
|
||||||
try
|
try
|
||||||
|
@ -547,9 +546,9 @@ public final class Adempiere
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SecureEngine.init(className);
|
SecureEngine.init(className);
|
||||||
|
|
||||||
//
|
//
|
||||||
if (isClient)
|
if (isClient)
|
||||||
MClient.get(Env.getCtx(),0); // Login Client loaded later
|
MClient.get(Env.getCtx(),0); // Login Client loaded later
|
||||||
else
|
else
|
||||||
MClient.getAll(Env.getCtx());
|
MClient.getAll(Env.getCtx());
|
||||||
|
@ -558,7 +557,7 @@ public final class Adempiere
|
||||||
{
|
{
|
||||||
log.warning("Environment problems: " + e.toString());
|
log.warning("Environment problems: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start Workflow Document Manager (in other package) for PO
|
// Start Workflow Document Manager (in other package) for PO
|
||||||
String className = null;
|
String className = null;
|
||||||
try
|
try
|
||||||
|
@ -573,7 +572,7 @@ public final class Adempiere
|
||||||
{
|
{
|
||||||
log.warning("Not started: " + className + " - " + e.getMessage());
|
log.warning("Not started: " + className + " - " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isClient)
|
if (!isClient)
|
||||||
DB.updateMail();
|
DB.updateMail();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -32,31 +32,11 @@ import java.util.logging.LogRecord;
|
||||||
*/
|
*/
|
||||||
public class CLogConsole extends Handler
|
public class CLogConsole extends Handler
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Get Console Handler
|
|
||||||
* @param create create if not exists
|
|
||||||
* @return console hander or null
|
|
||||||
*/
|
|
||||||
public static CLogConsole get (boolean create)
|
|
||||||
{
|
|
||||||
if (s_console == null && create)
|
|
||||||
s_console = new CLogConsole();
|
|
||||||
return s_console;
|
|
||||||
} // get
|
|
||||||
|
|
||||||
private static CLogConsole s_console = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public CLogConsole ()
|
public CLogConsole ()
|
||||||
{
|
{
|
||||||
if (s_console == null)
|
|
||||||
s_console = this;
|
|
||||||
else
|
|
||||||
reportError("Console Handler exists already",
|
|
||||||
new IllegalStateException("Existing Handler"),
|
|
||||||
ErrorManager.GENERIC_FAILURE);
|
|
||||||
initialize();
|
initialize();
|
||||||
} // CLogConsole
|
} // CLogConsole
|
||||||
|
|
||||||
|
@ -77,12 +57,12 @@ public class CLogConsole extends Handler
|
||||||
String encoding = getEncoding();
|
String encoding = getEncoding();
|
||||||
if (encoding != null)
|
if (encoding != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_writerOut = new PrintWriter(new OutputStreamWriter(System.out, encoding));
|
m_writerOut = new PrintWriter(new OutputStreamWriter(System.out, encoding));
|
||||||
m_writerErr = new PrintWriter(new OutputStreamWriter(System.err, encoding));
|
m_writerErr = new PrintWriter(new OutputStreamWriter(System.err, encoding));
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException ex)
|
catch (UnsupportedEncodingException ex)
|
||||||
{
|
{
|
||||||
reportError ("Opening encoded Writers", ex, ErrorManager.OPEN_FAILURE);
|
reportError ("Opening encoded Writers", ex, ErrorManager.OPEN_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +71,7 @@ public class CLogConsole extends Handler
|
||||||
m_writerOut = new PrintWriter(System.out);
|
m_writerOut = new PrintWriter(System.out);
|
||||||
if (m_writerErr == null)
|
if (m_writerErr == null)
|
||||||
m_writerErr = new PrintWriter(System.err);
|
m_writerErr = new PrintWriter(System.err);
|
||||||
|
|
||||||
// Formatting
|
// Formatting
|
||||||
setFormatter(CLogFormatter.get());
|
setFormatter(CLogFormatter.get());
|
||||||
// Default Level
|
// Default Level
|
||||||
|
@ -100,7 +80,7 @@ public class CLogConsole extends Handler
|
||||||
setFilter(CLogFilter.get());
|
setFilter(CLogFilter.get());
|
||||||
//
|
//
|
||||||
} // initialize
|
} // initialize
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Encoding
|
* Set Encoding
|
||||||
* @param encoding encoding
|
* @param encoding encoding
|
||||||
|
@ -116,7 +96,7 @@ public class CLogConsole extends Handler
|
||||||
initialize();
|
initialize();
|
||||||
} // setEncoding
|
} // setEncoding
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Level
|
* Set Level
|
||||||
* @see java.util.logging.Handler#setLevel(java.util.logging.Level)
|
* @see java.util.logging.Handler#setLevel(java.util.logging.Level)
|
||||||
|
@ -135,7 +115,7 @@ public class CLogConsole extends Handler
|
||||||
else
|
else
|
||||||
DriverManager.setLogWriter(null);
|
DriverManager.setLogWriter(null);
|
||||||
} // setLevel
|
} // setLevel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish
|
* Publish
|
||||||
* @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
|
* @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
|
||||||
|
@ -145,7 +125,7 @@ public class CLogConsole extends Handler
|
||||||
{
|
{
|
||||||
if (!isLoggable (record) || m_writerOut == null)
|
if (!isLoggable (record) || m_writerOut == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Format
|
// Format
|
||||||
String msg = null;
|
String msg = null;
|
||||||
try
|
try
|
||||||
|
@ -165,7 +145,7 @@ public class CLogConsole extends Handler
|
||||||
m_writerOut.write (getFormatter().getHead (this));
|
m_writerOut.write (getFormatter().getHead (this));
|
||||||
m_doneHeader = true;
|
m_doneHeader = true;
|
||||||
}
|
}
|
||||||
if (record.getLevel() == Level.SEVERE
|
if (record.getLevel() == Level.SEVERE
|
||||||
|| record.getLevel() == Level.WARNING)
|
|| record.getLevel() == Level.WARNING)
|
||||||
{
|
{
|
||||||
flush();
|
flush();
|
||||||
|
@ -212,7 +192,7 @@ public class CLogConsole extends Handler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close
|
* Close
|
||||||
*
|
*
|
||||||
* @see java.util.logging.Handler#close()
|
* @see java.util.logging.Handler#close()
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
*/
|
*/
|
||||||
|
@ -255,7 +235,7 @@ public class CLogConsole extends Handler
|
||||||
}
|
}
|
||||||
m_writerErr = null;
|
m_writerErr = null;
|
||||||
} // close
|
} // close
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.logging.ErrorManager;
|
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
|
@ -30,10 +29,10 @@ import org.compiere.model.MIssue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client Error Buffer
|
* Client Error Buffer
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: CLogErrorBuffer.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
|
* @version $Id: CLogErrorBuffer.java,v 1.3 2006/07/30 00:54:36 jjanke Exp $
|
||||||
*
|
*
|
||||||
* @author Teo Sarca, teo.sarca@gmail.com
|
* @author Teo Sarca, teo.sarca@gmail.com
|
||||||
* <li>BF [ 2973298 ] NPE on CLogErrorBuffer
|
* <li>BF [ 2973298 ] NPE on CLogErrorBuffer
|
||||||
*/
|
*/
|
||||||
|
@ -45,33 +44,11 @@ public class CLogErrorBuffer extends Handler
|
||||||
private static final String LOGS_KEY = "org.compiere.util.CLogErrorBuffer.logs";
|
private static final String LOGS_KEY = "org.compiere.util.CLogErrorBuffer.logs";
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Client Log Handler
|
|
||||||
* @param create create if not exists
|
|
||||||
* @return handler
|
|
||||||
*/
|
|
||||||
public static CLogErrorBuffer get(boolean create)
|
|
||||||
{
|
|
||||||
if (s_handler == null && create)
|
|
||||||
s_handler = new CLogErrorBuffer();
|
|
||||||
return s_handler;
|
|
||||||
} // get
|
|
||||||
|
|
||||||
/** Appender */
|
|
||||||
private static CLogErrorBuffer s_handler;
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public CLogErrorBuffer ()
|
public CLogErrorBuffer ()
|
||||||
{
|
{
|
||||||
if (s_handler == null)
|
|
||||||
s_handler = this;
|
|
||||||
else
|
|
||||||
reportError("Error Handler exists already",
|
|
||||||
new IllegalStateException("Existing Handler"),
|
|
||||||
ErrorManager.GENERIC_FAILURE);
|
|
||||||
initialize();
|
initialize();
|
||||||
} // CLogErrorBuffer
|
} // CLogErrorBuffer
|
||||||
|
|
||||||
|
@ -80,7 +57,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
|
|
||||||
/** Log Size */
|
/** Log Size */
|
||||||
private static final int LOG_SIZE = 100;
|
private static final int LOG_SIZE = 100;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize
|
* Initialize
|
||||||
*/
|
*/
|
||||||
|
@ -103,14 +80,14 @@ public class CLogErrorBuffer extends Handler
|
||||||
public boolean isIssueError()
|
public boolean isIssueError()
|
||||||
{
|
{
|
||||||
Boolean b = (Boolean) Env.getCtx().get(ISSUE_ERROR_KEY);
|
Boolean b = (Boolean) Env.getCtx().get(ISSUE_ERROR_KEY);
|
||||||
if (b == null)
|
if (b == null)
|
||||||
{
|
{
|
||||||
b = Boolean.TRUE;
|
b = Boolean.TRUE;
|
||||||
setIssueError(b);
|
setIssueError(b);
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
} // isIssueError
|
} // isIssueError
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Issue Error
|
* Set Issue Error
|
||||||
* @param issueError issue error
|
* @param issueError issue error
|
||||||
|
@ -119,7 +96,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
{
|
{
|
||||||
Env.getCtx().put(ISSUE_ERROR_KEY, issueError);
|
Env.getCtx().put(ISSUE_ERROR_KEY, issueError);
|
||||||
} // setIssueError
|
} // setIssueError
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Level.
|
* Set Level.
|
||||||
* Ignore OFF - and higher then FINE
|
* Ignore OFF - and higher then FINE
|
||||||
|
@ -139,7 +116,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
else
|
else
|
||||||
super.setLevel(newLevel);
|
super.setLevel(newLevel);
|
||||||
} // SetLevel
|
} // SetLevel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Publish
|
* Publish
|
||||||
* @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
|
* @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
|
||||||
|
@ -148,11 +125,11 @@ public class CLogErrorBuffer extends Handler
|
||||||
public void publish (LogRecord record)
|
public void publish (LogRecord record)
|
||||||
{
|
{
|
||||||
checkContext();
|
checkContext();
|
||||||
|
|
||||||
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
||||||
if (!isLoggable (record) || m_logs == null)
|
if (!isLoggable (record) || m_logs == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
synchronized (m_logs)
|
synchronized (m_logs)
|
||||||
{
|
{
|
||||||
|
@ -160,7 +137,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
m_logs.removeFirst();
|
m_logs.removeFirst();
|
||||||
m_logs.add(record);
|
m_logs.add(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have an error
|
// We have an error
|
||||||
if (record.getLevel() == Level.SEVERE)
|
if (record.getLevel() == Level.SEVERE)
|
||||||
{
|
{
|
||||||
|
@ -174,7 +151,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
// Add Error
|
// Add Error
|
||||||
m_errors.add(record);
|
m_errors.add(record);
|
||||||
record.getSourceClassName(); // forces Class Name eval
|
record.getSourceClassName(); // forces Class Name eval
|
||||||
|
|
||||||
// Create History
|
// Create History
|
||||||
ArrayList<LogRecord> history = new ArrayList<LogRecord>();
|
ArrayList<LogRecord> history = new ArrayList<LogRecord>();
|
||||||
for (int i = m_logs.size()-1; i >= 0; i--)
|
for (int i = m_logs.size()-1; i >= 0; i--)
|
||||||
|
@ -193,11 +170,11 @@ public class CLogErrorBuffer extends Handler
|
||||||
if (history.size() > 10)
|
if (history.size() > 10)
|
||||||
break; // no more then 10 history records
|
break; // no more then 10 history records
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
LogRecord[] historyArray = new LogRecord[history.size()];
|
LogRecord[] historyArray = new LogRecord[history.size()];
|
||||||
int no = 0;
|
int no = 0;
|
||||||
for (int i = history.size()-1; i >= 0; i--)
|
for (int i = history.size()-1; i >= 0; i--)
|
||||||
historyArray[no++] = (LogRecord)history.get(i);
|
historyArray[no++] = (LogRecord)history.get(i);
|
||||||
m_history.add(historyArray);
|
m_history.add(historyArray);
|
||||||
// Issue Reporting
|
// Issue Reporting
|
||||||
|
@ -207,8 +184,8 @@ public class CLogErrorBuffer extends Handler
|
||||||
if (loggerName == null)
|
if (loggerName == null)
|
||||||
loggerName = "";
|
loggerName = "";
|
||||||
String className = record.getSourceClassName(); // physical class
|
String className = record.getSourceClassName(); // physical class
|
||||||
String methodName = record.getSourceMethodName(); //
|
String methodName = record.getSourceMethodName(); //
|
||||||
if (DB.isConnected(false)
|
if (DB.isConnected(false)
|
||||||
&& !methodName.equals("saveError")
|
&& !methodName.equals("saveError")
|
||||||
&& !methodName.equals("get_Value")
|
&& !methodName.equals("get_Value")
|
||||||
&& !methodName.equals("dataSave")
|
&& !methodName.equals("dataSave")
|
||||||
|
@ -217,7 +194,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
setIssueError(false);
|
setIssueError(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MIssue.create(record);
|
MIssue.create(record);
|
||||||
setIssueError(true);
|
setIssueError(true);
|
||||||
|
@ -264,12 +241,12 @@ public class CLogErrorBuffer extends Handler
|
||||||
Env.getCtx().remove(HISTORY_KEY);
|
Env.getCtx().remove(HISTORY_KEY);
|
||||||
} // close
|
} // close
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Get ColumnNames of Log Entries
|
* Get ColumnNames of Log Entries
|
||||||
* @param ctx context (not used)
|
* @param ctx context (not used)
|
||||||
* @return string vector
|
* @return string vector
|
||||||
*/
|
*/
|
||||||
public Vector<String> getColumnNames(Properties ctx)
|
public Vector<String> getColumnNames(Properties ctx)
|
||||||
{
|
{
|
||||||
Vector<String> cn = new Vector<String>();
|
Vector<String> cn = new Vector<String>();
|
||||||
|
@ -295,7 +272,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
LogRecord[] records = getRecords(errorsOnly);
|
LogRecord[] records = getRecords(errorsOnly);
|
||||||
// System.out.println("getLogData - " + events.length);
|
// System.out.println("getLogData - " + events.length);
|
||||||
Vector<Vector<Object>> rows = new Vector<Vector<Object>>(records.length);
|
Vector<Vector<Object>> rows = new Vector<Vector<Object>>(records.length);
|
||||||
|
|
||||||
for (int i = 0; i < records.length; i++)
|
for (int i = 0; i < records.length; i++)
|
||||||
{
|
{
|
||||||
LogRecord record = records[i];
|
LogRecord record = records[i];
|
||||||
|
@ -314,16 +291,16 @@ public class CLogErrorBuffer extends Handler
|
||||||
}
|
}
|
||||||
return rows;
|
return rows;
|
||||||
} // getData
|
} // getData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Array of events with most recent first
|
* Get Array of events with most recent first
|
||||||
* @param errorsOnly if true errors otherwise log
|
* @param errorsOnly if true errors otherwise log
|
||||||
* @return array of events
|
* @return array of events
|
||||||
*/
|
*/
|
||||||
public LogRecord[] getRecords (boolean errorsOnly)
|
public LogRecord[] getRecords (boolean errorsOnly)
|
||||||
{
|
{
|
||||||
checkContext();
|
checkContext();
|
||||||
|
|
||||||
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
||||||
LinkedList<LogRecord> m_errors = (LinkedList<LogRecord>) Env.getCtx().get(ERRORS_KEY);
|
LinkedList<LogRecord> m_errors = (LinkedList<LogRecord>) Env.getCtx().get(ERRORS_KEY);
|
||||||
LogRecord[] retValue = null;
|
LogRecord[] retValue = null;
|
||||||
|
@ -345,7 +322,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getEvents
|
} // getEvents
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset Error Buffer
|
* Reset Error Buffer
|
||||||
* @param errorsOnly if true errors otherwise log
|
* @param errorsOnly if true errors otherwise log
|
||||||
|
@ -353,7 +330,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
public void resetBuffer (boolean errorsOnly)
|
public void resetBuffer (boolean errorsOnly)
|
||||||
{
|
{
|
||||||
checkContext();
|
checkContext();
|
||||||
|
|
||||||
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
||||||
LinkedList<LogRecord> m_errors = (LinkedList<LogRecord>) Env.getCtx().get(ERRORS_KEY);
|
LinkedList<LogRecord> m_errors = (LinkedList<LogRecord>) Env.getCtx().get(ERRORS_KEY);
|
||||||
LinkedList<LogRecord[]> m_history = (LinkedList<LogRecord[]>) Env.getCtx().get(HISTORY_KEY);
|
LinkedList<LogRecord[]> m_history = (LinkedList<LogRecord[]>) Env.getCtx().get(HISTORY_KEY);
|
||||||
|
@ -370,7 +347,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // resetBuffer
|
} // resetBuffer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get/Put Error Info in String
|
* Get/Put Error Info in String
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -380,7 +357,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
public String getErrorInfo (Properties ctx, boolean errorsOnly)
|
public String getErrorInfo (Properties ctx, boolean errorsOnly)
|
||||||
{
|
{
|
||||||
checkContext();
|
checkContext();
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
//
|
//
|
||||||
if (errorsOnly)
|
if (errorsOnly)
|
||||||
|
@ -390,7 +367,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
{
|
{
|
||||||
sb.append("-------------------------------\n");
|
sb.append("-------------------------------\n");
|
||||||
LogRecord[] records = (LogRecord[])m_history.get(i);
|
LogRecord[] records = (LogRecord[])m_history.get(i);
|
||||||
for (int j = 0; j < records.length; j++)
|
for (int j = 0; j < records.length; j++)
|
||||||
{
|
{
|
||||||
LogRecord record = records[j];
|
LogRecord record = records[j];
|
||||||
sb.append(getFormatter().format(record));
|
sb.append(getFormatter().format(record));
|
||||||
|
@ -420,20 +397,20 @@ public class CLogErrorBuffer extends Handler
|
||||||
LinkedList<LogRecord> m_logs = new LinkedList<LogRecord>();
|
LinkedList<LogRecord> m_logs = new LinkedList<LogRecord>();
|
||||||
Env.getCtx().put(LOGS_KEY, m_logs);
|
Env.getCtx().put(LOGS_KEY, m_logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Env.getCtx().containsKey(ERRORS_KEY))
|
if (!Env.getCtx().containsKey(ERRORS_KEY))
|
||||||
{
|
{
|
||||||
LinkedList<LogRecord> m_errors = new LinkedList<LogRecord>();
|
LinkedList<LogRecord> m_errors = new LinkedList<LogRecord>();
|
||||||
Env.getCtx().put(ERRORS_KEY, m_errors);
|
Env.getCtx().put(ERRORS_KEY, m_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Env.getCtx().containsKey(HISTORY_KEY))
|
if (!Env.getCtx().containsKey(HISTORY_KEY))
|
||||||
{
|
{
|
||||||
LinkedList<LogRecord[]> m_history = new LinkedList<LogRecord[]>();
|
LinkedList<LogRecord[]> m_history = new LinkedList<LogRecord[]>();
|
||||||
Env.getCtx().put(HISTORY_KEY, m_history);
|
Env.getCtx().put(HISTORY_KEY, m_history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
|
@ -441,7 +418,7 @@ public class CLogErrorBuffer extends Handler
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
checkContext();
|
checkContext();
|
||||||
|
|
||||||
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
LinkedList<LogRecord> m_logs = (LinkedList<LogRecord>) Env.getCtx().get(LOGS_KEY);
|
||||||
LinkedList<LogRecord> m_errors = (LinkedList<LogRecord>) Env.getCtx().get(ERRORS_KEY);
|
LinkedList<LogRecord> m_errors = (LinkedList<LogRecord>) Env.getCtx().get(ERRORS_KEY);
|
||||||
LinkedList<LogRecord[]> m_history = (LinkedList<LogRecord[]>) Env.getCtx().get(HISTORY_KEY);
|
LinkedList<LogRecord[]> m_history = (LinkedList<LogRecord[]>) Env.getCtx().get(HISTORY_KEY);
|
||||||
|
@ -453,5 +430,22 @@ public class CLogErrorBuffer extends Handler
|
||||||
.append ("]");
|
.append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
|
public static CLogErrorBuffer get(boolean create) {
|
||||||
|
Handler[] handlers = CLogMgt.getHandlers();
|
||||||
|
for (Handler handler : handlers)
|
||||||
|
{
|
||||||
|
if (handler instanceof CLogErrorBuffer)
|
||||||
|
return (CLogErrorBuffer) handler;
|
||||||
|
}
|
||||||
|
if (create)
|
||||||
|
{
|
||||||
|
CLogErrorBuffer handler = new CLogErrorBuffer();
|
||||||
|
CLogMgt.addHandler(handler);
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
} // CLogErrorBuffer
|
} // CLogErrorBuffer
|
||||||
|
|
|
@ -27,28 +27,12 @@ import java.util.logging.LogRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adempiere Log File Handler
|
* Adempiere Log File Handler
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: CLogFile.java,v 1.3 2006/07/30 00:54:35 jjanke Exp $
|
* @version $Id: CLogFile.java,v 1.3 2006/07/30 00:54:35 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class CLogFile extends Handler
|
public class CLogFile extends Handler
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Get File Logger
|
|
||||||
* @param create create if not exists
|
|
||||||
* @param adempiereHome adempiere home
|
|
||||||
* @param isClient client
|
|
||||||
* @return file logger
|
|
||||||
*/
|
|
||||||
public static CLogFile get (boolean create, String adempiereHome, boolean isClient)
|
|
||||||
{
|
|
||||||
if (s_logFile == null && create)
|
|
||||||
s_logFile = new CLogFile(adempiereHome, true, isClient);
|
|
||||||
return s_logFile;
|
|
||||||
} // get
|
|
||||||
|
|
||||||
private static CLogFile s_logFile = null;
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param adempiereHome adempiere home
|
* @param adempiereHome adempiere home
|
||||||
|
@ -57,12 +41,6 @@ public class CLogFile extends Handler
|
||||||
*/
|
*/
|
||||||
public CLogFile (String adempiereHome, boolean createLogDir, boolean isClient)
|
public CLogFile (String adempiereHome, boolean createLogDir, boolean isClient)
|
||||||
{
|
{
|
||||||
if (s_logFile == null)
|
|
||||||
s_logFile = this;
|
|
||||||
else
|
|
||||||
reportError("File Handler exists already",
|
|
||||||
new IllegalStateException("Existing Handler"),
|
|
||||||
ErrorManager.GENERIC_FAILURE);
|
|
||||||
//
|
//
|
||||||
if (adempiereHome != null && adempiereHome.length() > 0)
|
if (adempiereHome != null && adempiereHome.length() > 0)
|
||||||
m_adempiereHome = adempiereHome;
|
m_adempiereHome = adempiereHome;
|
||||||
|
@ -83,7 +61,7 @@ public class CLogFile extends Handler
|
||||||
private String m_fileNameDate = "";
|
private String m_fileNameDate = "";
|
||||||
/** Record Counter */
|
/** Record Counter */
|
||||||
private int m_records = 0;
|
private int m_records = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize
|
* Initialize
|
||||||
* @param adempiereHome log file base directory name
|
* @param adempiereHome log file base directory name
|
||||||
|
@ -112,7 +90,7 @@ public class CLogFile extends Handler
|
||||||
m_writer = null;
|
m_writer = null;
|
||||||
}
|
}
|
||||||
// System.out.println(getFileName());
|
// System.out.println(getFileName());
|
||||||
|
|
||||||
// Formatting
|
// Formatting
|
||||||
setFormatter(CLogFormatter.get());
|
setFormatter(CLogFormatter.get());
|
||||||
// Level
|
// Level
|
||||||
|
@ -162,6 +140,8 @@ public class CLogFile extends Handler
|
||||||
fileName += File.separator;
|
fileName += File.separator;
|
||||||
if (isClient)
|
if (isClient)
|
||||||
fileName += "client";
|
fileName += "client";
|
||||||
|
else
|
||||||
|
fileName += (CLogMgt.getRootLoggerName() +".");
|
||||||
m_fileNameDate = getFileNameDate(System.currentTimeMillis());
|
m_fileNameDate = getFileNameDate(System.currentTimeMillis());
|
||||||
fileName += m_fileNameDate + "_";
|
fileName += m_fileNameDate + "_";
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
|
@ -188,7 +168,7 @@ public class CLogFile extends Handler
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} // createFile
|
} // createFile
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get File Name Date portion
|
* Get File Name Date portion
|
||||||
* @param time time in ms
|
* @param time time in ms
|
||||||
|
@ -200,7 +180,7 @@ public class CLogFile extends Handler
|
||||||
String s = ts.toString();
|
String s = ts.toString();
|
||||||
return s.substring(0, 10);
|
return s.substring(0, 10);
|
||||||
} // getFileNameDate
|
} // getFileNameDate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate Log when day changes
|
* Rotate Log when day changes
|
||||||
* @param time time
|
* @param time time
|
||||||
|
@ -212,7 +192,7 @@ public class CLogFile extends Handler
|
||||||
return;
|
return;
|
||||||
rotateLog();
|
rotateLog();
|
||||||
} // rotateLog
|
} // rotateLog
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rotate Log
|
* Rotate Log
|
||||||
* Called after Initialization
|
* Called after Initialization
|
||||||
|
@ -221,7 +201,7 @@ public class CLogFile extends Handler
|
||||||
{
|
{
|
||||||
initialize(m_adempiereHome, true, Ini.isClient());
|
initialize(m_adempiereHome, true, Ini.isClient());
|
||||||
} // rotateLog
|
} // rotateLog
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get File Name
|
* Get File Name
|
||||||
* @return file name
|
* @return file name
|
||||||
|
@ -243,8 +223,8 @@ public class CLogFile extends Handler
|
||||||
return m_file.getParentFile();
|
return m_file.getParentFile();
|
||||||
return null;
|
return null;
|
||||||
} // getLogDirectory
|
} // getLogDirectory
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Level
|
* Set Level
|
||||||
* @see java.util.logging.Handler#setLevel(java.util.logging.Level)
|
* @see java.util.logging.Handler#setLevel(java.util.logging.Level)
|
||||||
|
@ -268,9 +248,9 @@ public class CLogFile extends Handler
|
||||||
{
|
{
|
||||||
if (!isLoggable (record) || m_writer == null)
|
if (!isLoggable (record) || m_writer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rotateLog(record.getMillis());
|
rotateLog(record.getMillis());
|
||||||
|
|
||||||
// Format
|
// Format
|
||||||
String msg = null;
|
String msg = null;
|
||||||
try
|
try
|
||||||
|
@ -331,7 +311,7 @@ public class CLogFile extends Handler
|
||||||
{
|
{
|
||||||
if (m_writer == null)
|
if (m_writer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Write Tail
|
// Write Tail
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -358,7 +338,7 @@ public class CLogFile extends Handler
|
||||||
m_writer = null;
|
m_writer = null;
|
||||||
m_file = null;
|
m_file = null;
|
||||||
} // close
|
} // close
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
|
@ -370,5 +350,21 @@ public class CLogFile extends Handler
|
||||||
.append ("]");
|
.append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
|
public static CLogFile get(boolean create, String adempiereHome, boolean isClient) {
|
||||||
|
Handler[] handlers = CLogMgt.getHandlers();
|
||||||
|
for (Handler handler : handlers)
|
||||||
|
{
|
||||||
|
if (handler instanceof CLogFile)
|
||||||
|
return (CLogFile) handler;
|
||||||
|
}
|
||||||
|
if (create)
|
||||||
|
{
|
||||||
|
CLogFile handler = new CLogFile(adempiereHome, true, isClient);
|
||||||
|
CLogMgt.addHandler(handler);
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
} // CLogFile
|
} // CLogFile
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.jar.Attributes;
|
import java.util.jar.Attributes;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
|
@ -41,25 +42,25 @@ import org.compiere.model.MClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adempiere Log Management.
|
* Adempiere Log Management.
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: CLogMgt.java,v 1.4 2006/07/30 00:54:36 jjanke Exp $
|
* @version $Id: CLogMgt.java,v 1.4 2006/07/30 00:54:36 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class CLogMgt
|
public class CLogMgt
|
||||||
{
|
{
|
||||||
|
public static final String DEFAULT_ROOT_LOGGER_NAME = "adempiere";
|
||||||
|
public static final String ROOT_LOGGER_NAME_PROPERTY = "org.adempiere.log.root";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize Logging
|
* Initialize Logging
|
||||||
* @param isClient client
|
* @param isClient client
|
||||||
*/
|
*/
|
||||||
public static void initialize(boolean isClient)
|
public static void initialize(boolean isClient)
|
||||||
{
|
{
|
||||||
if (s_handlers != null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (isClient)
|
if (isClient)
|
||||||
{
|
{
|
||||||
LogManager mgr = LogManager.getLogManager();
|
LogManager mgr = LogManager.getLogManager();
|
||||||
try
|
try
|
||||||
{ // Load Logging config from org.compiere.util.*properties
|
{ // Load Logging config from org.compiere.util.*properties
|
||||||
String fileName = "logClient.properties";
|
String fileName = "logClient.properties";
|
||||||
InputStream in = CLogMgt.class.getResourceAsStream(fileName);
|
InputStream in = CLogMgt.class.getResourceAsStream(fileName);
|
||||||
|
@ -72,19 +73,18 @@ public class CLogMgt
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Handler List
|
// Handler List
|
||||||
s_handlers = new ArrayList<Handler>();
|
List<String>handlerNames = new ArrayList<String>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logger rootLogger = Logger.getLogger("");
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
|
rootLogger.setUseParentHandlers(false);
|
||||||
// System.out.println(rootLogger.getName() + " (" + rootLogger + ")");
|
// System.out.println(rootLogger.getName() + " (" + rootLogger + ")");
|
||||||
Handler[] handlers = rootLogger.getHandlers();
|
Handler[] handlers = rootLogger.getHandlers();
|
||||||
for (int i = 0; i < handlers.length; i ++)
|
for (int i = 0; i < handlers.length; i ++)
|
||||||
{
|
{
|
||||||
// System.out.println(" > " + handlers[i]);
|
handlerNames.add(handlers[i].getClass().getName());
|
||||||
if (!s_handlers.contains(handlers[i]))
|
|
||||||
s_handlers.add(handlers[i]);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
Enumeration en = mgr.getLoggerNames();
|
Enumeration en = mgr.getLoggerNames();
|
||||||
|
@ -144,22 +144,17 @@ public class CLogMgt
|
||||||
else
|
else
|
||||||
System.err.println(e.toString());
|
System.err.println(e.toString());
|
||||||
}
|
}
|
||||||
// System.out.println("Handlers=" + s_handlers.size());
|
|
||||||
|
|
||||||
// Check Loggers
|
// Check Loggers
|
||||||
if (CLogErrorBuffer.get(false) == null)
|
if (!handlerNames.contains(CLogErrorBuffer.class.getName()))
|
||||||
addHandler(CLogErrorBuffer.get(true));
|
addHandler(new CLogErrorBuffer());
|
||||||
if (CLogConsole.get(false) == null)
|
if (!handlerNames.contains(CLogConsole.class.getName()))
|
||||||
addHandler(CLogConsole.get(true));
|
addHandler(new CLogConsole());
|
||||||
CLogFile fh = CLogFile.get (false, null, isClient);
|
if (!handlerNames.contains(CLogFile.class.getName()))
|
||||||
if (fh == null && !isClient)
|
|
||||||
{
|
{
|
||||||
fh = CLogFile.get (true, null, isClient);
|
Handler fh = new CLogFile(null, true, isClient);
|
||||||
addHandler(fh);
|
addHandler(fh);
|
||||||
}
|
}
|
||||||
if (fh != null && !isClient)
|
|
||||||
System.out.println(fh);
|
|
||||||
|
|
||||||
setFormatter(CLogFormatter.get());
|
setFormatter(CLogFormatter.get());
|
||||||
setFilter(CLogFilter.get());
|
setFilter(CLogFilter.get());
|
||||||
// setLevel(s_currentLevel);
|
// setLevel(s_currentLevel);
|
||||||
|
@ -169,19 +164,22 @@ public class CLogMgt
|
||||||
// System.out.println("Handlers=" + s_handlers.size() + ", Level=" + s_currentLevel);
|
// System.out.println("Handlers=" + s_handlers.size() + ", Level=" + s_currentLevel);
|
||||||
} // initialize
|
} // initialize
|
||||||
|
|
||||||
|
|
||||||
/** Handlers */
|
public static String getRootLoggerName() {
|
||||||
private static ArrayList<Handler> s_handlers = null;
|
String root = Env.getCtx().getProperty(ROOT_LOGGER_NAME_PROPERTY);
|
||||||
/** Current Log Level */
|
if (root == null || root.trim().length() == 0)
|
||||||
private static Level s_currentLevel = Level.INFO;
|
root = DEFAULT_ROOT_LOGGER_NAME;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static Logger log = Logger.getAnonymousLogger();
|
private static Logger log = Logger.getAnonymousLogger();
|
||||||
/** LOG Levels */
|
/** LOG Levels */
|
||||||
public static final Level[] LEVELS = new Level[]
|
public static final Level[] LEVELS = new Level[]
|
||||||
{Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO,
|
{Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO,
|
||||||
Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL};
|
Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL};
|
||||||
|
|
||||||
/** New Line */
|
/** New Line */
|
||||||
private static final String NL = System.getProperty("line.separator");
|
private static final String NL = System.getProperty("line.separator");
|
||||||
|
|
||||||
|
@ -191,12 +189,12 @@ public class CLogMgt
|
||||||
*/
|
*/
|
||||||
protected static Handler[] getHandlers()
|
protected static Handler[] getHandlers()
|
||||||
{
|
{
|
||||||
Handler[] handlers = new Handler[s_handlers.size()];
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
for (int i = 0; i < s_handlers.size(); i++)
|
rootLogger.setUseParentHandlers(false);
|
||||||
handlers[i] = (Handler)s_handlers.get(i);
|
Handler[] handlers = rootLogger.getHandlers();
|
||||||
return handlers;
|
return handlers;
|
||||||
} // getHandlers
|
} // getHandlers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add Handler (to root logger)
|
* Add Handler (to root logger)
|
||||||
* @param handler new Handler
|
* @param handler new Handler
|
||||||
|
@ -205,24 +203,25 @@ public class CLogMgt
|
||||||
{
|
{
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
return;
|
return;
|
||||||
Logger rootLogger = Logger.getLogger("");
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
rootLogger.addHandler(handler);
|
rootLogger.addHandler(handler);
|
||||||
//
|
//
|
||||||
s_handlers.add(handler);
|
|
||||||
log.log(Level.CONFIG, "Handler=" + handler);
|
log.log(Level.CONFIG, "Handler=" + handler);
|
||||||
} // addHandler
|
} // addHandler
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Formatter for all handlers
|
* Set Formatter for all handlers
|
||||||
* @param formatter formatter
|
* @param formatter formatter
|
||||||
*/
|
*/
|
||||||
protected static void setFormatter (java.util.logging.Formatter formatter)
|
protected static void setFormatter (java.util.logging.Formatter formatter)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < s_handlers.size(); i++)
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
|
rootLogger.setUseParentHandlers(false);
|
||||||
|
Handler[] handlers = rootLogger.getHandlers();
|
||||||
|
for (int i = 0; i < handlers.length; i++)
|
||||||
{
|
{
|
||||||
Handler handler = (Handler)s_handlers.get(i);
|
handlers[i].setFormatter(formatter);
|
||||||
handler.setFormatter(formatter);
|
|
||||||
}
|
}
|
||||||
log.log(Level.CONFIG, "Formatter=" + formatter);
|
log.log(Level.CONFIG, "Formatter=" + formatter);
|
||||||
} // setFormatter
|
} // setFormatter
|
||||||
|
@ -233,10 +232,12 @@ public class CLogMgt
|
||||||
*/
|
*/
|
||||||
protected static void setFilter (Filter filter)
|
protected static void setFilter (Filter filter)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < s_handlers.size(); i++)
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
|
rootLogger.setUseParentHandlers(false);
|
||||||
|
Handler[] handlers = rootLogger.getHandlers();
|
||||||
|
for (int i = 0; i < handlers.length; i++)
|
||||||
{
|
{
|
||||||
Handler handler = (Handler)s_handlers.get(i);
|
handlers[i].setFilter(filter);
|
||||||
handler.setFilter(filter);
|
|
||||||
}
|
}
|
||||||
log.log(Level.CONFIG, "Filter=" + filter);
|
log.log(Level.CONFIG, "Filter=" + filter);
|
||||||
} // setFilter
|
} // setFilter
|
||||||
|
@ -255,7 +256,7 @@ public class CLogMgt
|
||||||
while (en.hasMoreElements())
|
while (en.hasMoreElements())
|
||||||
{
|
{
|
||||||
String name = en.nextElement().toString();
|
String name = en.nextElement().toString();
|
||||||
if (loggerNamePart == null
|
if (loggerNamePart == null
|
||||||
|| name.indexOf(loggerNamePart) != -1)
|
|| name.indexOf(loggerNamePart) != -1)
|
||||||
{
|
{
|
||||||
Logger lll = Logger.getLogger(name);
|
Logger lll = Logger.getLogger(name);
|
||||||
|
@ -272,23 +273,22 @@ public class CLogMgt
|
||||||
{
|
{
|
||||||
if (level == null)
|
if (level == null)
|
||||||
return;
|
return;
|
||||||
if (s_handlers == null)
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
initialize(true);
|
rootLogger.setUseParentHandlers(false);
|
||||||
//
|
Handler[] handlers = rootLogger.getHandlers();
|
||||||
for (int i = 0; i < s_handlers.size(); i++)
|
if (handlers == null || handlers.length == 0)
|
||||||
{
|
{
|
||||||
Handler handler = (Handler)s_handlers.get(i);
|
initialize(true);
|
||||||
handler.setLevel(level);
|
handlers = rootLogger.getHandlers();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
for (int i = 0; i < handlers.length; i++)
|
||||||
|
{
|
||||||
|
handlers[i].setLevel(level);
|
||||||
}
|
}
|
||||||
// JDBC if ALL
|
// JDBC if ALL
|
||||||
setJDBCDebug(s_currentLevel.intValue() == Level.ALL.intValue());
|
setJDBCDebug(level.intValue() == Level.ALL.intValue());
|
||||||
//
|
//
|
||||||
if (level.intValue() != s_currentLevel.intValue())
|
|
||||||
{
|
|
||||||
setLoggerLevel(level, null);
|
|
||||||
log.config(level.toString());
|
|
||||||
}
|
|
||||||
s_currentLevel = level;
|
|
||||||
} // setHandlerLevel
|
} // setHandlerLevel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -299,7 +299,7 @@ public class CLogMgt
|
||||||
{
|
{
|
||||||
setLevel(String.valueOf(intLevel));
|
setLevel(String.valueOf(intLevel));
|
||||||
} // setLevel
|
} // setLevel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Level
|
* Set Level
|
||||||
* @param levelString string representation of level
|
* @param levelString string representation of level
|
||||||
|
@ -309,9 +309,9 @@ public class CLogMgt
|
||||||
if (levelString == null)
|
if (levelString == null)
|
||||||
return;
|
return;
|
||||||
//
|
//
|
||||||
for (int i = 0; i < LEVELS.length; i++)
|
for (int i = 0; i < LEVELS.length; i++)
|
||||||
{
|
{
|
||||||
if (LEVELS[i].getName().equals(levelString))
|
if (LEVELS[i].getName().equals(levelString))
|
||||||
{
|
{
|
||||||
setLevel(LEVELS[i]);
|
setLevel(LEVELS[i]);
|
||||||
return;
|
return;
|
||||||
|
@ -331,25 +331,27 @@ public class CLogMgt
|
||||||
else
|
else
|
||||||
DriverManager.setLogWriter(null);
|
DriverManager.setLogWriter(null);
|
||||||
} // setJDBCDebug
|
} // setJDBCDebug
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get logging Level of handlers
|
* Get logging Level of handlers
|
||||||
* @return logging level
|
* @return logging level
|
||||||
*/
|
*/
|
||||||
public static Level getLevel()
|
public static Level getLevel()
|
||||||
{
|
{
|
||||||
return s_currentLevel;
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
|
return rootLogger.getLevel();
|
||||||
} // getLevel
|
} // getLevel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get logging Level of handlers
|
* Get logging Level of handlers
|
||||||
* @return logging level
|
* @return logging level
|
||||||
*/
|
*/
|
||||||
public static int getLevelAsInt()
|
public static int getLevelAsInt()
|
||||||
{
|
{
|
||||||
return s_currentLevel.intValue();
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
|
return rootLogger.getLevel().intValue();
|
||||||
} // getLevel
|
} // getLevel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Logging Level logged
|
* Is Logging Level logged
|
||||||
* @param level level
|
* @param level level
|
||||||
|
@ -359,16 +361,16 @@ public class CLogMgt
|
||||||
{
|
{
|
||||||
if (level == null)
|
if (level == null)
|
||||||
return false;
|
return false;
|
||||||
return level.intValue() >= s_currentLevel.intValue();
|
return level.intValue() >= getLevelAsInt();
|
||||||
} // isLevel
|
} // isLevel
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Logging Level FINEST logged
|
* Is Logging Level FINEST logged
|
||||||
* @return true if it is logged
|
* @return true if it is logged
|
||||||
*/
|
*/
|
||||||
public static boolean isLevelAll ()
|
public static boolean isLevelAll ()
|
||||||
{
|
{
|
||||||
return Level.ALL.intValue() == s_currentLevel.intValue();
|
return Level.ALL.intValue() == getLevelAsInt();
|
||||||
} // isLevelFinest
|
} // isLevelFinest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -377,25 +379,25 @@ public class CLogMgt
|
||||||
*/
|
*/
|
||||||
public static boolean isLevelFinest ()
|
public static boolean isLevelFinest ()
|
||||||
{
|
{
|
||||||
return Level.FINEST.intValue() >= s_currentLevel.intValue();
|
return Level.FINEST.intValue() >= getLevelAsInt();
|
||||||
} // isLevelFinest
|
} // isLevelFinest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Logging Level FINER logged
|
* Is Logging Level FINER logged
|
||||||
* @return true if it is logged
|
* @return true if it is logged
|
||||||
*/
|
*/
|
||||||
public static boolean isLevelFiner ()
|
public static boolean isLevelFiner ()
|
||||||
{
|
{
|
||||||
return Level.FINER.intValue() >= s_currentLevel.intValue();
|
return Level.FINER.intValue() >= getLevelAsInt();
|
||||||
} // isLevelFiner
|
} // isLevelFiner
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is Logging Level FINE logged
|
* Is Logging Level FINE logged
|
||||||
* @return true if it is logged
|
* @return true if it is logged
|
||||||
*/
|
*/
|
||||||
public static boolean isLevelFine ()
|
public static boolean isLevelFine ()
|
||||||
{
|
{
|
||||||
return Level.FINE.intValue() >= s_currentLevel.intValue();
|
return Level.FINE.intValue() >= getLevelAsInt();
|
||||||
} // isLevelFine
|
} // isLevelFine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -404,7 +406,7 @@ public class CLogMgt
|
||||||
*/
|
*/
|
||||||
public static boolean isLevelInfo ()
|
public static boolean isLevelInfo ()
|
||||||
{
|
{
|
||||||
return Level.INFO.intValue() >= s_currentLevel.intValue();
|
return Level.INFO.intValue() >= getLevelAsInt();
|
||||||
} // isLevelFine
|
} // isLevelFine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -413,18 +415,19 @@ public class CLogMgt
|
||||||
*/
|
*/
|
||||||
public static void enable (boolean enableLogging)
|
public static void enable (boolean enableLogging)
|
||||||
{
|
{
|
||||||
|
Logger rootLogger = Logger.getLogger(getRootLoggerName());
|
||||||
|
rootLogger.setUseParentHandlers(false);
|
||||||
|
|
||||||
if (enableLogging)
|
if (enableLogging)
|
||||||
setLevel(s_currentLevel);
|
setLevel(rootLogger.getLevel());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Level level = s_currentLevel;
|
|
||||||
setLevel(Level.OFF);
|
setLevel(Level.OFF);
|
||||||
s_currentLevel = level;
|
|
||||||
}
|
}
|
||||||
} // enable
|
} // enable
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown Logging system
|
* Shutdown Logging system
|
||||||
*/
|
*/
|
||||||
|
@ -433,8 +436,8 @@ public class CLogMgt
|
||||||
LogManager mgr = LogManager.getLogManager();
|
LogManager mgr = LogManager.getLogManager();
|
||||||
mgr.reset();
|
mgr.reset();
|
||||||
} // shutdown
|
} // shutdown
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print Properties
|
* Print Properties
|
||||||
*
|
*
|
||||||
|
@ -450,8 +453,7 @@ public class CLogMgt
|
||||||
log.info(description + " - Size=" + p.size()
|
log.info(description + " - Size=" + p.size()
|
||||||
+ ", Hash=" + p.hashCode() + "\n" + getLocalHost());
|
+ ", Hash=" + p.hashCode() + "\n" + getLocalHost());
|
||||||
else
|
else
|
||||||
System.out.println("Log.printProperties = " + description + ", Size=" + p.size()
|
System.out.println("Log.printProperties = " + description + ", Size=" + p.size());
|
||||||
+ ", Hash=" + p.hashCode() + "\n" + getLocalHost());
|
|
||||||
|
|
||||||
Object[] pp = p.keySet().toArray();
|
Object[] pp = p.keySet().toArray();
|
||||||
Arrays.sort(pp);
|
Arrays.sort(pp);
|
||||||
|
@ -466,7 +468,7 @@ public class CLogMgt
|
||||||
}
|
}
|
||||||
} // printProperties
|
} // printProperties
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Adempiere System Info
|
* Get Adempiere System Info
|
||||||
* @param sb buffer to append or null
|
* @param sb buffer to append or null
|
||||||
|
@ -523,13 +525,13 @@ public class CLogMgt
|
||||||
sb.append(Adempiere.getJavaInfo()).append(NL);
|
sb.append(Adempiere.getJavaInfo()).append(NL);
|
||||||
sb.append("java.io.tmpdir="+System.getProperty("java.io.tmpdir")).append(NL);
|
sb.append("java.io.tmpdir="+System.getProperty("java.io.tmpdir")).append(NL);
|
||||||
sb.append(Adempiere.getOSInfo()).append(NL);
|
sb.append(Adempiere.getOSInfo()).append(NL);
|
||||||
|
|
||||||
//report memory info
|
//report memory info
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
//max heap size
|
//max heap size
|
||||||
sb.append("Max Heap = "+formatMemoryInfo(runtime.maxMemory())).append(NL);
|
sb.append("Max Heap = "+formatMemoryInfo(runtime.maxMemory())).append(NL);
|
||||||
//allocated heap size
|
//allocated heap size
|
||||||
sb.append("Allocated Heap = "+formatMemoryInfo(runtime.totalMemory())).append(NL);
|
sb.append("Allocated Heap = "+formatMemoryInfo(runtime.totalMemory())).append(NL);
|
||||||
//free heap size
|
//free heap size
|
||||||
sb.append("Free Heap = "+formatMemoryInfo(runtime.freeMemory())).append(NL);
|
sb.append("Free Heap = "+formatMemoryInfo(runtime.freeMemory())).append(NL);
|
||||||
//
|
//
|
||||||
|
@ -554,7 +556,7 @@ public class CLogMgt
|
||||||
}
|
}
|
||||||
return size + unit;
|
return size + unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create System Info
|
* Create System Info
|
||||||
* @param sb Optional string buffer
|
* @param sb Optional string buffer
|
||||||
|
@ -653,7 +655,7 @@ public class CLogMgt
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} // getDatabaseInfo
|
} // getDatabaseInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Localhost
|
* Get Localhost
|
||||||
* @return local host
|
* @return local host
|
||||||
|
@ -672,7 +674,7 @@ public class CLogMgt
|
||||||
return "-no local host info -";
|
return "-no local host info -";
|
||||||
} // getLocalHost
|
} // getLocalHost
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* CLogMgt
|
* CLogMgt
|
||||||
*/
|
*/
|
||||||
|
@ -705,7 +707,7 @@ public class CLogMgt
|
||||||
log1.info("thread info");
|
log1.info("thread info");
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Integer.parseInt("ABC");
|
Integer.parseInt("ABC");
|
||||||
|
@ -717,7 +719,7 @@ public class CLogMgt
|
||||||
log1.log(Level.INFO, "info message 1", "1Param");
|
log1.log(Level.INFO, "info message 1", "1Param");
|
||||||
log1.log(Level.INFO, "info message n", new Object[]{"1Param","2Param"});
|
log1.log(Level.INFO, "info message n", new Object[]{"1Param","2Param"});
|
||||||
} // testLog
|
} // testLog
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test
|
* Test
|
||||||
* @param args ignored
|
* @param args ignored
|
||||||
|
|
|
@ -23,14 +23,14 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adempiere Logger
|
* Adempiere Logger
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: CLogger.java,v 1.3 2006/08/09 16:38:47 jjanke Exp $
|
* @version $Id: CLogger.java,v 1.3 2006/08/09 16:38:47 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class CLogger extends Logger implements Serializable
|
public class CLogger extends Logger implements Serializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 6492376264463028357L;
|
private static final long serialVersionUID = 6492376264463028357L;
|
||||||
private static final String LAST_INFO = "org.compiere.util.CLogger.lastInfo";
|
private static final String LAST_INFO = "org.compiere.util.CLogger.lastInfo";
|
||||||
|
@ -44,12 +44,14 @@ public class CLogger extends Logger implements Serializable
|
||||||
* @param className class name
|
* @param className class name
|
||||||
* @return Logger
|
* @return Logger
|
||||||
*/
|
*/
|
||||||
public static synchronized CLogger getCLogger (String className)
|
public static synchronized CLogger getCLogger (String className)
|
||||||
{
|
{
|
||||||
// CLogMgt.initialize();
|
// CLogMgt.initialize();
|
||||||
LogManager manager = LogManager.getLogManager();
|
LogManager manager = LogManager.getLogManager();
|
||||||
if (className == null)
|
if (className == null || className.trim().length() == 0)
|
||||||
className = "";
|
className = CLogMgt.getRootLoggerName();
|
||||||
|
else
|
||||||
|
className = CLogMgt.getRootLoggerName() + "." + className;
|
||||||
Logger result = manager.getLogger(className);
|
Logger result = manager.getLogger(className);
|
||||||
if (result != null && result instanceof CLogger)
|
if (result != null && result instanceof CLogger)
|
||||||
return (CLogger)result;
|
return (CLogger)result;
|
||||||
|
@ -83,11 +85,11 @@ public class CLogger extends Logger implements Serializable
|
||||||
s_logger = getCLogger("org.compiere.default");
|
s_logger = getCLogger("org.compiere.default");
|
||||||
return s_logger;
|
return s_logger;
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
/** Default Logger */
|
/** Default Logger */
|
||||||
private static CLogger s_logger = null;
|
private static CLogger s_logger = null;
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Standard constructor
|
* Standard constructor
|
||||||
* @param name logger name
|
* @param name logger name
|
||||||
|
@ -99,7 +101,7 @@ public class CLogger extends Logger implements Serializable
|
||||||
// setLevel(Level.ALL);
|
// setLevel(Level.ALL);
|
||||||
} // CLogger
|
} // CLogger
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +118,7 @@ public class CLogger extends Logger implements Serializable
|
||||||
/**
|
/**
|
||||||
* Set and issue Error and save as ValueNamePair
|
* Set and issue Error and save as ValueNamePair
|
||||||
* @param AD_Message message key
|
* @param AD_Message message key
|
||||||
* @param ex exception
|
* @param ex exception
|
||||||
* @return true (to avoid removal of method)
|
* @return true (to avoid removal of method)
|
||||||
*/
|
*/
|
||||||
public boolean saveError (String AD_Message, Exception ex)
|
public boolean saveError (String AD_Message, Exception ex)
|
||||||
|
@ -128,8 +130,8 @@ public class CLogger extends Logger implements Serializable
|
||||||
/**
|
/**
|
||||||
* Set and issue (if specified) Error and save as ValueNamePair
|
* Set and issue (if specified) Error and save as ValueNamePair
|
||||||
* @param AD_Message message key
|
* @param AD_Message message key
|
||||||
* @param ex exception
|
* @param ex exception
|
||||||
* @param issueError if true will issue an error
|
* @param issueError if true will issue an error
|
||||||
* @return true (to avoid removal of method)
|
* @return true (to avoid removal of method)
|
||||||
*/
|
*/
|
||||||
public boolean saveError (String AD_Message, Exception ex, boolean issueError)
|
public boolean saveError (String AD_Message, Exception ex, boolean issueError)
|
||||||
|
@ -137,7 +139,7 @@ public class CLogger extends Logger implements Serializable
|
||||||
Env.getCtx().put(LAST_EXCEPTION, ex);
|
Env.getCtx().put(LAST_EXCEPTION, ex);
|
||||||
return saveError (AD_Message, ex.getLocalizedMessage(), issueError);
|
return saveError (AD_Message, ex.getLocalizedMessage(), issueError);
|
||||||
} // saveError
|
} // saveError
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Error and save as ValueNamePair
|
* Set Error and save as ValueNamePair
|
||||||
* @param AD_Message message key
|
* @param AD_Message message key
|
||||||
|
@ -161,10 +163,10 @@ public class CLogger extends Logger implements Serializable
|
||||||
*/
|
*/
|
||||||
public static ValueNamePair retrieveError()
|
public static ValueNamePair retrieveError()
|
||||||
{
|
{
|
||||||
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_ERROR);
|
ValueNamePair vp = (ValueNamePair) Env.getCtx().remove(LAST_ERROR);
|
||||||
return vp;
|
return vp;
|
||||||
} // retrieveError
|
} // retrieveError
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Error message from stack
|
* Get Error message from stack
|
||||||
* @param defaultMsg default message (used when there are no errors on stack)
|
* @param defaultMsg default message (used when there are no errors on stack)
|
||||||
|
@ -249,7 +251,7 @@ public class CLogger extends Logger implements Serializable
|
||||||
Env.getCtx().remove(LAST_WARNING);
|
Env.getCtx().remove(LAST_WARNING);
|
||||||
Env.getCtx().remove(LAST_INFO);
|
Env.getCtx().remove(LAST_INFO);
|
||||||
} // resetLast
|
} // resetLast
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get root cause
|
* Get root cause
|
||||||
* @param t
|
* @param t
|
||||||
|
@ -261,10 +263,10 @@ public class CLogger extends Logger implements Serializable
|
||||||
while (cause.getCause() != null)
|
while (cause.getCause() != null)
|
||||||
{
|
{
|
||||||
cause = cause.getCause();
|
cause = cause.getCause();
|
||||||
}
|
}
|
||||||
return cause;
|
return cause;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
|
@ -276,7 +278,7 @@ public class CLogger extends Logger implements Serializable
|
||||||
.append (",Level=").append (getLevel()).append ("]");
|
.append (",Level=").append (getLevel()).append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write Object - Serialization
|
* Write Object - Serialization
|
||||||
* @param out out
|
* @param out out
|
||||||
|
@ -287,9 +289,9 @@ public class CLogger extends Logger implements Serializable
|
||||||
out.writeObject(getName());
|
out.writeObject(getName());
|
||||||
System.out.println("====writeObject:" + getName());
|
System.out.println("====writeObject:" + getName());
|
||||||
} // writeObject
|
} // writeObject
|
||||||
|
|
||||||
private String m_className = null;
|
private String m_className = null;
|
||||||
|
|
||||||
private void readObject (ObjectInputStream in) throws IOException
|
private void readObject (ObjectInputStream in) throws IOException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -302,7 +304,7 @@ public class CLogger extends Logger implements Serializable
|
||||||
}
|
}
|
||||||
System.out.println("====readObject:" + m_className);
|
System.out.println("====readObject:" + m_className);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object readResolve() throws ObjectStreamException
|
protected Object readResolve() throws ObjectStreamException
|
||||||
{
|
{
|
||||||
System.out.println("====readResolve:" + m_className);
|
System.out.println("====readResolve:" + m_className);
|
||||||
|
|
|
@ -70,9 +70,6 @@ import org.compiere.swing.CFrame;
|
||||||
*/
|
*/
|
||||||
public final class Env
|
public final class Env
|
||||||
{
|
{
|
||||||
/** Logging */
|
|
||||||
private static CLogger s_log = CLogger.getCLogger(Env.class);
|
|
||||||
|
|
||||||
private final static ContextProvider clientContextProvider = new DefaultContextProvider();
|
private final static ContextProvider clientContextProvider = new DefaultContextProvider();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +95,6 @@ public final class Env
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
reset(true); // final cache reset
|
reset(true); // final cache reset
|
||||||
s_log.info("");
|
|
||||||
//
|
//
|
||||||
CLogMgt.shutdown();
|
CLogMgt.shutdown();
|
||||||
//
|
//
|
||||||
|
@ -128,7 +124,6 @@ public final class Env
|
||||||
*/
|
*/
|
||||||
public static void reset (boolean finalCall)
|
public static void reset (boolean finalCall)
|
||||||
{
|
{
|
||||||
s_log.info("finalCall=" + finalCall);
|
|
||||||
if (Ini.isClient())
|
if (Ini.isClient())
|
||||||
{
|
{
|
||||||
closeWindows();
|
closeWindows();
|
||||||
|
@ -243,7 +238,7 @@ public final class Env
|
||||||
{
|
{
|
||||||
if (ctx == null || context == null)
|
if (ctx == null || context == null)
|
||||||
return;
|
return;
|
||||||
s_log.finer("Context " + context + "==" + value);
|
getLogger().finer("Context " + context + "==" + value);
|
||||||
//
|
//
|
||||||
if (value == null || value.length() == 0)
|
if (value == null || value.length() == 0)
|
||||||
ctx.remove(context);
|
ctx.remove(context);
|
||||||
|
@ -251,6 +246,10 @@ public final class Env
|
||||||
ctx.setProperty(context, value);
|
ctx.setProperty(context, value);
|
||||||
} // setContext
|
} // setContext
|
||||||
|
|
||||||
|
private static CLogger getLogger() {
|
||||||
|
return CLogger.getCLogger(Env.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Global Context to Value
|
* Set Global Context to Value
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -264,7 +263,7 @@ public final class Env
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
ctx.remove(context);
|
ctx.remove(context);
|
||||||
s_log.finer("Context " + context + "==" + value);
|
getLogger().finer("Context " + context + "==" + value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // JDBC Format 2005-05-09 00:00:00.0
|
{ // JDBC Format 2005-05-09 00:00:00.0
|
||||||
|
@ -272,7 +271,7 @@ public final class Env
|
||||||
// Chop off .0 (nanos)
|
// Chop off .0 (nanos)
|
||||||
stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
||||||
ctx.setProperty(context, stringValue);
|
ctx.setProperty(context, stringValue);
|
||||||
s_log.finer("Context " + context + "==" + stringValue);
|
getLogger().finer("Context " + context + "==" + stringValue);
|
||||||
}
|
}
|
||||||
} // setContext
|
} // setContext
|
||||||
|
|
||||||
|
@ -286,7 +285,7 @@ public final class Env
|
||||||
{
|
{
|
||||||
if (ctx == null || context == null)
|
if (ctx == null || context == null)
|
||||||
return;
|
return;
|
||||||
s_log.finer("Context " + context + "==" + value);
|
getLogger().finer("Context " + context + "==" + value);
|
||||||
//
|
//
|
||||||
ctx.setProperty(context, String.valueOf(value));
|
ctx.setProperty(context, String.valueOf(value));
|
||||||
} // setContext
|
} // setContext
|
||||||
|
@ -314,7 +313,7 @@ public final class Env
|
||||||
if (ctx == null || context == null)
|
if (ctx == null || context == null)
|
||||||
return;
|
return;
|
||||||
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
|
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
|
||||||
s_log.finer("Context("+WindowNo+") " + context + "==" + value);
|
getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
|
||||||
//
|
//
|
||||||
if (value == null || value.equals(""))
|
if (value == null || value.equals(""))
|
||||||
ctx.remove(WindowNo+"|"+context);
|
ctx.remove(WindowNo+"|"+context);
|
||||||
|
@ -336,7 +335,7 @@ public final class Env
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
{
|
||||||
ctx.remove(WindowNo+"|"+context);
|
ctx.remove(WindowNo+"|"+context);
|
||||||
s_log.finer("Context("+WindowNo+") " + context + "==" + value);
|
getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // JDBC Format 2005-05-09 00:00:00.0
|
{ // JDBC Format 2005-05-09 00:00:00.0
|
||||||
|
@ -344,7 +343,7 @@ public final class Env
|
||||||
// Chop off .0 (nanos)
|
// Chop off .0 (nanos)
|
||||||
stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
stringValue = stringValue.substring(0, stringValue.indexOf("."));
|
||||||
ctx.setProperty(WindowNo+"|"+context, stringValue);
|
ctx.setProperty(WindowNo+"|"+context, stringValue);
|
||||||
s_log.finer("Context("+WindowNo+") " + context + "==" + stringValue);
|
getLogger().finer("Context("+WindowNo+") " + context + "==" + stringValue);
|
||||||
}
|
}
|
||||||
} // setContext
|
} // setContext
|
||||||
|
|
||||||
|
@ -360,7 +359,7 @@ public final class Env
|
||||||
if (ctx == null || context == null)
|
if (ctx == null || context == null)
|
||||||
return;
|
return;
|
||||||
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
|
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
|
||||||
s_log.finer("Context("+WindowNo+") " + context + "==" + value);
|
getLogger().finer("Context("+WindowNo+") " + context + "==" + value);
|
||||||
//
|
//
|
||||||
ctx.setProperty(WindowNo+"|"+context, String.valueOf(value));
|
ctx.setProperty(WindowNo+"|"+context, String.valueOf(value));
|
||||||
} // setContext
|
} // setContext
|
||||||
|
@ -390,7 +389,7 @@ public final class Env
|
||||||
if (ctx == null || context == null)
|
if (ctx == null || context == null)
|
||||||
return;
|
return;
|
||||||
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
|
if (WindowNo != WINDOW_FIND && WindowNo != WINDOW_MLOOKUP)
|
||||||
s_log.finest("Context("+WindowNo+","+TabNo+") " + context + "==" + value);
|
getLogger().finest("Context("+WindowNo+","+TabNo+") " + context + "==" + value);
|
||||||
//
|
//
|
||||||
if (value == null)
|
if (value == null)
|
||||||
if (context.endsWith("_ID"))
|
if (context.endsWith("_ID"))
|
||||||
|
@ -607,7 +606,7 @@ public final class Env
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e);
|
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} // getContextAsInt
|
} // getContextAsInt
|
||||||
|
@ -631,7 +630,7 @@ public final class Env
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e);
|
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} // getContextAsInt
|
} // getContextAsInt
|
||||||
|
@ -656,7 +655,7 @@ public final class Env
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e);
|
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} // getContextAsInt
|
} // getContextAsInt
|
||||||
|
@ -681,7 +680,7 @@ public final class Env
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e)
|
catch (NumberFormatException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "(" + context + ") = " + s, e);
|
getLogger().log(Level.SEVERE, "(" + context + ") = " + s, e);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} // getContextAsInt
|
} // getContextAsInt
|
||||||
|
@ -815,7 +814,7 @@ public final class Env
|
||||||
// JDBC Format YYYY-MM-DD example 2000-09-11 00:00:00.0
|
// JDBC Format YYYY-MM-DD example 2000-09-11 00:00:00.0
|
||||||
if (s == null || s.equals(""))
|
if (s == null || s.equals(""))
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "No value for: " + context);
|
getLogger().log(Level.SEVERE, "No value for: " + context);
|
||||||
return new Timestamp(System.currentTimeMillis());
|
return new Timestamp(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,7 +1067,7 @@ public final class Env
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "", e);
|
getLogger().log(Level.SEVERE, "", e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
DB.close(rs, pstmt);
|
DB.close(rs, pstmt);
|
||||||
|
@ -1080,7 +1079,7 @@ public final class Env
|
||||||
// No Language - set to System
|
// No Language - set to System
|
||||||
if (AD_Languages.size() == 0)
|
if (AD_Languages.size() == 0)
|
||||||
{
|
{
|
||||||
s_log.warning ("NO System Language - Set to Base " + Language.getBaseAD_Language());
|
getLogger().warning ("NO System Language - Set to Base " + Language.getBaseAD_Language());
|
||||||
language.setAD_Language(Language.getBaseAD_Language());
|
language.setAD_Language(Language.getBaseAD_Language());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1093,7 +1092,7 @@ public final class Env
|
||||||
String langCompare = language.getAD_Language().substring(0, 2);
|
String langCompare = language.getAD_Language().substring(0, 2);
|
||||||
if (lang.equals(langCompare))
|
if (lang.equals(langCompare))
|
||||||
{
|
{
|
||||||
s_log.fine("Found similar Language " + AD_Language);
|
getLogger().fine("Found similar Language " + AD_Language);
|
||||||
language.setAD_Language(AD_Language);
|
language.setAD_Language(AD_Language);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1102,7 +1101,7 @@ public final class Env
|
||||||
// We found same language
|
// We found same language
|
||||||
// if (!"0".equals(Msg.getMsg(AD_Language, "0")))
|
// if (!"0".equals(Msg.getMsg(AD_Language, "0")))
|
||||||
|
|
||||||
s_log.warning ("Not System Language=" + language
|
getLogger().warning ("Not System Language=" + language
|
||||||
+ " - Set to Base Language " + Language.getBaseAD_Language());
|
+ " - Set to Base Language " + Language.getBaseAD_Language());
|
||||||
language.setAD_Language(Language.getBaseAD_Language());
|
language.setAD_Language(Language.getBaseAD_Language());
|
||||||
} // verifyLanguage
|
} // verifyLanguage
|
||||||
|
@ -1226,7 +1225,7 @@ public final class Env
|
||||||
int j = inStr.indexOf('@'); // next @
|
int j = inStr.indexOf('@'); // next @
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "No second tag: " + inStr);
|
getLogger().log(Level.SEVERE, "No second tag: " + inStr);
|
||||||
return ""; // no second tag
|
return ""; // no second tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1237,7 +1236,7 @@ public final class Env
|
||||||
ctxInfo = getContext(ctx, token); // get global context
|
ctxInfo = getContext(ctx, token); // get global context
|
||||||
if (ctxInfo.length() == 0)
|
if (ctxInfo.length() == 0)
|
||||||
{
|
{
|
||||||
s_log.config("No Context Win=" + WindowNo + " for: " + token);
|
getLogger().config("No Context Win=" + WindowNo + " for: " + token);
|
||||||
if (!ignoreUnparsable)
|
if (!ignoreUnparsable)
|
||||||
return ""; // token not found
|
return ""; // token not found
|
||||||
}
|
}
|
||||||
|
@ -1291,7 +1290,7 @@ public final class Env
|
||||||
int j = inStr.indexOf('@'); // next @
|
int j = inStr.indexOf('@'); // next @
|
||||||
if (j < 0)
|
if (j < 0)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "No second tag: " + inStr);
|
getLogger().log(Level.SEVERE, "No second tag: " + inStr);
|
||||||
return ""; // no second tag
|
return ""; // no second tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1410,7 +1409,7 @@ public final class Env
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, e.toString());
|
getLogger().log(Level.SEVERE, e.toString());
|
||||||
}
|
}
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getWindow
|
} // getWindow
|
||||||
|
@ -1513,7 +1512,7 @@ public final class Env
|
||||||
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
|
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
|
||||||
if (url == null)
|
if (url == null)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "Not found: " + fileNameInImageDir);
|
getLogger().log(Level.SEVERE, "Not found: " + fileNameInImageDir);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||||
|
@ -1533,7 +1532,7 @@ public final class Env
|
||||||
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
|
// URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
|
||||||
if (url == null)
|
if (url == null)
|
||||||
{
|
{
|
||||||
s_log.log(Level.INFO, "Not found: " + fileNameInImageDir);
|
getLogger().log(Level.INFO, "Not found: " + fileNameInImageDir);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new ImageIcon(url);
|
return new ImageIcon(url);
|
||||||
|
@ -1558,7 +1557,7 @@ public final class Env
|
||||||
// url = Adempiere.class.getResource("images/" + fileName+".png");
|
// url = Adempiere.class.getResource("images/" + fileName+".png");
|
||||||
if (url == null)
|
if (url == null)
|
||||||
{
|
{
|
||||||
s_log.log(Level.INFO, "GIF/PNG Not found: " + fileName);
|
getLogger().log(Level.INFO, "GIF/PNG Not found: " + fileName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new ImageIcon(url);
|
return new ImageIcon(url);
|
||||||
|
@ -1571,7 +1570,7 @@ public final class Env
|
||||||
*/
|
*/
|
||||||
public static void startBrowser (String url)
|
public static void startBrowser (String url)
|
||||||
{
|
{
|
||||||
s_log.info(url);
|
getLogger().info(url);
|
||||||
getContextProvider().showURL(url);
|
getContextProvider().showURL(url);
|
||||||
} // startBrowser
|
} // startBrowser
|
||||||
|
|
||||||
|
@ -1615,7 +1614,7 @@ public final class Env
|
||||||
for (int i = 0; i < s_hiddenWindows.size(); i++)
|
for (int i = 0; i < s_hiddenWindows.size(); i++)
|
||||||
{
|
{
|
||||||
CFrame hidden = s_hiddenWindows.get(i);
|
CFrame hidden = s_hiddenWindows.get(i);
|
||||||
s_log.info(i + ": " + hidden);
|
getLogger().info(i + ": " + hidden);
|
||||||
if (hidden.getAD_Window_ID() == window.getAD_Window_ID())
|
if (hidden.getAD_Window_ID() == window.getAD_Window_ID())
|
||||||
return false; // already there
|
return false; // already there
|
||||||
}
|
}
|
||||||
|
@ -1624,7 +1623,7 @@ public final class Env
|
||||||
if (s_hiddenWindows.add(window))
|
if (s_hiddenWindows.add(window))
|
||||||
{
|
{
|
||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
s_log.info(window.toString());
|
getLogger().info(window.toString());
|
||||||
// window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_ICONIFIED));
|
// window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_ICONIFIED));
|
||||||
if (s_hiddenWindows.size() > 10) {
|
if (s_hiddenWindows.size() > 10) {
|
||||||
CFrame toClose = s_hiddenWindows.remove(0); // sort of lru
|
CFrame toClose = s_hiddenWindows.remove(0); // sort of lru
|
||||||
|
@ -1654,7 +1653,7 @@ public final class Env
|
||||||
if (hidden.getAD_Window_ID() == AD_Window_ID)
|
if (hidden.getAD_Window_ID() == AD_Window_ID)
|
||||||
{
|
{
|
||||||
s_hiddenWindows.remove(i);
|
s_hiddenWindows.remove(i);
|
||||||
s_log.info(hidden.toString());
|
getLogger().info(hidden.toString());
|
||||||
hidden.setVisible(true);
|
hidden.setVisible(true);
|
||||||
// De-iconify window - teo_sarca [ 1707221 ]
|
// De-iconify window - teo_sarca [ 1707221 ]
|
||||||
int state = hidden.getExtendedState();
|
int state = hidden.getExtendedState();
|
||||||
|
@ -1689,16 +1688,16 @@ public final class Env
|
||||||
*/
|
*/
|
||||||
public static void sleep (int sec)
|
public static void sleep (int sec)
|
||||||
{
|
{
|
||||||
s_log.info("Start - Seconds=" + sec);
|
getLogger().info("Start - Seconds=" + sec);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep(sec*1000);
|
Thread.sleep(sec*1000);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log(Level.WARNING, "", e);
|
getLogger().log(Level.WARNING, "", e);
|
||||||
}
|
}
|
||||||
s_log.info("End");
|
getLogger().info("End");
|
||||||
} // sleep
|
} // sleep
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,7 +51,7 @@ import org.compiere.util.Util;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $
|
* @version $Id: Adempiere.java,v 1.8 2006/08/11 02:58:14 jjanke Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class AdempiereClient
|
public final class AdempiereClient
|
||||||
{
|
{
|
||||||
|
@ -92,18 +92,17 @@ public final class AdempiereClient
|
||||||
|
|
||||||
// System properties
|
// System properties
|
||||||
Ini.loadProperties (false);
|
Ini.loadProperties (false);
|
||||||
|
|
||||||
// Set up Log
|
// Set up Log
|
||||||
CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL));
|
CLogMgt.setLevel(Ini.getProperty(Ini.P_TRACELEVEL));
|
||||||
if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE)
|
if (isClient && Ini.isPropertyBool(Ini.P_TRACEFILE))
|
||||||
&& CLogFile.get(false, null, isClient) == null)
|
CLogMgt.addHandler(new CLogFile(Ini.findAdempiereHome(), true, isClient));
|
||||||
CLogMgt.addHandler(CLogFile.get (true, Ini.findAdempiereHome(), isClient));
|
|
||||||
|
|
||||||
// Set UI
|
// Set UI
|
||||||
if (isClient)
|
if (isClient)
|
||||||
{
|
{
|
||||||
if (CLogMgt.isLevelAll())
|
if (CLogMgt.isLevelAll())
|
||||||
log.log(Level.FINEST, System.getProperties().toString());
|
log.log(Level.FINEST, System.getProperties().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Default Database Connection from Ini
|
// Set Default Database Connection from Ini
|
||||||
|
@ -111,7 +110,7 @@ public final class AdempiereClient
|
||||||
|
|
||||||
if (isClient) // don't test connection
|
if (isClient) // don't test connection
|
||||||
return false; // need to call
|
return false; // need to call
|
||||||
|
|
||||||
return startupEnvironment(isClient);
|
return startupEnvironment(isClient);
|
||||||
} // startup
|
} // startup
|
||||||
|
|
||||||
|
@ -133,7 +132,7 @@ public final class AdempiereClient
|
||||||
MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too
|
MSystem system = MSystem.get(Env.getCtx()); // Initializes Base Context too
|
||||||
if (system == null)
|
if (system == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Initialize main cached Singletons
|
// Initialize main cached Singletons
|
||||||
ModelValidationEngine.get();
|
ModelValidationEngine.get();
|
||||||
try
|
try
|
||||||
|
@ -151,9 +150,9 @@ public final class AdempiereClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SecureEngine.init(className);
|
SecureEngine.init(className);
|
||||||
|
|
||||||
//
|
//
|
||||||
if (isClient)
|
if (isClient)
|
||||||
MClient.get(Env.getCtx(),0); // Login Client loaded later
|
MClient.get(Env.getCtx(),0); // Login Client loaded later
|
||||||
else
|
else
|
||||||
MClient.getAll(Env.getCtx());
|
MClient.getAll(Env.getCtx());
|
||||||
|
@ -162,7 +161,7 @@ public final class AdempiereClient
|
||||||
{
|
{
|
||||||
log.warning("Environment problems: " + e.toString());
|
log.warning("Environment problems: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start Workflow Document Manager (in other package) for PO
|
// Start Workflow Document Manager (in other package) for PO
|
||||||
String className = null;
|
String className = null;
|
||||||
try
|
try
|
||||||
|
@ -177,7 +176,7 @@ public final class AdempiereClient
|
||||||
{
|
{
|
||||||
log.warning("Not started: " + className + " - " + e.getMessage());
|
log.warning("Not started: " + className + " - " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isClient)
|
if (!isClient)
|
||||||
DB.updateMail();
|
DB.updateMail();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.compiere.util.CLogMgt;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.util.Locales;
|
import org.zkoss.util.Locales;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
@ -80,7 +81,7 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
SessionManager.getAppDesktop().showURL(url, true);
|
SessionManager.getAppDesktop().showURL(url, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
ctx.put(CLogMgt.ROOT_LOGGER_NAME_PROPERTY, "org.adempiere.webui");
|
||||||
ctx.setProperty(SERVLET_SESSION_ID, httpSession.getId());
|
ctx.setProperty(SERVLET_SESSION_ID, httpSession.getId());
|
||||||
session.setAttribute(SESSION_CTX, ctx);
|
session.setAttribute(SESSION_CTX, ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.adempiere.webui.window.ZkReportViewerProvider;
|
||||||
import org.compiere.Adempiere;
|
import org.compiere.Adempiere;
|
||||||
import org.compiere.print.ReportCtl;
|
import org.compiere.print.ReportCtl;
|
||||||
import org.compiere.report.ReportStarter;
|
import org.compiere.report.ReportStarter;
|
||||||
|
import org.compiere.util.CLogMgt;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.Ini;
|
import org.compiere.util.Ini;
|
||||||
import org.zkoss.zk.ui.http.DHtmlLayoutServlet;
|
import org.zkoss.zk.ui.http.DHtmlLayoutServlet;
|
||||||
|
@ -69,6 +70,7 @@ public class WebUIServlet extends DHtmlLayoutServlet
|
||||||
SessionManager.getAppDesktop().showURL(url, true);
|
SessionManager.getAppDesktop().showURL(url, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
serverContext.put(CLogMgt.ROOT_LOGGER_NAME_PROPERTY, "org.adempiere.webui");
|
||||||
ServerContext.setCurrentInstance(serverContext);
|
ServerContext.setCurrentInstance(serverContext);
|
||||||
|
|
||||||
boolean started = Adempiere.startup(false);
|
boolean started = Adempiere.startup(false);
|
||||||
|
|
Loading…
Reference in New Issue