[freenet-dev] [patch] logging unhandled exceptions

2002-09-02 Thread Robert Bihlmeyer
Pascal  writes:

> I modified Fred's logger some time ago to redirect StdErr and StdOut
> to the logfile if they did not exist. If this is not happening on
> your JVM your patch will certainly act as a workaround, but the
> preferred solution would be to submit a bug report to the developers
> of your JVM. If System.out.print is called when StdOut does not
> exist (such as when running Fred as a service)
> System.out.checkError() should return true.

You are mistaken. The way Unix services work stdout and friends will
work perfectly fine and accept anything thrown at them. It just won't
get anywhere.

Logging some things, and printing random others to stdout is certainly
wrong.

Actually I think the right way is to log everything, as Fred is closer
to a service than a (console) application. My patch is a small step in
the right direction.

-- 
Robbe
-- next part --
A non-text attachment was scrubbed...
Name: signature.ng
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [freenet-dev] [patch] logging unhandled exceptions

2002-09-02 Thread Robert Bihlmeyer

Pascal <[EMAIL PROTECTED]> writes:

> I modified Fred's logger some time ago to redirect StdErr and StdOut
> to the logfile if they did not exist. If this is not happening on
> your JVM your patch will certainly act as a workaround, but the
> preferred solution would be to submit a bug report to the developers
> of your JVM. If System.out.print is called when StdOut does not
> exist (such as when running Fred as a service)
> System.out.checkError() should return true.

You are mistaken. The way Unix services work stdout and friends will
work perfectly fine and accept anything thrown at them. It just won't
get anywhere.

Logging some things, and printing random others to stdout is certainly
wrong.

Actually I think the right way is to log everything, as Fred is closer
to a service than a (console) application. My patch is a small step in
the right direction.

-- 
Robbe



signature.ng
Description: PGP signature


[freenet-dev] [patch] logging unhandled exceptions

2002-09-02 Thread Oskar Sandberg

That shows nothing. A lot of files contain main() methods used for
testing and alike that contain such calls. Some are external programs
(config.Setup, client.cli, etc) that actually use it independently of the
node.

The real question is, what is being written to out/err when a node is
running?


