| 1 | 1 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package PerlIO::via::ToFirePHP; | ||||||||||
| 6 | 1 | our $VERSION = '1.100860'; | |||||||||
| 7 | # ABSTRACT: log to FirePHP via an PerlIO layer | ||||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub PUSHED { | ||||||||
|
Subroutine
PUSHED: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 10 | 0 | my ($class, $mode, $fh) = @_; | |||||||||
| 11 | 0 | ▶ | return -1 unless $mode eq 'w'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 0 | bless { buf => '', }, $class; | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub OPEN { | ||||||||
|
Subroutine
OPEN: not called CC=1 SCAR=6.9
| |||||||||||
| 16 | 0 | my ($self, $path, $mode, $fh) = @_; | |||||||||
| 17 | |||||||||||
| 18 | # $path is actually our FirePHP::Dispatcher object | ||||||||||
| 19 | 0 | $self->{fire_php} = $path; | |||||||||
| 20 | 0 | 1; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | 0 | ▶ | sub WRITE { | ||||||||
|
Subroutine
WRITE: not called CC=2 SCAR=17.9
| |||||||||||
| 24 | 0 | my ($self, $buf, $fh) = @_; | |||||||||
| 25 | |||||||||||
| 26 | # accumulate whole lines before logging | ||||||||||
| 27 | 0 | $self->{buf} .= $buf; | |||||||||
| 28 | 0 | ▶ | if ($self->{buf} =~ tr/\n//) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 0 | $self->{fire_php}->log($self->{buf}); | |||||||||
| 30 | |||||||||||
| 31 | # finalize now in case CLOSE() doesn't get called; it's idempotent | ||||||||||
| 32 | 0 | $self->{fire_php}->finalize; | |||||||||
| 33 | 0 | $self->{buf} = ''; | |||||||||
| 34 | } | ||||||||||
| 35 | 0 | length $buf; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ▶ | sub CLOSE { | ||||||||
|
Subroutine
CLOSE: not called CC=1 SCAR=6.9
| |||||||||||
| 39 | 0 | my $self = shift; | |||||||||
| 40 | 0 | $self->{fire_php}->finalize; | |||||||||
| 41 | 0 | 0; | |||||||||
| 42 | } | ||||||||||
| 43 | 1 | 1; | |||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||