[Chicago-talk] writing a log with Cron, Daemons, Perl

Jay Strauss me at heyjay.com
Sat Sep 6 15:51:20 CDT 2003


thanks Paul,

I think that will work, I've been away from my computer for the last day.
I'm going to try it tonight after I finish painting the baby's room

Jay
----- Original Message -----
From: "Paul Baker" <pbaker at where2getit.com>
To: "Chicago.pm chatter" <chicago-talk at mail.pm.org>
Sent: Friday, September 05, 2003 2:53 PM
Subject: Re: [Chicago-talk] writing a log with Cron, Daemons, Perl



On Friday, September 5, 2003, at 09:50  AM, Jay Strauss wrote:

> I'd like to have a log file that contains everything that would
> normally go
> to STDERR plus all the messages my program spits out.
>
> I'm running into a couple of problems:
>
> 1) how do I get stuff into my log file without closing the file
> handle?  I
> tried $|++;  For example:
>
> use Net::Server::Daemonize qw(daemonize);
> daemonize ("jstrauss","jstrauss","/home/jstrauss/test.pid");
> open (LOG,">/home/jstrauss/bin/test.log");
> print LOG "Help\n";
> while (1) {
> }
>
> my message never gets printed to the file.
>
> [snip]

The other replies are total overkill for what you are trying to do.
Jay, from what I can tell you just want everything that would normally
go to STDERR to be written to a log, instead of being lost in oblivion
right? Real simple. Your code above is very close, just replace LOG
with STDERR. This will reopen the file as STDERR and everything that
normally writes to STDERR will go to that file instead. Piece of cake.

  use Net::Server::Daemonize qw(daemonize);
  daemonize ("jstrauss","jstrauss","/home/jstrauss/test.pid");
  open (STDERR,">/home/jstrauss/bin/test.log");
  print STDERR "Help\n";
  while (1) {
    die "this will go to STDERR too!";
  }


--
Paul Baker

"Yes, we did produce a near-perfect republic. But will they keep it? Or
will they, in the enjoyment of plenty, lose the memory of freedom?”
          -- Thomas Jefferson in a letter to John Adams

GPG Key: http://homepage.mac.com/pauljbaker/public.asc


_______________________________________________
Chicago-talk mailing list
Chicago-talk at mail.pm.org
http://mail.pm.org/mailman/listinfo/chicago-talk






More information about the Chicago-talk mailing list