本文整理了Java中io.vertx.core.logging.Logger.isTraceEnabled()
方法的一些代码示例,展示了Logger.isTraceEnabled()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isTraceEnabled()
方法的具体详情如下:
包路径:io.vertx.core.logging.Logger
类名称:Logger
方法名:isTraceEnabled
暂无
代码示例来源:origin: vert-x3/vertx-web
protected void sendInvalidJSON(HttpServerResponse response) {
if (log.isTraceEnabled()) log.trace("Broken JSON");
response.setStatusCode(500);
response.end("Broken JSON encoding.");
}
代码示例来源:origin: vert-x3/vertx-web
private String getFile(String path, RoutingContext context) {
String file = webRoot + Utils.pathOffset(path, context);
if (log.isTraceEnabled()) log.trace("File to serve is " + file);
return file;
}
代码示例来源:origin: vert-x3/vertx-web
public void sendFrame(final String body) {
if (log.isTraceEnabled()) log.trace("WS, sending frame");
if (!closed) {
ws.writeTextMessage(body);
}
}
代码示例来源:origin: vert-x3/vertx-web
public void handle(RoutingContext rc) {
if (log.isTraceEnabled()) log.trace("In Info handler");
rc.response().putHeader("Content-Type", "application/json; charset=UTF-8");
setNoCacheHeaders(rc);
JsonObject json = new JsonObject();
json.put("websocket", websocket);
json.put("cookie_needed", options.isInsertJSESSIONID());
json.put("origins", new JsonArray().add("*:*"));
// Java ints are signed, so we need to use a long and add the offset so
// the result is not negative
json.put("entropy", RAND_OFFSET + new Random().nextInt());
setCORS(rc);
rc.response().end(json.encode());
}
};
代码示例来源:origin: vert-x3/vertx-web
protected void addCloseHandler(HttpServerResponse resp, final SockJSSession session) {
resp.closeHandler(v -> {
if (log.isTraceEnabled()) log.trace("Connection closed (from client?), closing session");
// Connection has been closed from the client or network error so
// we remove the session
session.shutdown();
closed = true;
});
}
代码示例来源:origin: vert-x3/vertx-web
@Override
public void handle(HttpServerRequest request) {
if (log.isTraceEnabled()) log.trace("Router: " + System.identityHashCode(this) +
" accepting request " + request.method() + " " + request.absoluteURI());
new RoutingContextImpl(null, this, request, routes).next();
}
代码示例来源:origin: vert-x3/vertx-web
@Override
public void handle(RoutingContext context) {
if (log.isTraceEnabled()) {
log.trace("Got request in sockjs server: " + context.request().uri());
}
router.handleContext(context);
}
代码示例来源:origin: vert-x3/vertx-web
public void close() {
if (log.isTraceEnabled()) log.trace("XHR stream closing listener");
if (!closed) {
session.resetListener();
try {
rc.response().end();
rc.response().close();
closed = true;
} catch (IllegalStateException e) {
// Underlying connection might already be closed - that's fine
}
}
}
}
代码示例来源:origin: vert-x3/vertx-web
public void close() {
if (log.isTraceEnabled()) log.trace("XHR poll closing listener");
if (!closed) {
try {
session.resetListener();
rc.response().end();
rc.response().close();
closed = true;
} catch (IllegalStateException e) {
// Underlying connection might already be closed - that's fine
}
}
}
}
代码示例来源:origin: vert-x3/vertx-web
static Handler<RoutingContext> createCORSOptionsHandler(SockJSHandlerOptions options, String methods) {
return rc -> {
if (log.isTraceEnabled()) log.trace("In CORS options handler");
rc.response().putHeader("Cache-Control", "public,max-age=31536000");
long oneYearSeconds = 365 * 24 * 60 * 60;
long oneYearms = oneYearSeconds * 1000;
String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").format(new Date(System.currentTimeMillis() + oneYearms));
rc.response().putHeader("Expires", expires)
.putHeader("Access-Control-Allow-Methods", methods)
.putHeader("Access-Control-Max-Age", String.valueOf(oneYearSeconds));
setCORS(rc);
setJSESSIONID(options, rc);
rc.response().setStatusCode(204);
rc.response().end();
};
}
代码示例来源:origin: vert-x3/vertx-web
private Handler<RoutingContext> createIFrameHandler(String iframeHTML) {
String etag = getMD5String(iframeHTML);
return rc -> {
try {
if (log.isTraceEnabled()) log.trace("In Iframe handler");
if (etag != null && etag.equals(rc.request().getHeader("if-none-match"))) {
rc.response().setStatusCode(304);
rc.response().end();
} else {
long oneYear = 365 * 24 * 60 * 60 * 1000L;
String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").format(new Date(System.currentTimeMillis() + oneYear));
rc.response().putHeader("Content-Type", "text/html; charset=UTF-8")
.putHeader("Cache-Control", "public,max-age=31536000")
.putHeader("Expires", expires).putHeader("ETag", etag).end(iframeHTML);
}
} catch (Exception e) {
log.error("Failed to server iframe", e);
}
};
}
代码示例来源:origin: vert-x3/vertx-web
public void sendFrame(String body) {
if (log.isTraceEnabled()) log.trace("HtmlFile, sending frame");
if (!headersWritten) {
String htmlFile = HTML_FILE_TEMPLATE.replace("{{ callback }}", callback);
rc.response().putHeader("Content-Type", "text/html; charset=UTF-8");
setNoCacheHeaders(rc);
rc.response().setChunked(true);
setJSESSIONID(options, rc);
rc.response().write(htmlFile);
headersWritten = true;
}
body = escapeForJavaScript(body);
String sb = "<script>\np(\"" +
body +
"\");\n</script>\r\n";
Buffer buff = buffer(sb);
rc.response().write(buff);
bytesSent += buff.length();
if (bytesSent >= maxBytesStreaming) {
if (log.isTraceEnabled()) log.trace("More than maxBytes sent so closing connection");
// Reset and close the connection
close();
}
}
代码示例来源:origin: vert-x3/vertx-web
public void sendFrame(String body) {
if (log.isTraceEnabled()) log.trace("EventSource, sending frame");
if (!headersWritten) {
// event stream data is always UTF8
// https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format
// no need to specify the character encoding
rc.response().putHeader("Content-Type", "text/event-stream");
setNoCacheHeaders(rc);
setJSESSIONID(options, rc);
rc.response().setChunked(true).write("\r\n");
headersWritten = true;
}
String sb = "data: " +
body +
"\r\n\r\n";
Buffer buff = buffer(sb);
rc.response().write(buff);
bytesSent += buff.length();
if (bytesSent >= maxBytesStreaming) {
if (log.isTraceEnabled()) log.trace("More than maxBytes sent so closing connection");
// Reset and close the connection
close();
}
}
代码示例来源:origin: vert-x3/vertx-web
private void handleSendMessage(RoutingContext rc, SockJSSession session, Buffer body) {
String msgs = body.toString();
if (msgs.equals("")) {
rc.response().setStatusCode(500);
rc.response().end("Payload expected.");
return;
}
if (!session.handleMessages(msgs)) {
sendInvalidJSON(rc.response());
} else {
rc.response().putHeader("Content-Type", "text/plain; charset=UTF-8");
setNoCacheHeaders(rc);
setJSESSIONID(options, rc);
setCORS(rc);
rc.response().setStatusCode(204);
rc.response().end();
}
if (log.isTraceEnabled()) log.trace("XHR send processed ok");
}
代码示例来源:origin: vert-x3/vertx-web
public void sendFrame(String body) {
if (log.isTraceEnabled()) log.trace("XHR sending frame");
if (!headersWritten) {
HttpServerResponse resp = rc.response();
resp.putHeader("Content-Type", "application/javascript; charset=UTF-8");
setJSESSIONID(options, rc);
setCORS(rc);
if (rc.request().version() != HttpVersion.HTTP_1_0) {
resp.setChunked(true);
}
// NOTE that this is streaming!!!
// Client are not expecting to see Content-Length as we don't know it's value
headersWritten = true;
}
}
代码示例来源:origin: vert-x3/vertx-web
HtmlFileTransport(Vertx vertx, Router router, LocalMap<String, SockJSSession> sessions, SockJSHandlerOptions options,
Handler<SockJSSocket> sockHandler) {
super(vertx, sessions, options);
String htmlFileRE = COMMON_PATH_ELEMENT_RE + "htmlfile.*";
router.getWithRegex(htmlFileRE).handler(rc -> {
if (log.isTraceEnabled()) log.trace("HtmlFile, get: " + rc.request().uri());
String callback = rc.request().getParam("callback");
if (callback == null) {
callback = rc.request().getParam("c");
if (callback == null) {
rc.response().setStatusCode(500).end("\"callback\" parameter required\n");
return;
}
}
if (CALLBACK_VALIDATION.matcher(callback).find()) {
rc.response().setStatusCode(500);
rc.response().end("invalid \"callback\" parameter\n");
return;
}
HttpServerRequest req = rc.request();
String sessionID = req.params().get("param0");
SockJSSession session = getSession(rc, options.getSessionTimeout(), options.getHeartbeatInterval(), sessionID, sockHandler);
session.register(req, new HtmlFileListener(options.getMaxBytesStreaming(), rc, callback, session));
});
}
代码示例来源:origin: vert-x3/vertx-web
@Override
public void handle(RoutingContext context) {
HttpServerRequest request = context.request();
if (request.method() != HttpMethod.GET && request.method() != HttpMethod.HEAD) {
if (log.isTraceEnabled()) log.trace("Not GET or HEAD so ignoring request");
context.next();
} else {
String path = HttpUtils.removeDots(URIDecoder.decodeURIComponent(context.normalisedPath(), false));
// if the normalized path is null it cannot be resolved
if (path == null) {
log.warn("Invalid path: " + context.request().path());
context.next();
return;
}
// only root is known for sure to be a directory. all other directories must be identified as such.
if (!directoryListing && "/".equals(path)) {
path = indexPage;
}
// can be called recursive for index pages
sendStatic(context, path);
}
}
代码示例来源:origin: vert-x3/vertx-web
EventSourceTransport(Vertx vertx, Router router, LocalMap<String, SockJSSession> sessions, SockJSHandlerOptions options,
Handler<SockJSSocket> sockHandler) {
super(vertx, sessions, options);
String eventSourceRE = COMMON_PATH_ELEMENT_RE + "eventsource";
router.getWithRegex(eventSourceRE).handler(rc -> {
if (log.isTraceEnabled()) log.trace("EventSource transport, get: " + rc.request().uri());
String sessionID = rc.request().getParam("param0");
SockJSSession session = getSession(rc, options.getSessionTimeout(), options.getHeartbeatInterval(), sessionID, sockHandler);
HttpServerRequest req = rc.request();
session.register(req, new EventSourceListener(options.getMaxBytesStreaming(), rc, session));
});
}
代码示例来源:origin: vert-x3/vertx-web
public void sendFrame(String body) {
if (log.isTraceEnabled()) log.trace("JsonP, sending frame");
if (!headersWritten) {
rc.response()
.setChunked(true)
// protect against SWF JSONP exploit
.putHeader("X-Content-Type-Options", "nosniff")
.putHeader("Content-Type", "application/javascript; charset=UTF-8");
setNoCacheHeaders(rc);
setJSESSIONID(options, rc);
headersWritten = true;
}
body = escapeForJavaScript(body);
// prepend comment to avoid SWF exploit https://github.com/sockjs/sockjs-node/issues/163
String sb = "/**/" + callback + "(\"" +
body +
"\");\r\n";
//End the response and close the HTTP connection
rc.response().write(sb);
close();
}
代码示例来源:origin: vert-x3/vertx-web
private void registerHandler(Router router, Handler<SockJSSocket> sockHandler, String re,
boolean streaming, SockJSHandlerOptions options) {
router.postWithRegex(re).handler(rc -> {
if (log.isTraceEnabled()) log.trace("XHR, post, " + rc.request().uri());
setNoCacheHeaders(rc);
String sessionID = rc.request().getParam("param0");
SockJSSession session = getSession(rc, options.getSessionTimeout(), options.getHeartbeatInterval(), sessionID, sockHandler);
HttpServerRequest req = rc.request();
session.register(req, streaming? new XhrStreamingListener(options.getMaxBytesStreaming(), rc, session) : new XhrPollingListener(rc, session));
});
}
内容来源于网络,如有侵权,请联系作者删除!