83 // TESTING = AccessController.doPrivileged(action) != null; |
83 // TESTING = AccessController.doPrivileged(action) != null; |
84 // } else TESTING = false; |
84 // } else TESTING = false; |
85 // } |
85 // } |
86 public static final boolean DEBUG = // Revisit: temporary dev flag. |
86 public static final boolean DEBUG = // Revisit: temporary dev flag. |
87 getBooleanProperty(DebugLogger.HTTP_NAME, false); |
87 getBooleanProperty(DebugLogger.HTTP_NAME, false); |
|
88 public static final boolean DEBUG_WS = // Revisit: temporary dev flag. |
|
89 getBooleanProperty(DebugLogger.WS_NAME, false); |
88 public static final boolean DEBUG_HPACK = // Revisit: temporary dev flag. |
90 public static final boolean DEBUG_HPACK = // Revisit: temporary dev flag. |
89 getBooleanProperty(DebugLogger.HPACK_NAME, false); |
91 getBooleanProperty(DebugLogger.HPACK_NAME, false); |
90 public static final boolean TESTING = DEBUG; |
92 public static final boolean TESTING = DEBUG; |
91 |
93 |
92 public static final boolean isHostnameVerificationDisabled = // enabled by default |
94 public static final boolean isHostnameVerificationDisabled = // enabled by default |
805 Level outLevel = on ? Level.ALL : Level.OFF; |
807 Level outLevel = on ? Level.ALL : Level.OFF; |
806 return getHpackLogger(dbgTag, outLevel); |
808 return getHpackLogger(dbgTag, outLevel); |
807 } |
809 } |
808 |
810 |
809 /** |
811 /** |
|
812 * Get a logger for debug WebSocket traces.The logger should only be used |
|
813 * with levels whose severity is {@code <= DEBUG}. |
|
814 * |
|
815 * By default, this logger will forward all messages logged to an internal |
|
816 * logger named "jdk.internal.httpclient.websocket.debug". |
|
817 * In addition, if the message severity level is >= to |
|
818 * the provided {@code errLevel} it will print the messages on stderr. |
|
819 * The logger will add some decoration to the printed message, in the form of |
|
820 * {@code <Level>:[<thread-name>] [<elapsed-time>] <dbgTag>: <formatted message>} |
|
821 * |
|
822 * @apiNote To obtain a logger that will always print things on stderr in |
|
823 * addition to forwarding to the internal logger, use |
|
824 * {@code getWebSocketLogger(this::dbgTag, Level.ALL);}. |
|
825 * This is also equivalent to calling |
|
826 * {@code getWSLogger(this::dbgTag, true);}. |
|
827 * To obtain a logger that will only forward to the internal logger, |
|
828 * use {@code getWebSocketLogger(this::dbgTag, Level.OFF);}. |
|
829 * This is also equivalent to calling |
|
830 * {@code getWSLogger(this::dbgTag, false);}. |
|
831 * |
|
832 * @param dbgTag A lambda that returns a string that identifies the caller |
|
833 * (e.g: "WebSocket(3)") |
|
834 * @param errLevel The level above which messages will be also printed on |
|
835 * stderr (in addition to be forwarded to the internal logger). |
|
836 * |
|
837 * @return A logger for HPACK internal debug traces |
|
838 */ |
|
839 public static Logger getWebSocketLogger(Supplier<String> dbgTag, Level errLevel) { |
|
840 Level outLevel = Level.OFF; |
|
841 return DebugLogger.createWebSocketLogger(dbgTag, outLevel, errLevel); |
|
842 } |
|
843 |
|
844 /** |
|
845 * Get a logger for debug WebSocket traces.The logger should only be used |
|
846 * with levels whose severity is {@code <= DEBUG}. |
|
847 * |
|
848 * By default, this logger will forward all messages logged to an internal |
|
849 * logger named "jdk.internal.httpclient.websocket.debug". |
|
850 * In addition, the provided boolean {@code on==true}, it will print the |
|
851 * messages on stderr. |
|
852 * The logger will add some decoration to the printed message, in the form of |
|
853 * {@code <Level>:[<thread-name>] [<elapsed-time>] <dbgTag>: <formatted message>} |
|
854 * |
|
855 * @apiNote To obtain a logger that will always print things on stderr in |
|
856 * addition to forwarding to the internal logger, use |
|
857 * {@code getWebSocketLogger(this::dbgTag, true);}. |
|
858 * This is also equivalent to calling |
|
859 * {@code getWebSocketLogger(this::dbgTag, Level.ALL);}. |
|
860 * To obtain a logger that will only forward to the internal logger, |
|
861 * use {@code getWebSocketLogger(this::dbgTag, false);}. |
|
862 * This is also equivalent to calling |
|
863 * {@code getHpackLogger(this::dbgTag, Level.OFF);}. |
|
864 * |
|
865 * @param dbgTag A lambda that returns a string that identifies the caller |
|
866 * (e.g: "WebSocket(3)") |
|
867 * @param on Whether messages should also be printed on |
|
868 * stderr (in addition to be forwarded to the internal logger). |
|
869 * |
|
870 * @return A logger for WebSocket internal debug traces |
|
871 */ |
|
872 public static Logger getWebSocketLogger(Supplier<String> dbgTag, boolean on) { |
|
873 Level errLevel = on ? Level.ALL : Level.OFF; |
|
874 return getWebSocketLogger(dbgTag, errLevel); |
|
875 } |
|
876 |
|
877 /** |
810 * SSLSessions returned to user are wrapped in an immutable object |
878 * SSLSessions returned to user are wrapped in an immutable object |
811 */ |
879 */ |
812 public static SSLSession immutableSession(SSLSession session) { |
880 public static SSLSession immutableSession(SSLSession session) { |
813 if (session instanceof ExtendedSSLSession) |
881 if (session instanceof ExtendedSSLSession) |
814 return new ImmutableExtendedSSLSession((ExtendedSSLSession)session); |
882 return new ImmutableExtendedSSLSession((ExtendedSSLSession)session); |