< prev index next >
src/java.httpclient/share/classes/java/net/http/Log.java
Print this page
*** 24,34 ****
package java.net.http;
import java.util.Locale;
/**
! * -Djava.net.HttpClient.log=errors,requests,headers,frames[:type:type2:..],content
*
* Any of errors, requests, headers or content are optional.
*
* Other handlers may be added. All logging is at level INFO
*
--- 24,36 ----
package java.net.http;
import java.util.Locale;
/**
! * -Djava.net.HttpClient.log=
! * errors,requests,headers,
! * frames[:type:type2:..],content,ssl,trace
*
* Any of errors, requests, headers or content are optional.
*
* Other handlers may be added. All logging is at level INFO
*
*** 45,54 ****
--- 47,57 ----
public static final int REQUESTS = 0x2;
public static final int HEADERS = 0x4;
public static final int CONTENT = 0x8;
public static final int FRAMES = 0x10;
public static final int SSL = 0x20;
+ public static final int TRACE = 0x40;
static int logging;
// Frame types: "control", "data", "window", "all"
public static final int CONTROL = 1; // all except DATA and WINDOW_UPDATES
public static final int DATA = 2;
*** 79,90 ****
logging |= CONTENT;
break;
case "ssl":
logging |= SSL;
break;
case "all":
! logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS;
break;
}
if (val.startsWith("frames")) {
logging |= FRAMES;
String[] types = val.split(":");
--- 82,96 ----
logging |= CONTENT;
break;
case "ssl":
logging |= SSL;
break;
+ case "trace":
+ logging |= TRACE;
+ break;
case "all":
! logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE;
break;
}
if (val.startsWith("frames")) {
logging |= FRAMES;
String[] types = val.split(":");
*** 128,175 ****
static boolean headers() {
return (logging & HEADERS) != 0;
}
static boolean ssl() {
return (logging & SSL) != 0;
}
static boolean frames() {
return (logging & FRAMES) != 0;
}
! static void logError(String s) {
if (errors())
! logger.log(Level.INFO, "ERROR: " + s);
}
static void logError(Throwable t) {
if (errors()) {
String s = Utils.stackTrace(t);
logger.log(Level.INFO, "ERROR: " + s);
}
}
! static void logSSL(String s) {
if (ssl())
! logger.log(Level.INFO, "SSL: " + s);
}
! static void logRequest(String s) {
if (requests())
! logger.log(Level.INFO, "REQUEST: " + s);
}
! static void logResponse(String s) {
if (requests())
! logger.log(Level.INFO, "RESPONSE: " + s);
}
! static void logHeaders(String s) {
if (headers())
! logger.log(Level.INFO, "HEADERS: " + s);
}
// not instantiable
private Log() {}
--- 134,211 ----
static boolean headers() {
return (logging & HEADERS) != 0;
}
+ static boolean trace() {
+ return (logging & TRACE) != 0;
+ }
+
static boolean ssl() {
return (logging & SSL) != 0;
}
static boolean frames() {
return (logging & FRAMES) != 0;
}
! static void logError(String s, Object... s1) {
if (errors())
! logger.log(Level.INFO, "ERROR: " + s, s1);
}
static void logError(Throwable t) {
if (errors()) {
String s = Utils.stackTrace(t);
logger.log(Level.INFO, "ERROR: " + s);
}
}
! static void logSSL(String s, Object... s1) {
if (ssl())
! logger.log(Level.INFO, "SSL: " + s, s1);
! }
!
! static void logTrace(String s, Object... s1) {
! if (trace()) {
! String format = "TRACE: " + s;
! logger.log(Level.INFO, format, s1);
! }
}
! static void logRequest(String s, Object... s1) {
if (requests())
! logger.log(Level.INFO, "REQUEST: " + s, s1);
}
! static void logResponse(String s, Object... s1) {
if (requests())
! logger.log(Level.INFO, "RESPONSE: " + s, s1);
}
! static void logHeaders(String s, Object... s1) {
if (headers())
! logger.log(Level.INFO, "HEADERS: " + s, s1);
! }
! // START HTTP2
! static boolean loggingFrame(Class<? extends Http2Frame> clazz) {
! if (frametypes == ALL) {
! return true;
! }
! if (clazz == DataFrame.class) {
! return (frametypes & DATA) != 0;
! } else if (clazz == WindowUpdateFrame.class) {
! return (frametypes & WINDOW_UPDATES) != 0;
! } else {
! return (frametypes & CONTROL) != 0;
! }
! }
!
! static void logFrames(Http2Frame f, String direction) {
! if (frames() && loggingFrame(f.getClass())) {
! logger.log(Level.INFO, "FRAME: " + direction + ": " + f.toString());
! }
}
// not instantiable
private Log() {}
< prev index next >