On Sun, Sep 01, 2002 at 06:23:19PM -0500, Pascal wrote:
> Windows find shows 50 files containing system.out.print and 71
> containing system.err.print
> 
> -Pascal
> 
> 
> Oskar Sandberg wrote:
> > 
> > On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> > > There are many places in Fred where output is sent to StdErr and
> > > StdOut.
> > 
> > Except for cruft (which there shouldn't be any) I don't think this is
> > true. If it is, then each case is a coding error that should be fixed.
> > 
> > --
> > 
> > Oskar Sandberg
> > oskar at freenetproject.org
> > 
> > ___
> > devl mailing list
> > devl at freenetproject.org
> > http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl
> 
> ___
> devl mailing list
> devl at freenetproject.org
> http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl

-- 

Oskar Sandberg
oskar at freenetproject.org

___
devl mailing list
devl at freenetproject.org
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



[freenet-dev] [patch] logging unhandled exceptions

2002-09-02 Thread Oskar Sandberg
On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> There are many places in Fred where output is sent to StdErr and
> StdOut.  

Except for cruft (which there shouldn't be any) I don't think this is
true. If it is, then each case is a coding error that should be fixed.

-- 

Oskar Sandberg
oskar at freenetproject.org

___
devl mailing list
devl at freenetproject.org
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



[freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Robert Bihlmeyer
Hi,

I'm running Fred as a service in the background, and so won't see
exceptions that are not logged. The most likely culprits are fatal
datastore corruptions. All I see is that Fred is no longer running
after a boot.

So to get more information, I wrote code to catch unhandled exceptions
in the main class, and log them. I think it's useful, and applied it
to the Debian package. Would be fine if you could use this or a
similar mechanism ... most other exceptions /are/ logged after all.

Here's the patch:

-- next part --
A non-text attachment was scrubbed...
Name: _patch
Type: text/x-patch
Size: 848 bytes
Desc: not available
URL: 

-- next part --

-- 
Robbe
-- next part --
A non-text attachment was scrubbed...
Name: signature.ng
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Matthew Toseland
On Sun, Sep 01, 2002 at 09:33:18PM +0200, Robert Bihlmeyer wrote:
> Hi,
> 
> I'm running Fred as a service in the background, and so won't see
> exceptions that are not logged. The most likely culprits are fatal
> datastore corruptions. All I see is that Fred is no longer running
> after a boot.
> 
> So to get more information, I wrote code to catch unhandled exceptions
> in the main class, and log them. I think it's useful, and applied it
> to the Debian package. Would be fine if you could use this or a
> similar mechanism ... most other exceptions /are/ logged after all.
> 
> Here's the patch:
Committed. Thanks.
> 


> 
> -- 
> Robbe
BTW, why does the freenet-unstable DEB use a single JAR file? Maybe you
could arrange a configurable classpath, sourced by the init.d and
fclient, so I can still use fclient even if I want to build from CVS?
Just a thought.

-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



[freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Pascal
In main.java alone exception handling for BadAddressException,
DiagnosticsException, and ListenException write nothing to the log but
instead send the output to StdErr.  On JVMs that do not work correctly
these error messages are simply lost even with today's patch.  Making
these errors always goto the log prevents people who are not running
Fred as a service from seeing instantly what the problem is.

I'm not sure about what is being written while a node is running but I
think the point was more along the lines of finding out why a node isn't
starting rather than debugging messages output while it's running.  In
the users case he was getting exceptions from datastore corruption and
seeing nothing in the log but there are other reasons (as noted above)
where nothing will be put in the log (on a broke JVM) yet the node will
still not start.

-Pascal


Oskar Sandberg wrote:
> 
> That shows nothing. A lot of files contain main() methods used for
> testing and alike that contain such calls. Some are external programs
> (config.Setup, client.cli, etc) that actually use it independently of the
> node.
> 
> The real question is, what is being written to out/err when a node is
> running?
> 
> On Sun, Sep 01, 2002 at 06:23:19PM -0500, Pascal wrote:
> > Windows find shows 50 files containing system.out.print and 71
> > containing system.err.print
> >
> > -Pascal
> >
> >
> > Oskar Sandberg wrote:
> > >
> > > On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> > > > There are many places in Fred where output is sent to StdErr and
> > > > StdOut.
> > >
> > > Except for cruft (which there shouldn't be any) I don't think this is
> > > true. If it is, then each case is a coding error that should be fixed.
> > >
> > > --
> > >
> > > Oskar Sandberg
> > > oskar at freenetproject.org
> > >
> > > ___
> > > devl mailing list
> > > devl at freenetproject.org
> > > http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl
> >
> > ___
> > devl mailing list
> > devl at freenetproject.org
> > http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl
> 
> --
> 
> Oskar Sandberg
> oskar at freenetproject.org
> 
> ___
> devl mailing list
> devl at freenetproject.org
> http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl

___
devl mailing list
devl at freenetproject.org
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



[freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Pascal
Windows find shows 50 files containing system.out.print and 71
containing system.err.print

-Pascal


Oskar Sandberg wrote:
> 
> On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> > There are many places in Fred where output is sent to StdErr and
> > StdOut.
> 
> Except for cruft (which there shouldn't be any) I don't think this is
> true. If it is, then each case is a coding error that should be fixed.
> 
> --
> 
> Oskar Sandberg
> oskar at freenetproject.org
> 
> ___
> devl mailing list
> devl at freenetproject.org
> http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl

___
devl mailing list
devl at freenetproject.org
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



Re: [freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Pascal

In main.java alone exception handling for BadAddressException,
DiagnosticsException, and ListenException write nothing to the log but
instead send the output to StdErr.  On JVMs that do not work correctly
these error messages are simply lost even with today's patch.  Making
these errors always goto the log prevents people who are not running
Fred as a service from seeing instantly what the problem is.

I'm not sure about what is being written while a node is running but I
think the point was more along the lines of finding out why a node isn't
starting rather than debugging messages output while it's running.  In
the users case he was getting exceptions from datastore corruption and
seeing nothing in the log but there are other reasons (as noted above)
where nothing will be put in the log (on a broke JVM) yet the node will
still not start.

-Pascal


Oskar Sandberg wrote:
> 
> That shows nothing. A lot of files contain main() methods used for
> testing and alike that contain such calls. Some are external programs
> (config.Setup, client.cli, etc) that actually use it independently of the
> node.
> 
> The real question is, what is being written to out/err when a node is
> running?
> 
> On Sun, Sep 01, 2002 at 06:23:19PM -0500, Pascal wrote:
> > Windows find shows 50 files containing system.out.print and 71
> > containing system.err.print
> >
> > -Pascal
> >
> >
> > Oskar Sandberg wrote:
> > >
> > > On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> > > > There are many places in Fred where output is sent to StdErr and
> > > > StdOut.
> > >
> > > Except for cruft (which there shouldn't be any) I don't think this is
> > > true. If it is, then each case is a coding error that should be fixed.
> > >
> > > --
> > >
> > > Oskar Sandberg
> > > [EMAIL PROTECTED]
> > >
> > > ___
> > > devl mailing list
> > > [EMAIL PROTECTED]
> > > http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl
> >
> > ___
> > devl mailing list
> > [EMAIL PROTECTED]
> > http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl
> 
> --
> 
> Oskar Sandberg
> [EMAIL PROTECTED]
> 
> ___
> devl mailing list
> [EMAIL PROTECTED]
> http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl

___
devl mailing list
[EMAIL PROTECTED]
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



[freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Pascal
There are many places in Fred where output is sent to StdErr and
StdOut.  This patch will only catch the specific instance of an
unhandled exception occurring.  I modified Fred's logger some time ago
to redirect StdErr and StdOut to the logfile if they did not exist.  If
this is not happening on your JVM your patch will certainly act as a
workaround, but the preferred solution would be to submit a bug report
to the developers of your JVM.  If System.out.print is called when
StdOut does not exist (such as when running Fred as a service)
System.out.checkError() should return true.  Likewise for StdErr.  This
apparently is not happening on your JVM.  Your patch may cause
exceptions to be logged twice on working JVMs.  Not a huge issue, but
fixing the JVM would obviously be preferable.

-Pascal


Robert Bihlmeyer wrote:
> 
> Hi,
> 
> I'm running Fred as a service in the background, and so won't see
> exceptions that are not logged. The most likely culprits are fatal
> datastore corruptions. All I see is that Fred is no longer running
> after a boot.
> 
> So to get more information, I wrote code to catch unhandled exceptions
> in the main class, and log them. I think it's useful, and applied it
> to the Debian package. Would be fine if you could use this or a
> similar mechanism ... most other exceptions /are/ logged after all.
> 
> Here's the patch:
> 
>   
> 
>_patchName: _patch
>  Type: text/x-patch
> 
>   
> 
> --
> Robbe
> 
>   
>Name: signature.ng
>signature.ngType: application/pgp-signature
>Encoding: 7bit

___
devl mailing list
devl at freenetproject.org
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



Re: [freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Oskar Sandberg


That shows nothing. A lot of files contain main() methods used for
testing and alike that contain such calls. Some are external programs
(config.Setup, client.cli, etc) that actually use it independently of the
node.

The real question is, what is being written to out/err when a node is
running?


On Sun, Sep 01, 2002 at 06:23:19PM -0500, Pascal wrote:
> Windows find shows 50 files containing system.out.print and 71
> containing system.err.print
> 
> -Pascal
> 
> 
> Oskar Sandberg wrote:
> > 
> > On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> > > There are many places in Fred where output is sent to StdErr and
> > > StdOut.
> > 
> > Except for cruft (which there shouldn't be any) I don't think this is
> > true. If it is, then each case is a coding error that should be fixed.
> > 
> > --
> > 
> > Oskar Sandberg
> > [EMAIL PROTECTED]
> > 
> > ___
> > devl mailing list
> > [EMAIL PROTECTED]
> > http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl
> 
> ___
> devl mailing list
> [EMAIL PROTECTED]
> http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl

-- 

Oskar Sandberg
[EMAIL PROTECTED]

___
devl mailing list
[EMAIL PROTECTED]
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



Re: [freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Pascal

Windows find shows 50 files containing system.out.print and 71
containing system.err.print

-Pascal


Oskar Sandberg wrote:
> 
> On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> > There are many places in Fred where output is sent to StdErr and
> > StdOut.
> 
> Except for cruft (which there shouldn't be any) I don't think this is
> true. If it is, then each case is a coding error that should be fixed.
> 
> --
> 
> Oskar Sandberg
> [EMAIL PROTECTED]
> 
> ___
> devl mailing list
> [EMAIL PROTECTED]
> http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl

___
devl mailing list
[EMAIL PROTECTED]
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



Re: [freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Oskar Sandberg

On Sun, Sep 01, 2002 at 04:27:41PM -0500, Pascal wrote:
> There are many places in Fred where output is sent to StdErr and
> StdOut.  

Except for cruft (which there shouldn't be any) I don't think this is
true. If it is, then each case is a coding error that should be fixed.

-- 

Oskar Sandberg
[EMAIL PROTECTED]

___
devl mailing list
[EMAIL PROTECTED]
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



Re: [freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Pascal

There are many places in Fred where output is sent to StdErr and
StdOut.  This patch will only catch the specific instance of an
unhandled exception occurring.  I modified Fred's logger some time ago
to redirect StdErr and StdOut to the logfile if they did not exist.  If
this is not happening on your JVM your patch will certainly act as a
workaround, but the preferred solution would be to submit a bug report
to the developers of your JVM.  If System.out.print is called when
StdOut does not exist (such as when running Fred as a service)
System.out.checkError() should return true.  Likewise for StdErr.  This
apparently is not happening on your JVM.  Your patch may cause
exceptions to be logged twice on working JVMs.  Not a huge issue, but
fixing the JVM would obviously be preferable.

-Pascal


Robert Bihlmeyer wrote:
> 
> Hi,
> 
> I'm running Fred as a service in the background, and so won't see
> exceptions that are not logged. The most likely culprits are fatal
> datastore corruptions. All I see is that Fred is no longer running
> after a boot.
> 
> So to get more information, I wrote code to catch unhandled exceptions
> in the main class, and log them. I think it's useful, and applied it
> to the Debian package. Would be fine if you could use this or a
> similar mechanism ... most other exceptions /are/ logged after all.
> 
> Here's the patch:
> 
>   
> 
>_patchName: _patch
>  Type: text/x-patch
> 
>   
> 
> --
> Robbe
> 
>   
>Name: signature.ng
>signature.ngType: application/pgp-signature
>Encoding: 7bit

___
devl mailing list
[EMAIL PROTECTED]
http://hawk.freenetproject.org/cgi-bin/mailman/listinfo/devl



Re: [freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Matthew Toseland

On Sun, Sep 01, 2002 at 09:33:18PM +0200, Robert Bihlmeyer wrote:
> Hi,
> 
> I'm running Fred as a service in the background, and so won't see
> exceptions that are not logged. The most likely culprits are fatal
> datastore corruptions. All I see is that Fred is no longer running
> after a boot.
> 
> So to get more information, I wrote code to catch unhandled exceptions
> in the main class, and log them. I think it's useful, and applied it
> to the Debian package. Would be fine if you could use this or a
> similar mechanism ... most other exceptions /are/ logged after all.
> 
> Here's the patch:
Committed. Thanks.
> 


> 
> -- 
> Robbe
BTW, why does the freenet-unstable DEB use a single JAR file? Maybe you
could arrange a configurable classpath, sourced by the init.d and
fclient, so I can still use fclient even if I want to build from CVS?
Just a thought.




msg03737/pgp0.pgp
Description: PGP signature


[freenet-dev] [patch] logging unhandled exceptions

2002-09-01 Thread Robert Bihlmeyer

Hi,

I'm running Fred as a service in the background, and so won't see
exceptions that are not logged. The most likely culprits are fatal
datastore corruptions. All I see is that Fred is no longer running
after a boot.

So to get more information, I wrote code to catch unhandled exceptions
in the main class, and log them. I think it's useful, and applied it
to the Debian package. Would be fine if you could use this or a
similar mechanism ... most other exceptions /are/ logged after all.

Here's the patch:



diff -Nur freenet-unstable-0.4.3+20020815/src/freenet/node/Main.java freenet-unstable-0.4.3+20020815+/src/freenet/node/Main.java
--- freenet-unstable-0.4.3+20020815/src/freenet/node/Main.java	2002-08-15 17:25:01.0 +0200
+++ freenet-unstable-0.4.3+20020815+/src/freenet/node/Main.java	2002-08-24 15:02:33.0 +0200
@@ -505,6 +505,16 @@
+" to bind to a port < 1024.");
 System.exit(1);
 }
+	catch (Exception e) {
+	ByteArrayOutputStream s = new ByteArrayOutputStream();
+	PrintStream ps = new PrintStream(s);
+	e.printStackTrace(ps);
+	ps.flush();
+	Core.logger.log(Main.class, "Unexpected Exception: "
+			+e.getClass().getName()+"\n"+s.toString(),
+			Logger.ERROR);
+	throw e;
+	}
 finally {
 Core.randSource.close();
 }



-- 
Robbe



signature.ng
Description: PGP signature