[26033] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8241 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 11 10:32:47 2005

Date: Sun, 10 Jul 2005 21:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 10 Jul 2005     Volume: 10 Number: 8241

Today's topics:
        Custom message formatting callback for Log::Dispatch <Cpp@subclassed.net>
    Re: error 400 url must be absolut <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Problems understanding and implementing process man <tadmc@augustmail.com>
    Re: Problems understanding and implementing process man <amheiserbush@yahoo.com.au>
    Re: Problems understanding and implementing process man <amheiserbush@yahoo.com.au>
        toast <tester@test.te>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 11 Jul 2005 01:24:40 GMT
From: Dan <Cpp@subclassed.net>
Subject: Custom message formatting callback for Log::Dispatch
Message-Id: <89i3d15qvmr975i1hon02qo8n2c6oplbck@4ax.com>

I want to set up Log::Dispatch with two outputs... "file" and "email".
I'd like to use a callback function to do custom formatting of the
message based on whether the output is going to a logfile or email.

I.E. a one line entry if sent to logfile and a verbose description,
possibly including html, hyperlinks, etc if sent by email.

I figured since the log method supports sending arbitrary named pairs
to the callback function, all I needed to do was get the name of the
Dispatch object doing the logging, and have the callback do the
necessary formatting based on the destination, but getting the name of
the Dispatch object is proving to be beyond my very measly perl
programming skills!

Any help would be greatly appreciated!

Thanks,
-Dan

daf@mapson.ninemoons.com
(remove reverse("nospam") to reply via email.) Spambots are getting
waaay too smart nowadays! 


======================
Sample code follows:  
======================

#!/usr/local/bin/perl -w

use Log::Dispatch;
use Log::Dispatch::Email::MailSend;
use Log::Dispatch::File;
use Data::Dumper;

$sub = sub { my %p = @_;  
             ##############################################
             # if $p{type} == "email" do some formatting on
$p{message};
             # else do something else... or maybe nothing ;-P
             ##############################################
             print Dumper(\%p);
             return $p{message}; 
           };

$dispatcher = Log::Dispatch->new( callbacks => $sub);

$dispatcher->add( Log::Dispatch::File->new( name => 'file1',
                 min_level => 'debug',
                 mode => 'append',
                 filename => 'logfile' ) );

$dispatcher->add( Log::Dispatch::Email::MailSend->new( name =>
'email',
                 min_level => 'error',
                 to => [ qw( foo@bar.com bar@baz.org ) ],
                 subject => 'Oh no!!!!!!!!!!!') );

#################################################################
# Need "type" to automatically reflect dispatcher->outputs->name...
#################################################################
$dispatcher->log( level => 'error', message => "ERROR level logging
test\n", type=>"???" );
  
print Dumper(\$dispatcher);

#EOF



------------------------------

Date: Sun, 10 Jul 2005 20:06:33 +0200
From: Mark <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: error 400 url must be absolut
Message-Id: <42d163ab$0$25026$8fcfb975@news.wanadoo.fr>

Alexandre Jaquet > wrote:
> Alexandre Jaquet > a écrit :
> 
>> Hi,
>>
>> With my following script I got this error and didn't know why.
>>
>> Here is my script :
>>
>> #!perl -w
>>   use LWP::UserAgent;
>>   use LWP::Simple;
>>
>>   my $server = 'http://www.hardstyle-force.ch/phpBB2/index.php';
>>

<snip>
> 
> 
> I founded :  my $response = $ua->get('$server');
> 
> but now I get 501 Protocol scheme '' is not supported...
single quotes do not interpolate. You probably need


my $response = $ua->get($server);

(remove the single quotes)


------------------------------

Date: Sun, 10 Jul 2005 11:14:47 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Problems understanding and implementing process management
Message-Id: <slrndd2ibn.crs.tadmc@magna.augustmail.com>

James Calivar <amheiserbush@yahoo.com.au> wrote:
>> 
>> Then, it is not clear at first sight, what is causing these problems. 
>> Then, after some time, I realized the long, vanity comments. At that 
>> point, I had no more motivation to try anything.
>> 
>> I am glad Ala was able to help you (and I learned something from his 
>> post). But the next time, I won't even see your post.
>> 
>> Sinan
>> 
> 
> ??? You're *killfiling me* because I had a comment line that exceeded 80 
> lines ???  


No, the "disease" is that you did not make it easy for us to help you.

The "symptom" was posting code that we could not copy/paste and run.

The line-wrapping of the overly long comments (probably done by your
news posting client) made the code not even compile, let alone run.


> For the record, my perl executable didn't puke on this.  


Then your "this" is not our "this".

We don't have your code. All we have is the code you showed us.

Have you tried running the actual code that you showed us? (rhetorical question)


> I guess ActiveState''s perl is at 
> least smart enough to know that a comment should be treated as such.


You sure look silly now.


> Thanks for not helping,


Glad to join in and oblige.

*plonk*


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 11 Jul 2005 00:47:03 GMT
From: James Calivar <amheiserbush@yahoo.com.au>
Subject: Re: Problems understanding and implementing process management
Message-Id: <bkjAe.20868$eM6.12922@newsread3.news.atl.earthlink.net>

Joe Smith wrote:
> James Calivar wrote:
> 
>> because I had a comment line that exceeded 80 lines ???  For the 
>> record, my perl executable didn't puke on this.
> 
> 
> Have you actually tested that?  To properly test it, you'll need to
> have to the code as we received it, which is different from what
> you started with.
> 
> Go back to
>    Date: Fri, 8 Jul 2005 15:36:31 -0400
>    Message-ID: <damkjv$k5k$1@home.itg.ti.com>
> select the text and copy-and-paste it into a new file.  Then check
> to see if your perl executable barfs on that.
> 
> I expect that you'll see the same thing we see: overly long comments
> got mangled by the trip to USENET and back.  If you can't get
> the program to work after copy-and-paste, neither can we.
>     -Joe

It showed up and tested out OK on my PC's news reader - (what, are you 
guys using a news client written in Perl or something?)  :-)  But I see 
what you are saying now.  However, I feel that it's pretty harsh for 
whatever his name is to killfile me for that.  A simple transgression, 
particularly in this day and age of more-than-text news readers.

Anyway, the bottom line is that I think that I HAVE to use fork() 
instead of any other method in order to be able to track and kill my 
child process,  system(), piped proceses (using open()), etc. won't cut 
the mustard.  I've entered a bug report on ActiveState's database to see 
if they can help.

Later

James


------------------------------

Date: Mon, 11 Jul 2005 00:48:35 GMT
From: James Calivar <amheiserbush@yahoo.com.au>
Subject: Re: Problems understanding and implementing process management
Message-Id: <DljAe.20869$eM6.13789@newsread3.news.atl.earthlink.net>

Tad McClellan wrote:
> 
> 
> 
> Glad to join in and oblige.
> 
> *plonk*
> 
> 

Christ you people sure are intolerant.  Enjoy your limited view of the 
Perl world, fucktard.

James


------------------------------

Date: 11 Jul 2005 02:18:48 GMT
From: tester <tester@test.te>
Subject: toast
Message-Id: <dasku8$qrb$2@eeyore.INS.cwru.edu>

if ( $c=~/t[aeiou]st[aeiou]/i) {print STDOUT "A toast to my test about testes which took testicles to post\n";} 




------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8241
***************************************


home help back first fref pref prev next nref lref last post