| 1 | package XAS::Lib::Modules::Log::Console; | ||
| 2 | |||
| 3 | our $VERSION = '0.01'; | ||
| 4 | |||
| 5 | use Params::Validate 'HASHREF'; | ||
| 6 | use XAS::Class | ||
| 7 | version => $VERSION, | ||
| 8 | base => 'XAS::Base', | ||
| 9 | mixins => 'init_log output destroy', | ||
| 10 | ; | ||
| 11 | |||
| 12 | # ---------------------------------------------------------------------- | ||
| 13 | # Public Methods | ||
| 14 | # ---------------------------------------------------------------------- | ||
| 15 | |||
| 16 | sub output { | ||
| 17 | my $self = shift; | ||
| 18 | |||
| 19 | my ($args) = $self->validate_params(\@_, [ | ||
| 20 | { type => HASHREF } | ||
| 21 | ]); | ||
| 22 | |||
| 23 | warn sprintf("%-5s - %s\n", | ||
| 24 | uc($args->{priority}), | ||
| 25 | $args->{message} | ||
| 26 | ); | ||
| 27 | |||
| 28 | } | ||
| 29 | |||
| 30 | sub destroy { | ||
| 31 | my $self = shift; | ||
| 32 | |||
| 33 | } | ||
| 34 | |||
| 35 | # ---------------------------------------------------------------------- | ||
| 36 | # Private Methods | ||
| 37 | # ---------------------------------------------------------------------- | ||
| 38 | |||
| 39 | sub init_log { | ||
| 40 | my $self = shift; | ||
| 41 | return $self; | ||
| 42 | } | ||
| 43 | |||
| 44 | 1; | ||
| 45 | |||
| 46 | __END__ | ||
| 47 | |||
| 48 | =head1 NAME | ||
| 49 | |||
| 50 | XAS::Lib::Modules::Log::Console - A mixin class for logging | ||
| 51 | |||
| 52 | =head1 DESCRIPTION | ||
| 53 | |||
| 54 | This module is a mixin for logging. It logs to stderr. | ||
| 55 | |||
| 56 | =head1 METHODS | ||
| 57 | |||
| 58 | =head2 init_log | ||
| 59 | |||
| 60 | This method initializes the module. | ||
| 61 | |||
| 62 | =head2 output($hashref) | ||
| 63 | |||
| 64 | The method formats the hashref and writes out the results. | ||
| 65 | |||
| 66 | =head2 destroy | ||
| 67 | |||
| 68 | This methods deinitializes the module. | ||
| 69 | |||
| 70 | =head1 SEE ALSO | ||
| 71 | |||
| 72 | =over 4 | ||
| 73 | |||
| 74 | =item L<XAS|XAS> | ||
| 75 | |||
| 76 | =back | ||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Kevin L. Esteb, E<lt>kevin@kesteb.usE<gt> | ||
| 81 | |||
| 82 | =head1 COPYRIGHT AND LICENSE | ||
| 83 | |||
| 84 | Copyright (C) 2014 Kevin L. Esteb | ||
| 85 | |||
| 86 | This library is free software; you can redistribute it and/or modify | ||
| 87 | it under the same terms as Perl itself, either Perl version 5.8.8 or, | ||
| 88 | at your option, any later version of Perl 5 you may have available. | ||
| 89 | |||
| 90 | See L<http://dev.perl.org/licenses/> for more information. | ||
| 91 | |||
| 92 | =cut |