Common.pm 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # 2022 - 2024 https://://www.bananas-playground.net/projekt/aranea
  2. # This program is free software: you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation, either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
  14. package Aranea::Common;
  15. use 5.20.0;
  16. use strict;
  17. use warnings;
  18. use utf8;
  19. use Term::ANSIColor qw(:constants);
  20. use DateTime;
  21. use Exporter qw(import);
  22. our @EXPORT_OK = qw(sayLog sayYellow sayGreen sayRed);
  23. sub sayLog {
  24. my ($string) = @_;
  25. my $dt = DateTime->now;
  26. say "[".$dt->datetime."] DEBUG: ".$string;
  27. }
  28. sub sayYellow {
  29. my ($string) = @_;
  30. my $dt = DateTime->now;
  31. say CLEAR,YELLOW, "[".$dt->datetime."] ".$string, RESET;
  32. }
  33. sub sayGreen {
  34. my ($string) = @_;
  35. my $dt = DateTime->now;
  36. say CLEAR,GREEN, "[".$dt->datetime."] ".$string, RESET;
  37. }
  38. sub sayRed {
  39. my ($string) = @_;
  40. my $dt = DateTime->now;
  41. say BOLD, RED, "[".$dt->datetime."] ".$string, RESET;
  42. }
  43. 1;