aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/Core
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MasterServer/Core')
-rwxr-xr-xlib/MasterServer/Core/Logging.pm41
1 files changed, 40 insertions, 1 deletions
diff --git a/lib/MasterServer/Core/Logging.pm b/lib/MasterServer/Core/Logging.pm
index 5aaf683..e8631de 100755
--- a/lib/MasterServer/Core/Logging.pm
+++ b/lib/MasterServer/Core/Logging.pm
@@ -3,10 +3,49 @@ package MasterServer::Core::Logging;
use strict;
use warnings;
+use Switch;
use POSIX qw/strftime/;
use Exporter 'import';
-our @EXPORT = qw| log |;
+our @EXPORT = qw| log error |;
+
+################################################################################
+## Split up errors in multiple log types for suppressing
+## args: $self, message
+################################################################################
+sub error {
+ my ($self, $error, $instigator) = @_;
+
+ # which error?
+ switch ($error) {
+
+ # connection timed out
+ case m/Connection timed out/i {
+ $self->log("timeout", "on $instigator.");
+ }
+
+ # connection reset by peer
+ case m/Connection reset by peer/i {
+ $self->log("reset", "on $instigator.");
+ }
+
+ # connection refused
+ case m/Connection refused/i {
+ $self->log("refused", "on $instigator.");
+ }
+
+ # no such device or address
+ case m/No such device or address/i {
+ $self->log("nodevice", "on $instigator.");
+ }
+
+ # if all else fails
+ else {
+ $self->log("error", "$error on $instigator.");
+ }
+ }
+}
+
################################################################################
## Log to file and print to screen.