From ed51b08c1634b0cd23af784219c069dd6d278075 Mon Sep 17 00:00:00 2001 From: Denis Fedoseev Date: Thu, 21 Feb 2019 23:23:53 +0300 Subject: [PATCH] small fixes --- .gitignore | 4 ++++ .travis.yml | 1 + META.json | 9 ++++++-- README.md | 17 ++++++++++++--- lib/Log/Mini.pm | 50 +++++++++++++++++++++++++++++++++++++++---- t/00_compile.t | 1 + t/01_logger_builder.t | 9 ++++---- 7 files changed, 77 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 92e73b3..16677aa 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,7 @@ cover_db/ MYMETA.* /Log-Mini-* + +Log-Mini.iml +Log-Mini.ipr +Log-Mini.iws \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b43b4e4..30d2d33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,5 @@ perl: - "5.22" - "5.24" - "5.26" + - "5.28" diff --git a/META.json b/META.json index 4a058cc..9ae9a24 100644 --- a/META.json +++ b/META.json @@ -1,5 +1,5 @@ { - "abstract" : "It's new $module", + "abstract" : "It's a very simple logger which can log your messages to a file or STDERR.", "author" : [ "Denis Fedoseev " ], @@ -42,17 +42,22 @@ }, "runtime" : { "requires" : { + "Carp" : "0", + "List::Util" : "0", + "Time::Moment" : "0", "perl" : "5.008001" } }, "test" : { "requires" : { + "Capture::Tiny" : "0", + "Test::Fatal" : "0", "Test::More" : "0.98" } } }, "release_status" : "unstable", - "version" : "0.01", + "version" : "0.0.1", "x_serialization_backend" : "JSON::PP version 2.93", "x_static_install" : 1 } diff --git a/README.md b/README.md index 5036ece..f107ed7 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,29 @@ # NAME -Log::Mini - It's new $module +Log::Mini - It's a very simple logger which can log your messages to a file or STDERR. # SYNOPSIS use Log::Mini; + my $logger = Log::Mini->get_logger(); #STDERR logger used by default + $logger->warn('Very important message'); + + + my $file_logger = Log::Mini->get_logger(file => 'log_file.log'); + $file_logger->info('message to log file'); + + #prevent buffered output. May slow down your application! + my $synced_file_logger = Log::Mini->get_logger(file => 'log_file.log', synced => 1); + # DESCRIPTION -Log::Mini is ... +Log::Mini is a very simple logger which can log your messages to a file or STDERR. +You can have a number of loggers for various log files. # LICENSE -Copyright (C) Denis Fedoseev. +Copyright (C) Denis Fedoseev This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/lib/Log/Mini.pm b/lib/Log/Mini.pm index ada86f1..92efcd2 100644 --- a/lib/Log/Mini.pm +++ b/lib/Log/Mini.pm @@ -3,10 +3,12 @@ package Log::Mini; use strict; use warnings; -use Print3r::Logger::LoggerFILE; -use Print3r::Logger::LoggerSTDERR; +our $VERSION = "0.0.1"; -sub get_logger { +use Log::Mini::LoggerFILE; +use Log::Mini::LoggerSTDERR; + +sub new { my $class = shift; my ( $type, @args ) = @_; @@ -16,7 +18,47 @@ sub get_logger { else { return Log::Mini::LoggerSTDERR->new(@args); } - } 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +Log::Mini - It's a very simple logger which can log your messages to a file or STDERR. + +=head1 SYNOPSIS + + use Log::Mini; + + my $logger = Log::Mini->get_logger(); #STDERR logger used by default + $logger->warn('Very important message'); + + + my $file_logger = Log::Mini->get_logger(file => 'log_file.log'); + $file_logger->info('message to log file'); + + #prevent buffered output. May slow down your application! + my $synced_file_logger = Log::Mini->get_logger(file => 'log_file.log', synced => 1); + + +=head1 DESCRIPTION + +Log::Mini is a very simple logger which can log your messages to a file or STDERR. +You can have a number of loggers for various log files. + +=head1 LICENSE + +Copyright (C) Denis Fedoseev + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=head1 AUTHOR + +Denis Fedoseev diff --git a/t/00_compile.t b/t/00_compile.t index 3b992a9..ca929a2 100644 --- a/t/00_compile.t +++ b/t/00_compile.t @@ -1,3 +1,4 @@ +use lib 'lib'; use strict; use warnings FATAL => 'all'; use Test::More 0.98; diff --git a/t/01_logger_builder.t b/t/01_logger_builder.t index 900e95b..3cddc39 100644 --- a/t/01_logger_builder.t +++ b/t/01_logger_builder.t @@ -7,20 +7,19 @@ use Test::Fatal; use Log::Mini; subtest 'creates stderr logger' => sub { - my $logger = Log::Mini->get_logger('stderr'); + my $logger = Log::Mini->new('stderr'); isa_ok $logger, 'Log::Mini::LoggerSTDERR'; }; subtest 'creates file logger' => sub { - my $logger = Log::Mini->get_logger('file'); + my $logger = Log::Mini->new('file'); isa_ok $logger, 'Log::Mini::LoggerFILE'; }; -subtest 'throws when unknown logger' => sub { - # ok exception { Logger->build('unknown') }; - my $logger = Log::Mini->get_logger('unknown'); +subtest 'return STDERR on unknown logger' => sub { + my $logger = Log::Mini->new('unknown'); isa_ok $logger, 'Log::Mini::LoggerSTDERR'; };