A logging and event timing framework for clustered or distributed systems
PaulBunyan4J uses protobuf messages over a UDP socket to distribute messages from different applications on the same network so the information can be displayed and managed from a single application. Making it possible to create a dashboard that shows the state of multiple applications or multiple clusters.
-
Install the Guice Module
install(new LoggingCentralModule(9876, "LoggingServer", "hostname"));
-
Install the Guice Module
install(new LoggingClientModule("10.10.1.1", 9876, "LoggingClient", "hostname"));
Code on both the central and remote clients can be annotated with @LoggableEvent annotations and the label for the event can be overridden in the annotation.
@LoggableEvent
public String performAction(? arg0, ? arg1) {
...
}
@LoggableEvent("NewEventLabel")
public String performOtherAction(? arg0, ? arg1) {
...
}
If you are running a multiuser enviroment (i.e. hosting webservices) and you want each specific username attached to the event you can either:
-
Set a username provider in the annotation
@LoggableEvent(subjectProvider=NewSubjectProvider.class) public String performAction(? arg0, ? arg1) { ... }
-
Change the default provider
install(Modules.override(new LoggingCentralModule(...)).with(new AbstractModule() { @Override protected void configure() { bind(LoggingClient.SubjectProvider.class).to(NewSubjectProvider.class); } }));
If you want to override more specific attributes or don't want to use annotations
-
Get a reference to the log sender
@Inject LoggingClient.LoggingSender logger;
-
Wrap your executing code in a wrapper
public String performAction(? arg0, ? arg1) { return logger.createWrapper() .setApplicationName("OverrideName") .setEventName("EventName") .setUsername("executor's username") .execute(new TimedWrapper() { @Override public String execute() throws Throwable { //TODO Do some work in here a return it return "OK"; } }); }
If you want full control over the message you can
-
Get a reference to the log sender
@Inject LoggingClient.LoggingSender logger;
-
Build a protobuf message
LoggingMessage msg = LoggingMessage.newBuilder() .... .build();
-
Send it
logger.send(msg);