| 1 | package Dezi::Stats::File; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 1 | ▶ | use base 'Dezi::Stats'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use Log::Dispatchouli; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use JSON; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 1 | our $VERSION = '0.001006'; | |||||||||||
| 11 | |||||||||||||
| 12 | =head1 NAME | ||||||||||||
| 13 | |||||||||||||
| 14 | Dezi::Stats::File - store Dezi statistics via Log::Dispatchouli | ||||||||||||
| 15 | |||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||
| 17 | |||||||||||||
| 18 | # see Dezi::Stats | ||||||||||||
| 19 | |||||||||||||
| 20 | =head1 DESCRIPTION | ||||||||||||
| 21 | |||||||||||||
| 22 | Dezi::Stats::File logs statistics using Log::Dispatchouli. | ||||||||||||
| 23 | |||||||||||||
| 24 | =head1 METHODS | ||||||||||||
| 25 | |||||||||||||
| 26 | =head2 init_store() | ||||||||||||
| 27 | |||||||||||||
| 28 | Required method. Initializes the internal Log::Dispatchouli object. | ||||||||||||
| 29 | You can pass any params supported by Log::Dispatchouli->new() | ||||||||||||
| 30 | directly to Dezi::Stats->new(). | ||||||||||||
| 31 | |||||||||||||
| 32 | =cut | ||||||||||||
| 33 | |||||||||||||
| 34 | 1 | ▶ | sub init_store { | ||||||||||
|
Subroutine
init_store: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||
| 35 | 1 | my $self = shift; | |||||||||||
| 36 | 1 | ▶ | my $path = delete $self->{path} or croak "path required"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | 1 | my %args = %$self; | |||||||||||
| 38 | 1 | ▶ | $args{ident} ||= 'dezi-stats'; | ||||||||||
|
Condition50%1/2
$args{"ident"} ||= "dezi-stats"
MC/DC0%0/1
$args{"ident"} ||= "dezi-stats"
$args{"ident"}
Truth table50%1/2
A
A= $args{"ident"}
| |||||||||||||
| 39 | |||||||||||||
| 40 | # TODO filter out any that LD doesn't support | ||||||||||||
| 41 | 1 | $self->{dispatcher} = Log::Dispatchouli->new( \%args, ); | |||||||||||
| 42 | 1 | return $self; | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | =head2 dispatcher | ||||||||||||
| 46 | |||||||||||||
| 47 | Returns the internal Log::Dispatchouli object. | ||||||||||||
| 48 | |||||||||||||
| 49 | =cut | ||||||||||||
| 50 | |||||||||||||
| 51 | 1 | ▶ | sub dispatcher { | ||||||||||
|
Subroutine
dispatcher: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 52 | 1 | my $self = shift; | |||||||||||
| 53 | 1 | return $self->{dispatcher}; | |||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | =head2 insert( I<hashref> ) | ||||||||||||
| 57 | |||||||||||||
| 58 | Writes I<hashref> encoded as JSON to the dispatcher()->log method. | ||||||||||||
| 59 | |||||||||||||
| 60 | =cut | ||||||||||||
| 61 | |||||||||||||
| 62 | 1 | ▶ | sub insert { | ||||||||||
|
Subroutine
insert: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 63 | 1 | my $self = shift; | |||||||||||
| 64 | 1 | ▶ | my $row = shift or croak "hashref required"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 65 | 1 | $self->{dispatcher}->log( encode_json($row) ); | |||||||||||
| 66 | 1 | return $row; | |||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | 1 | 1; | |||||||||||
| 70 | |||||||||||||
| 71 | __END__ | ||||||||||||