Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > logging and daemons

Reply
Thread Tools

logging and daemons

 
 
Fernando M. Maresca
Guest
Posts: n/a
 
      02-16-2009

Hello.

I'm in the process of replacing a custom logger class in one of my apps
that has several daemons. In the last step of daemonizing a program,
after closing fds, stderr and stdout are redirected to the logfile of
the program.

Now, I'm trying to use TimedRotatingFileHandler as the only channel when
the programs run in daemon mode. My problem is: I can't see a goog way
to redirect stderr/stdout both to the logger.

Note that I don't have any print statements in any of my code, but I
can't be sure about all the modules I'm importing, and I like to get any
uncached exception info that may go to stderr/stdout to show up in the
logfiles.

Any ideas?
Thanks a lot,

--
Fernando

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkmZY84ACgkQCtDmpVXdEMbwLQCfewl3PUrGvT 1tkywj3LExUBUd
SjsAn0pdBXgShSy/PV1V6is65HP0IWSC
=gG12
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      02-16-2009
Fernando M. Maresca schrieb:
> Hello.
>
> I'm in the process of replacing a custom logger class in one of my apps
> that has several daemons. In the last step of daemonizing a program,
> after closing fds, stderr and stdout are redirected to the logfile of
> the program.
>
> Now, I'm trying to use TimedRotatingFileHandler as the only channel when
> the programs run in daemon mode. My problem is: I can't see a goog way
> to redirect stderr/stdout both to the logger.
>
> Note that I don't have any print statements in any of my code, but I
> can't be sure about all the modules I'm importing, and I like to get any
> uncached exception info that may go to stderr/stdout to show up in the
> logfiles.


why don't you just replace the sys.stdout/sys.stdin objects with
something that is file-like (supports a write-method, that should be
enough in this case), and then simply write the data arriving to the
logger instance of your trust.

If other modules don't get overly tricky to bypass sys.stdout, that
should capture all you output, regardless of the file descriptor issues.

In the end, if a 3rd-party-module choses to open a filedescriptor itself
& write to that, there is nothing you can do about that. But usually,
they don't behave that way.

Diez
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Daemons and Paths Davertron Ruby 3 03-16-2009 12:48 PM
Re: logging and daemons Fernando M. Maresca Python 2 02-16-2009 07:19 PM
Python, Daemons and D-Bus PurpleServerMonkey Python 3 05-25-2008 11:40 AM
Threads and daemons Cd Cd Ruby 7 09-12-2007 05:20 AM
about daemons and IPC sdistefano@gmail.com Python 4 08-29-2006 05:36 PM



Advertisments