Log::UDP::Client - a simple way to send structured log messages via UDP
Version 0.01
use Log::UDP::Client; # Send the simple scalar to the server Log::UDP::Client->new->send("Hi"); # Log lots of messages my $logger = Log::UDP::Client->new(server_port => 15000); my $counter=0; while(++$counter) { $logger->send($counter); last if $counter >= 1000; } # Send some debugging info $logger->send({ pid => $$, program => $0, args => \@ARGV, }); # Use of JSON serializer my $logger = Log::UDP::Client->new( serializer_module => 'JSON' ); # Will emit { "message" => "Hi" } because JSON want to wrap stuff into a hashref $logger->send("Hi"); # Use of custom serializer use Storable qw(freeze); my $logger = Log::UDP::Client->new ( serializer => sub { return nfreeze( \( $_[0] ) ); }, );
This module enables you to send a message (simple string or complicated object) over an UDP socket to a listening server. The message will be encoded with a serializer module (default is Storable).
This is an object-oriented module. It has no exports.
IP address or hostname for the server you want to send the messages to. This field can be changed after instantiation. Default is 127.0.0.1.
Port for the server you plan to send the messages to. This field can be changed after instantiation. Default is port 9999.
If errors are encountered, should we throw exception or just return? Default is return. Set to true for exceptions. You can change this flag after instantiation.
Read-only field that contains the socket used to send the messages.
Instance method that actually encodes and transmits the specified message over UDP to the listening server. Will die if throw_exception is set to true and some kind of transmission error occurs. The message will be serialized by the instance-defined serializer. Returns true on success.
All of these methods are inherited from Data::Serializable. Read more about them there.
Robin Smidsrød, <robin at smidsrod.no>
<robin at smidsrod.no>
Please report any bugs or feature requests to bug-log-udp at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Log-UDP-Client. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-log-udp at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Log::UDP::Client
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-UDP-Client
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Log-UDP-Client
CPAN Ratings
http://cpanratings.perl.org/d/Log-UDP-Client
Search CPAN
http://search.cpan.org/dist/Log-UDP-Client/
Moose, Storable, JSON::XS, IO::Socket::INET
Copyright 2009 Robin Smidsrød.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Smidsrød,'. Assuming UTF-8
To install Log::UDP::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::UDP::Client
CPAN shell
perl -MCPAN -e shell install Log::UDP::Client
For more information on module installation, please visit the detailed CPAN module installation guide.