| Log-Dispatch-Jabber documentation | view source | Contained in the Log-Dispatch-Jabber distribution. |
Log::Dispatch::Jabber - Log messages via Jabber
use Log::Dispatch;
use Log::Dispatch::Jabber;
my $dispatcher = Log::Dispatch->new();
my $jabber = Log::Dispatch::Jabber->new(
name=>"jabber",
min_level=>"debug",
login=>{
hostname => "some.jabber.server",
port => 5222,
username => "logger",
password => "*****",
resource => "logger",
},
to=>["webmaster\@a.jabber.server",chief_honco\@a.jabber.server"],
check_presence=>1,
# Send a message to this address even if their
# presence indicates they are not available.
force=>"webmaster\@a.jabber.server",
# Buffer 5 messages before sending.
buffer => "5",
);
$dispatcher->add($jabber);
$dispatcher->log(
level => 'debug',
message => 'Hello. Programmer. This is '.ref($jabber)
);
Log messages via Jabber.
All internal errors that the package encounters connecting to or authenticating with the Jabber server are logged to STDERR via Log::Dispatch::Screen.
Valid arguments are
Returns an object.
This package inherits from Log::Dispatch::Output.
Please consult the docs for details.
0.3
November 25, 2002
Aaron Straup Cope
sub _send {
my $self = shift;
my $im = Jabber::NodeFactory->newNode("message");
$im->insertTag('body')->data(...);
# Where &_connect() and &_disconnect()
# are simply wrapper methods that DWIM
# $self->_connect();
# The above works great except that only
# the first address in $self->{'__to'}
# ever receives any messages
# This would be my preferred way of doing
# things since there's no point in creating
# a gazillion connetions - unless I've spaced
# on some important Jabber fundamentals....
foreach my $addr (@{$self->{'__to'}}) {
$im->attr("to",$addr);
$self->_connect();
# The above works so long as not too many
# messages are sent in rapid succession
# Log::Dispatch::Jabber has hooks to
# buffer messages but if I send (4)
# successive notices with nothing in
# between, the server I'm testing against
# (and out-of-the-box FreeBSD port) starts
# to carp with 'is being connection rate limited'
# errors after the third notice.
# I suppose I could sleep(n) but that seems
# like sort of rude behaviour for a log thingy.
# Happy happy
$self->{'__client'}->send($im);
$self->_disconnect();
}
# $self->_disconnect() }
Please report all bugs to http://rt.cpan.org/NoAuth/Dists.html?Queue=Log::Dispatch::Jabber
Copyright (c) 2002, Aaron Straup Cope. All Rights Reserved.
This is free software, you may use it and distribute it under the same terms as Perl itself.
| Log-Dispatch-Jabber documentation | view source | Contained in the Log-Dispatch-Jabber distribution. |