use of com.codingchili.core.logging.Logger in project chili-core by codingchili.
the class ConfigurationsTest method testLoadDefaultsFromConfigurable.
@Test
public void testLoadDefaultsFromConfigurable(TestContext test) {
Async async = test.async();
Configurations.setWarnOnDefaultsLoaded(true);
Configurations.initialize(new ContextMock(context) {
@Override
public Logger logger(Class aClass) {
return new ConsoleLogger(aClass) {
@Override
public void onConfigurationDefaultsLoaded(String path, Class<?> clazz) {
if (path.equals(CoreStrings.testFile(CONFIGURATIONS, DEFAULT_JSON))) {
Configurations.reset();
async.complete();
}
}
};
}
});
load(CoreStrings.testFile(CONFIGURATIONS, DEFAULT_JSON), ConfigurableTest.class);
}
use of com.codingchili.core.logging.Logger in project chili-core by codingchili.
the class Service method start.
@Override
public void start(Future<Void> start) {
List<Future> deployments = new ArrayList<>();
for (ListenerSettings listener : context.transports()) {
handler = new RouterHandler(context);
Future<String> future = Future.future();
deployments.add(future);
switch(listener.getType()) {
case UDP:
start(UdpListener::new, listener.getType(), future);
break;
case TCP:
start(TcpListener::new, listener.getType(), future);
break;
case WEBSOCKET:
start(WebsocketListener::new, listener.getType(), future);
break;
case REST:
start(RestListener::new, listener.getType(), future);
break;
}
}
Logger logger = context.logger(getClass());
all(deployments).setHandler(done -> {
// logger.onServiceStarted(this);
start.complete();
});
}
use of com.codingchili.core.logging.Logger in project chili-core by codingchili.
the class ListenerExceptionLogger method create.
/**
* @param core the core context.
* @param listener the listener that the logger is created for.
* @param handler the handler that is attached to the listener.
* @return a logger with metadata which includes information about the handler/listener.
*/
public static Logger create(CoreContext core, CoreListener listener, CoreHandler handler) {
Logger logger = new RemoteLogger(core, handler.getClass());
logger.setMetadataValue(LOG_LISTENER, listener.getClass()::getSimpleName);
return logger;
}
use of com.codingchili.core.logging.Logger in project chili-core by codingchili.
the class SystemContextTest method setUp.
@Before
public void setUp() {
this.settings = Configurations.system();
settings.getMetrics().setRate(100);
settings.getMetrics().setEnabled(true);
this.context = new ContextMock() {
@Override
public Logger logger(Class aClass) {
return new AbstractLogger(getClass()) {
@Override
public void onMetricsSnapshot(JsonObject metrics) {
listener.onMetric(metrics);
}
};
}
@Override
public SystemSettings system() {
return settings;
}
};
}
use of com.codingchili.core.logging.Logger in project chili-core by codingchili.
the class WebsocketListener method listen.
private void listen(Promise<Void> start) {
Router router = Router.router(core.vertx());
router.route().handler(BodyHandler.create().setBodyLimit(settings.getMaxRequestBytes()).setHandleFileUploads(false));
RestHelper.addHeaders(router, settings.isSecure());
router.routeWithRegex(".*").handler(request -> {
// handle all attempts at performing a HTTP request.
request.response().setStatusCode(HttpResponseStatus.ACCEPTED.code()).end(new JsonObject().put(PROTOCOL_STATUS, ResponseStatus.ACCEPTED).put(ID_MESSAGE, CoreStrings.getRestNotSupportedByWebsocketListener()).encodePrettily());
});
var handlerPromise = Promise.<Void>promise();
handlerPromise.future().onSuccess((v) -> {
core.vertx().createHttpServer(settings.getHttpOptions()).exceptionHandler(logger::onError).webSocketHandler(socket -> {
Connection connection = connected(socket);
socket.handler(data -> handle(connection, data));
socket.closeHandler(closed -> connection.runCloseHandlers());
socket.exceptionHandler(logger::onError);
}).requestHandler(router).listen(settings.getPort(), getBindAddress(), listen -> {
if (listen.succeeded()) {
settings.addListenPort(listen.result().actualPort());
} else {
start.fail(listen.cause());
}
});
}).onFailure(start::fail);
handler.start(handlerPromise);
}
Aggregations