1package Ubic::Logger; 2{ 3 $Ubic::Logger::VERSION = '1.58'; 4} 5 6use strict; 7use warnings; 8 9# ABSTRACT: very simple logging functions 10 11 12use Term::ANSIColor qw(:constants); 13$Term::ANSIColor::AUTORESET = 1; 14 15use parent qw(Exporter); 16our @EXPORT = qw( INFO ERROR ); 17 18sub INFO { 19 print '[', scalar(localtime), "]\t", @_, "\n"; 20} 21 22sub ERROR { 23 my @message = ('[', scalar(localtime), "]\t", @_, "\n"); 24 if (-t STDOUT) { 25 print RED(@message); 26 } 27 else { 28 print @message; 29 } 30} 31 32 331; 34 35__END__ 36 37=pod 38 39=head1 NAME 40 41Ubic::Logger - very simple logging functions 42 43=head1 VERSION 44 45version 1.58 46 47=head1 SYNOPSIS 48 49 use Ubic::Logger; 50 INFO("hello"); 51 ERROR("Fire! Fire!"); 52 53=head1 FUNCTIONS 54 55=over 56 57=item B<INFO(@data)> 58 59Log something. 60 61=item B<ERROR(@data)> 62 63Log some error. 64 65Message will be red if writing to terminal. 66 67=back 68 69=head1 AUTHOR 70 71Vyacheslav Matyukhin <mmcleric@yandex-team.ru> 72 73=head1 COPYRIGHT AND LICENSE 74 75This software is copyright (c) 2015 by Yandex LLC. 76 77This is free software; you can redistribute it and/or modify it under 78the same terms as the Perl 5 programming language system itself. 79 80=cut 81