Mercurial > repos > cpt > cpt_psm_plotter
comparison lib/CPT/Logger.pm @ 1:8691c1c61a8e draft default tip
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
| author | cpt |
|---|---|
| date | Mon, 05 Jun 2023 02:48:47 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:54c7a3ea81e2 | 1:8691c1c61a8e |
|---|---|
| 1 package CPT::Logger; | |
| 2 use Moose; | |
| 3 use strict; | |
| 4 use warnings; | |
| 5 use autodie; | |
| 6 | |
| 7 # This will eventually be merged into CPT proper. | |
| 8 | |
| 9 has 'outfile' => ( is => 'ro', isa => 'Str' ); | |
| 10 has 'appid' => ( is => 'ro', isa => 'Str' ); | |
| 11 has 'outfilehandle' => ( is => 'ro', isa => 'FileHandle' ); | |
| 12 | |
| 13 my $fh; | |
| 14 | |
| 15 sub new { | |
| 16 my ( $class, %options ) = @_; | |
| 17 my $self = {%options}; | |
| 18 bless( $self, $class ); | |
| 19 if ( $self->{'outfile'} ) { | |
| 20 open( $fh, '>>', $self->{'outfile'} ); | |
| 21 } | |
| 22 return $self; | |
| 23 } | |
| 24 | |
| 25 sub log { | |
| 26 my ( $self, $message ) = @_; | |
| 27 my @t = localtime; | |
| 28 $t[5] += 1900; | |
| 29 $t[4]++; | |
| 30 my $time = sprintf "%04d-%02d-%02d %02d:%02d:%02d", | |
| 31 @t[ 5, 4, 3, 2, 1, 0 ]; | |
| 32 print $fh "[$time] $message\n"; | |
| 33 } | |
| 34 | |
| 35 no Moose; | |
| 36 1; | |
| 37 | |
| 38 __END__ | |
| 39 | |
| 40 =pod | |
| 41 | |
| 42 =encoding UTF-8 | |
| 43 | |
| 44 =head1 NAME | |
| 45 | |
| 46 CPT::Logger | |
| 47 | |
| 48 =head1 VERSION | |
| 49 | |
| 50 version 1.99.4 | |
| 51 | |
| 52 =head1 AUTHOR | |
| 53 | |
| 54 Eric Rasche <rasche.eric@yandex.ru> | |
| 55 | |
| 56 =head1 COPYRIGHT AND LICENSE | |
| 57 | |
| 58 This software is Copyright (c) 2014 by Eric Rasche. | |
| 59 | |
| 60 This is free software, licensed under: | |
| 61 | |
| 62 The GNU General Public License, Version 3, June 2007 | |
| 63 | |
| 64 =cut |
