Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* (c) Copyright 2018 Palantir Technologies Inc. All rights reserved.
*
* 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 com.palantir.atlasdb.logging;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Stopwatch;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.Supplier;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class KvsProfilingLogger {
public static final String SLOW_LOGGER_NAME = "kvs-slow-log-2";
@SuppressWarnings("PreferSafeLogger") // May be used externally. Don't force an api break
public static final Logger slowlogger = LoggerFactory.getLogger(SLOW_LOGGER_NAME);
@SuppressWarnings("PreferSafeLogger") // Nontrivial refactoring
private static final Logger log = LoggerFactory.getLogger(KvsProfilingLogger.class);
public static final int DEFAULT_THRESHOLD_MILLIS = 1000;
private static volatile Predicate slowLogPredicate =
createLogPredicateForThresholdMillis(DEFAULT_THRESHOLD_MILLIS);
@FunctionalInterface
public interface LoggingFunction {
void log(String fmt, Object... args);
}
interface CloseableLoggingFunction extends LoggingFunction, AutoCloseable {
@Override
void close();
}
// Accumulates logs in a single string.
// Warning to users of this class: We do not guarantee that SLF4J special characters work properly across log lines,
// nor do we guarantee behaviour when the number of arguments does not match the number of placeholders.
@VisibleForTesting
static class LogAccumulator implements CloseableLoggingFunction {
private static final String DELIMITER = "\n";
private final List formatElements = new ArrayList<>();
private final List