| 1 | ########################################################################### | ||
| 2 | # | ||
| 3 | # Channel.pm | ||
| 4 | # | ||
| 5 | # Copyright (C) 1999 Raphael Manfredi. | ||
| 6 | # Copyright (C) 2002-2017 Mark Rogaski, mrogaski@cpan.org; | ||
| 7 | # all rights reserved. | ||
| 8 | # | ||
| 9 | # See the README file included with the | ||
| 10 | # distribution for license information. | ||
| 11 | # | ||
| 12 | ########################################################################## | ||
| 13 | |||
| 14 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | |||
| 16 | ######################################################################## | ||
| 17 | package Log::Agent::Channel; | ||
| 18 | |||
| 19 | # | ||
| 20 | # Ancestor for all Log::Agent logging channels. | ||
| 21 | # | ||
| 22 | |||
| 23 | # | ||
| 24 | # is_deferred | ||
| 25 | # | ||
| 26 | # Report routine as being deferred | ||
| 27 | # | ||
| 28 | 0 | ▶ | sub is_deferred { |
|
Subroutine
is_deferred: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 29 | 0 | require Carp; | |
| 30 | 0 | Carp::confess("deferred"); | |
| 31 | } | ||
| 32 | |||
| 33 | # | ||
| 34 | # ->make -- deferred | ||
| 35 | # | ||
| 36 | # Creation routine. | ||
| 37 | # | ||
| 38 | 0 | ▶ | sub make { |
|
Subroutine
make: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 39 | 0 | &is_deferred; | |
| 40 | } | ||
| 41 | |||
| 42 | # | ||
| 43 | # ->write_fn -- frozen | ||
| 44 | # | ||
| 45 | # Message is a CODE ref, call routine to generate it, then perform write. | ||
| 46 | # Extra arguments after CODE ref are passed back to the routine. | ||
| 47 | # | ||
| 48 | 0 | ▶ | sub write_fn { |
|
Subroutine
write_fn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 49 | 0 | my $self = shift; | |
| 50 | 0 | my ($priority, $fn) = splice(@_, 0, 2); | |
| 51 | 0 | my $msg = &$fn(@_); | |
| 52 | 0 | $self->write($priority, $msg); | |
| 53 | } | ||
| 54 | |||
| 55 | # | ||
| 56 | # ->write -- deferred | ||
| 57 | # | ||
| 58 | # Physical writing of the message with the said priority. | ||
| 59 | # | ||
| 60 | 0 | ▶ | sub write { |
|
Subroutine
write: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 61 | 0 | my $self = shift; | |
| 62 | 0 | my ($priority, $msg) = @_; | |
| 63 | 0 | &is_deferred; | |
| 64 | } | ||
| 65 | |||
| 66 | # | ||
| 67 | # ->close -- deferred | ||
| 68 | # | ||
| 69 | 0 | ▶ | sub close { |
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 70 | 0 | my $self = shift; | |
| 71 | 0 | &is_deferred; | |
| 72 | } | ||
| 73 | |||
| 74 | 8 | 1; # for require | |
| 75 | __END__ | ||