class DeprecationLogger {

    private static final ThreadLocal<RingBuffer<String>> RECENT_WARNINGS = ThreadLocal.withInitial(() -> new RingBuffer<String>(20));

    private final Logger logger;

    /**
     * Creates a new deprecation logger based on the parent logger. Automatically
     * prefixes the logger name with "deprecation", if it starts with "org.elasticsearch.",
     * it replaces "org.elasticsearch" with "org.elasticsearch.deprecation" to maintain
     * the "org.elasticsearch" namespace.
     */
    public DeprecationLogger(Logger parentLogger) {
        String name = parentLogger.getName();
        if (name.startsWith("org.elasticsearch")) {
            name = name.replace("org.elasticsearch.", "org.elasticsearch.deprecation.");
        } else {
            name = "deprecation." + name;
        }
        this.logger = LogManager.getLogger(name);
    }

    // LRU set of keys used to determine if a deprecation message should be emitted to the deprecation logs
    private final Set<String> keys = Collections.newSetFromMap(Collections.synchronizedMap(new LinkedHashMap<String, Boolean>() {
        @Override
        protected boolean removeEldestEntry(final Map.Entry<String, Boolean> eldest) {
            return size() > 128;
        }
    }));

    @VisibleForTesting
    public void resetLRU() {
        keys.clear();
    }

    /**
     * Adds a formatted warning message as a response header on the thread context, and logs a deprecation message if the associated key has
     * not recently been seen.
     *
     * @param key    the key used to determine if this deprecation should be logged
     * @param msg    the message to log
     * @param params parameters to the message
     */
    public void deprecatedAndMaybeLog(final String key, final String msg, final Object... params) {
        deprecated(msg, keys.add(key), params);
    }

    @SuppressLoggerChecks(reason = "safely delegates to logger")
    void deprecated(final String message, final boolean shouldLog, final Object... params) {<FILL_FUNCTION_BODY>}

    public static List<String> getRecentWarnings() {
        return Lists.of(RECENT_WARNINGS.get());
    }

    public static void resetWarnings() {
        RECENT_WARNINGS.get().reset();
    }
}

        if (shouldLog) {
            logger.warn(message, params);
            var msg = LoggerMessageFormat.format(message, params);
            RECENT_WARNINGS.get().add(msg);
        }
    
<no_super_class>