123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package htlogr;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- use HTTP::Lite;
- use URI::Escape;
- use Carp;
-
- sub new {
- my ($class, $opts) = @_;
- my $self = {};
-
- foreach (qw/ path /) {
- $self->{$_} = $opts->{$_} or croak("missing mandatory option: $_");
- }
-
- $self->{http} = HTTP::Lite->new;
-
- return bless $self, $class;
- }
-
- sub log {
- my $self = shift;
- my $msg = shift;
- my $tag = shift;
- my $uri;
- $uri .= $self->{path};
- $uri .= "?msg=" . uri_escape($msg);
- $uri .= "&tag=" . uri_escape($tag) if $tag;
- $self->{http}->request($uri) or croak("could not htlog message: $!");
- return $self->{http}->body();
- }
-
- 1;
|