latest changes from Stefan: logging and fixed to short socket timeout in config file

This commit is contained in:
Ralf Becker 2013-01-22 17:57:27 +00:00
parent c3e831347d
commit 9ff3add324
9 changed files with 171 additions and 3 deletions

View File

@ -32,7 +32,7 @@ public class BaseHttp
private boolean _isSSL = false;
private boolean _isAjax = false;
private String _cookie = "";
private int _sockettimeout = 10;
private int _sockettimeout = 10000;
static private BaseHttpsTrustManager _bhtm = null;
@ -215,6 +215,7 @@ public class BaseHttp
}
catch( Exception exp )
{
egwDebuging.log.log(Level.SEVERE, null, exp);
throw new Exception("NETERROR");
}
@ -322,6 +323,7 @@ public class BaseHttp
}
catch(Exception exp)
{
egwDebuging.log.log(Level.SEVERE, null, exp);
throw new Exception("NETERROR");
}
@ -499,6 +501,7 @@ public class BaseHttp
}
catch( IOException ex)
{
egwDebuging.log.log(Level.SEVERE, null, ex);
}
return false;

View File

@ -20,6 +20,7 @@ import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.logging.Level;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
@ -86,6 +87,8 @@ public class BaseHttpsTrustManager implements javax.net.ssl.X509TrustManager
}
this.acceptcerts.add(cs);
egwDebuging.log.log(Level.SEVERE, null, exp);
}
}
}

View File

@ -50,6 +50,13 @@ public class EgroupwareTrayApp extends SingleFrameApplication {
public static void main(String[] args)
{
// Trayer Main Classe erstellen
new jegwMain();
try
{
jegwMain jegwMain = new jegwMain();
}
catch (Throwable uncaught)
{
egwDebuging.dumpUncaughtError(uncaught);
}
}
}

View File

@ -0,0 +1,132 @@
/**
* EGroupware - Notifications Java Desktop App
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package notifications
* @subpackage jdesk
* @link http://www.egroupware.org
* @author Stefan Werfling <stefan.werfling@hw-softwareentwicklung.de>
* @author Maik Hüttner <maik.huettner@hw-softwareentwicklung.de>
*/
package egroupwaretray;
import java.io.*;
import java.util.Date;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* egwDebuging
*
* @author Stefan Werfling <stefan.werfling@hw-softwareentwicklung.de>
*/
public class egwDebuging {
public static final Logger log = Logger.getLogger( egwDebuging.class.getName() );
public static Handler handler = null;
/**
* setLevel
* set Logging Level
*
* @param uselevel
*/
public static void setLevel(Level uselevel)
{
egwDebuging.log.setLevel(uselevel);
}
/**
* setDebuging
* enable/disable Debuging
*
* @param enable
*/
public static void setDebuging(Boolean enable)
{
if( enable && (handler == null) )
{
long now = System.currentTimeMillis();
try
{
egwDebuging.handler = new FileHandler(
String.format("egroupwarenotifier_log_%d.txt", now) );
egwDebuging.log.addHandler(egwDebuging.handler);
}
catch( IOException ex )
{
Logger.getLogger(egwDebuging.class.getName()).log(
Level.SEVERE, null, ex);
}
catch (SecurityException ex)
{
Logger.getLogger(egwDebuging.class.getName()).log(
Level.SEVERE, null, ex);
}
}
else if( !enable && (handler != null) )
{
egwDebuging.log.removeHandler(egwDebuging.handler);
egwDebuging.handler = null;
}
}
/**
*
* @param err
*/
protected static void dumpUncaughtError(Throwable err)
{
err.printStackTrace(System.err);
try
{
long now = System.currentTimeMillis();
String report = String.format("%s\n%s\n%s\n",
new Date(now),
err.getLocalizedMessage(),
egwDebuging.stackTraceToStr(err));
egwDebuging.writeFile(
new File(System.getProperty("java.io.tmpdir"),
String.format("egroupwarenotifier_uncaught_%d.txt", now)),
report.getBytes());
}
catch (Throwable ignored)
{
}
}
public static String stackTraceToStr(Throwable err)
{
StringWriter result = new StringWriter();
PrintWriter pwr = new PrintWriter(result);
err.printStackTrace(pwr);
pwr.flush();
pwr.close();
return result.toString();
}
public static void writeFile(File fl, byte[] data) throws IOException
{
FileOutputStream fos = new FileOutputStream(fl);
try
{
fos.write(data);
}
finally
{
fos.close();
}
}
}

