Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rex::Logger improvements #848

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/Rex/Logger.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ use warnings;

# VERSION

#use Rex;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(log_debug log_info log_warn log_error);
our %EXPORT_TAGS = (all => [@EXPORT_OK]);

our $no_color = 0;
eval "use Term::ANSIColor";
Expand Down Expand Up @@ -105,7 +108,7 @@ sub init {
$log_opened = 1;
}

sub info {
sub logger {
my ( $msg, $type ) = @_;
my $color = 'green';

Expand Down Expand Up @@ -171,6 +174,15 @@ sub info {
}
}

sub log_error { logger( shift, "error" ) }
sub log_warn { logger( shift, "warn" ) }
sub log_info { logger( shift, "info" ) }
sub log_debug { debug(@_) }

sub error { logger( shift, "error" ) }
sub warn { logger( shift, "warn" ) }
sub info { logger(@_) }

sub debug {
my ($msg) = @_;
return if $silent;
Expand Down