/* * Copyright 2013 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package feign; import java.io.BufferedReader; import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; import java.io.StringWriter; import java.util.logging.FileHandler; import java.util.logging.LogRecord; import java.util.logging.SimpleFormatter; import static feign.Util.UTF_8; import static feign.Util.ensureClosed; import static feign.Util.valuesOrEmpty; /** * Simple logging abstraction for debug messages. Adapted from {@code retrofit.RestAdapter.Log}. */ public abstract class Logger { /** * Controls the level of logging. */ public enum Level { /** * No logging. */ NONE, /** * Log only the request method and URL and the response status code and execution time. */ BASIC, /** * Log the basic information along with request and response headers. */ HEADERS, /** * Log the headers, body, and metadata for both requests and responses. */ FULL } /** * logs to the category {@link Logger} at {@link java.util.logging.Level#FINE}. */ public static class ErrorLogger extends Logger { final java.util.logging.Logger logger = java.util.logging.Logger.getLogger(Logger.class.getName()); @Override protected void log(String configKey, String format, Object... args) { System.err.printf(methodTag(configKey) + format + "%n", args); } } /** * logs to the category {@link Logger} at {@link java.util.logging.Level#FINE}, if loggable. */ public static class JavaLogger extends Logger { final java.util.logging.Logger logger =