| 1 | package Authen::Simple::Log; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 6 | ▶ | use IO::Handle; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 6 | our $SINGLETON = bless( {}, __PACKAGE__ ); | |||||||||
| 9 | |||||||||||
| 10 | 5 | ▶ | sub new { $SINGLETON } | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 11 | 2 | ▶ | sub debug { } | ||||||||
|
Subroutine
debug: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | 2 | ▶ | sub error { shift->_log( 'error', @_ ) } | ||||||||
|
Subroutine
error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 13 | 2 | ▶ | sub info { } | ||||||||
|
Subroutine
info: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | 2 | ▶ | sub warn { shift->_log( 'warn', @_ ) if $^W } | ||||||||
|
Subroutine
warn: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | 17 | ▶ | sub _caller { | ||||||||
|
Subroutine
_caller: called CC=2 SCAR=6.9
| |||||||||||
| 17 | 17 | my $self = shift; | |||||||||
| 18 | 17 | my $frame = 0; | |||||||||
| 19 | |||||||||||
| 20 | 17 | ▶ | $frame++ until ( caller($frame) ne __PACKAGE__ ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | 17 | return scalar caller($frame); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 17 | ▶ | sub _format { | ||||||||
|
Subroutine
_format: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 17 | my ( $self, $level, @message ) = @_; | |||||||||
| 27 | 17 | return sprintf( "[%s] [%s] [%s] %s\n", scalar localtime(), $level, $self->_caller, "@message" ); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 3 | ▶ | sub _output { | ||||||||
|
Subroutine
_output: called CC=1 SCAR=0.0
| |||||||||||
| 31 | 3 | my $self = shift; | |||||||||
| 32 | 3 | STDERR->print(@_); | |||||||||
| 33 | 3 | STDERR->flush; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 17 | ▶ | sub _log { | ||||||||
|
Subroutine
_log: called CC=1 SCAR=0.0
| |||||||||||
| 37 | 17 | my $self = shift; | |||||||||
| 38 | 17 | my $message = $self->_format(@_); | |||||||||
| 39 | 17 | $self->_output($message); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 6 | 1; | |||||||||
| 43 | |||||||||||
| 44 | __END__ | ||||||||||