Skip to content

Commit

Permalink
better logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Atomic-Laboratory committed Apr 16, 2024
1 parent ac9e35e commit d23f99c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Argon/Argon.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Argon extends Plugin {
try {
channel = connection.createChannel();
} catch (IOException e) {
throw new RuntimeException(e);
Log.err(e);
}
Log.debug("Argon: Firing RegisterRabbitQueues");
Events.fire(new RegisterArgonEvents());
Expand Down Expand Up @@ -148,7 +148,7 @@ private static String getQueueName(String name, boolean exchange) {
channel.queueDeclare(name, false, false, false, null);
queuesDeclared.add(name);
} catch (IOException e) {
throw new RuntimeException(e);
Log.err(e);
}
}
return name;
Expand All @@ -164,7 +164,7 @@ public static <T> void on(Class<T> type, Cons<T> listener) {
String queueName = getQueueName(type.getSimpleName(), exchange);//gets, or declares new queue and returns proper name
try {
channel.basicConsume(queueName, true, (consumerTag, delivery) -> {//queue listener
Log.debug("Argon: Received Data on RabbitMQ Queue @", queueName);
Log.debug("Argon: Received Data on RabbitMQ Queue @", type.getSimpleName());
Log.debug(new String(delivery.getBody()));
//deserialize body to proper class
T receivedData = objectMapper.readValue(delivery.getBody(), type);
Expand All @@ -178,7 +178,7 @@ public static <T> void on(Class<T> type, Cons<T> listener) {
}, ignored -> {
});
} catch (IOException e) {
throw new RuntimeException(e);
Log.err(e);
}
return new Seq<>(Cons.class);
}).add(listener);//get listener seq and add this listener
Expand All @@ -201,7 +201,7 @@ public static <T> void fire(T event) {
channel.basicPublish("", name, null, serializedData);
}
} catch (IOException e) {
throw new RuntimeException(e);
Log.err(e);
}
}

Expand All @@ -224,7 +224,7 @@ private static Connection createConnectionWithRetry(ConnectionFactory factory) {
Thread.sleep(delay);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new RuntimeException("Thread interrupted while waiting to reconnect.");
Log.err(new RuntimeException("Thread interrupted while waiting to reconnect."));
}
}
}
Expand Down

0 comments on commit d23f99c

Please sign in to comment.