use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.
the class HttpStatusItemTest method initStrBuilder.
@Before
public void initStrBuilder() {
routingContext = Mockito.mock(RoutingContext.class);
finishEvent = Mockito.mock(InvocationFinishEvent.class);
response = Mockito.mock(Response.class);
serverResponse = Mockito.mock(HttpServerResponse.class);
accessLogEvent = new ServerAccessLogEvent();
accessLogEvent.setRoutingContext(routingContext);
strBuilder = new StringBuilder();
}
use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.
the class PlainTextItemTest method initStrBuilder.
@Before
public void initStrBuilder() {
accessLogEvent = new ServerAccessLogEvent();
finishEvent = Mockito.mock(InvocationFinishEvent.class);
strBuilder = new StringBuilder();
}
use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.
the class CookieItemTest method initStrBuilder.
@Before
public void initStrBuilder() {
mockContext = Mockito.mock(RoutingContext.class);
finishEvent = Mockito.mock(InvocationFinishEvent.class);
invocation = Mockito.mock(Invocation.class);
restClientRequest = Mockito.mock(RestClientRequestImpl.class);
accessLogEvent = new ServerAccessLogEvent();
strBuilder = new StringBuilder();
}
use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.
the class DurationMillisecondItemTest method initStrBuilder.
@Before
public void initStrBuilder() {
finishEvent = Mockito.mock(InvocationFinishEvent.class);
invocation = Mockito.mock(Invocation.class);
invocationStageTrace = Mockito.mock(InvocationStageTrace.class);
when(finishEvent.getInvocation()).thenReturn(invocation);
when(invocation.getInvocationStageTrace()).thenReturn(invocationStageTrace);
when(invocationStageTrace.getStartSend()).thenReturn(0L);
when(invocationStageTrace.getFinish()).thenReturn(1000_000L);
accessLogEvent = new ServerAccessLogEvent();
accessLogEvent.setMilliStartTime(1L);
accessLogEvent.setMilliEndTime(2L);
strBuilder = new StringBuilder();
}
use of org.apache.servicecomb.core.event.ServerAccessLogEvent in project java-chassis by ServiceComb.
the class RestServerVerticle method mountAccessLogHandler.
private void mountAccessLogHandler(Router mainRouter) {
if (!AccessLogConfig.INSTANCE.isServerLogEnabled()) {
return;
}
LOGGER.info("access log enabled, pattern = {}", AccessLogConfig.INSTANCE.getServerLogPattern());
mainRouter.route().handler(context -> {
ServerAccessLogEvent accessLogEvent = new ServerAccessLogEvent().setRoutingContext(context).setMilliStartTime(System.currentTimeMillis()).setLocalAddress(LocalHostAccessItem.getLocalAddress(context));
context.response().endHandler(event -> EventManager.post(accessLogEvent.setMilliEndTime(System.currentTimeMillis())));
context.next();
});
}
Aggregations