View File

@ -80,6 +80,15 @@ public class jegwMain implements ActionListener
System.exit(0);
}
// Debuging
Boolean _debuging = ( jegwConst.getConstTag("egw_debuging").trim()
== "1" ? true : false);
egwDebuging.setDebuging(_debuging);
egwDebuging.setLevel(Level.parse(
jegwConst.getConstTag("egw_debuging_level").trim()));
// END
if( this.egwconfig.getCXMLM().countConf() < 1 )
{
String turl = jegwConst.getConstTag("egw_dc_url").trim();
@ -162,6 +171,7 @@ public class jegwMain implements ActionListener
{
Logger.getLogger(jegwMain.class.getName()).log(Level.SEVERE, null, ex);
jegwMain.debugDialog(ex.getMessage());
egwDebuging.log.log(Level.SEVERE, null, ex);
}
}
@ -412,6 +422,8 @@ public class jegwMain implements ActionListener
jegwConst.getConstTag("info_info"),
jegwConst.getConstTag("egw_msg_start_browser_error"),
TrayIcon.MessageType.ERROR);
egwDebuging.log.log(Level.SEVERE, null, exp);
}
}
}
@ -479,6 +491,7 @@ public class jegwMain implements ActionListener
dialog.setIconImage(hwTrayIcon.getImage(jegwConst.getConstTag("egwicon")));
} catch (IOException ex) {
Logger.getLogger(hwTrayIcon.class.getName()).log(Level.SEVERE, null, ex);
egwDebuging.log.log(Level.SEVERE, null, ex);
}
dialog.setAlwaysOnTop(true);
@ -629,6 +642,8 @@ public class jegwMain implements ActionListener
}
catch(Exception exp)
{
egwDebuging.log.log(Level.SEVERE, null, exp);
// Fehler
this.hwtray.showBallon(
jegwConst.getConstTag("info_info"),
@ -705,5 +720,6 @@ public class jegwMain implements ActionListener
}
Logger.getLogger(jegwMain.class.getName()).log(Level.SEVERE, null, ex);
egwDebuging.log.log(Level.SEVERE, null, ex);
}
}

View File

@ -150,6 +150,7 @@ public class jegwapplications
dialog.setIconImage(hwTrayIcon.getImage(jegwConst.getConstTag("egwicon")));
} catch (IOException ex) {
Logger.getLogger(hwTrayIcon.class.getName()).log(Level.SEVERE, null, ex);
egwDebuging.log.log(Level.SEVERE, null, ex);
}
((jegwInfoDialog)dialog).setNotifiyId(app.getString("notify_id"));

View File

@ -14,6 +14,7 @@ package egroupwaretray;
import java.awt.event.ActionListener;
import java.net.InetAddress;
import java.util.*;
import java.util.logging.Level;
import org.json.simple.parser.ContainerFactory;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
@ -146,6 +147,7 @@ public class jegwhttp
}
catch( Exception exp)
{
egwDebuging.log.log(Level.SEVERE, null, exp);
throw new Exception("HOSTNOTFOUND");
}
@ -705,6 +707,8 @@ public class jegwhttp
}
catch( ParseException pe )
{
egwDebuging.log.log(Level.SEVERE, null, pe);
throw new Exception("NOAPPS");
}
}

View File

@ -15,8 +15,10 @@
<egw_dc_url></egw_dc_url>
<egw_dc_logindomain></egw_dc_logindomain>
<egw_dc_username></egw_dc_username>
<egw_dc_timeout_socket>10</egw_dc_timeout_socket>
<egw_dc_timeout_socket>1000</egw_dc_timeout_socket>
<egw_dc_timeout_notify>30000</egw_dc_timeout_notify>
<egw_debuging>0</egw_debuging>
<egw_debuging_level>ALL</egw_debuging_level>
</egwdefaultconfig>
<ShowBallonInfo>
<info_login>Login</info_login>