// Path: configuration/src/main/java/io/airlift/configuration/ConfigurationLoader.java
// public static Map<String, String> loadPropertiesFrom(String path)
//         throws IOException
// {
//     Properties properties = new Properties();
//     try (InputStream inputStream = new FileInputStream(path)) {
//         properties.load(inputStream);
//     }
// 
//     return fromProperties(properties).entrySet().stream()
//             .collect(toImmutableMap(Entry::getKey, entry -> entry.getValue().trim()));
// }
// 
// Path: log-manager/src/main/java/io/airlift/log/SocketMessageOutput.java
// public static BufferedHandler createSocketHandler(HostAndPort hostAndPort, Formatter formatter, ErrorManager errorManager)
// {
//     SocketMessageOutput output = new SocketMessageOutput(hostAndPort);
//     BufferedHandler handler = new BufferedHandler(output, formatter, errorManager);
//     handler.start();
//     return handler;
// }


import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.net.HostAndPort;
import io.airlift.log.RollingFileMessageOutput.CompressionType;
import io.airlift.units.DataSize;
import javax.annotation.concurrent.GuardedBy;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.LogManager;
import static com.google.common.collect.Maps.fromProperties;
import static io.airlift.configuration.ConfigurationLoader.loadPropertiesFrom;
import static io.airlift.configuration.ConfigurationUtils.replaceEnvironmentVariables;
import static io.airlift.log.RollingFileMessageOutput.createRollingFileHandler;
import static io.airlift.log.SocketMessageOutput.createSocketHandler;
        ROOT.addHandler(consoleHandler);
    }

    public synchronized void disableConsole()
    {
        log.info("Disabling stderr output");
        ROOT.removeHandler(consoleHandler);
        consoleHandler = null;
    }

    public void logToFile(boolean legacyLoggerImplementation, String logPath, int maxHistory, DataSize maxFileSize, DataSize maxTotalSize, CompressionType compressionType, Formatter formatter)
    {
        log.info("Logging to %s", logPath);

        Handler handler;
        if (legacyLoggerImplementation) {
            handler = new LegacyRollingFileHandler(logPath, maxHistory, maxFileSize.toBytes(), formatter);
        }
        else {
            handler = createRollingFileHandler(logPath, maxFileSize, maxTotalSize, compressionType, formatter, new BufferedHandlerErrorManager(stdErr));
        }
        ROOT.addHandler(handler);
    }

    private void logToSocket(String logPath, Formatter formatter)
    {
        if (!logPath.startsWith("tcp://") || logPath.lastIndexOf("/") > 6) {
            throw new IllegalArgumentException("LogPath for sockets must begin with tcp:// and not contain any path component.");
        }
        HostAndPort hostAndPort = HostAndPort.fromString(logPath.replace("tcp://", ""));
// Path: configuration/src/main/java/io/airlift/configuration/ConfigurationLoader.java
// public static Map<String, String> loadPropertiesFrom(String path)
//         throws IOException
// {
//     Properties properties = new Properties();
//     try (InputStream inputStream = new FileInputStream(path)) {
//         properties.load(inputStream);
//     }
// 
//     return fromProperties(properties).entrySet().stream()
//             .collect(toImmutableMap(Entry::getKey, entry -> entry.getValue().trim()));
// }
// 
// Path: log-manager/src/main/java/io/airlift/log/SocketMessageOutput.java
// public static BufferedHandler createSocketHandler(HostAndPort hostAndPort, Formatter formatter, ErrorManager errorManager)
// {
//     SocketMessageOutput output = new SocketMessageOutput(hostAndPort);
//     BufferedHandler handler = new BufferedHandler(output, formatter, errorManager);
//     handler.start();
//     return handler;
// }


// Path: log-manager/src/main/java/io/airlift/log/Logging.java
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.net.HostAndPort;
import io.airlift.log.RollingFileMessageOutput.CompressionType;
import io.airlift.units.DataSize;
import javax.annotation.concurrent.GuardedBy;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.LogManager;
import static com.google.common.collect.Maps.fromProperties;
import static io.airlift.configuration.ConfigurationLoader.loadPropertiesFrom;
import static io.airlift.configuration.ConfigurationUtils.replaceEnvironmentVariables;
import static io.airlift.log.RollingFileMessageOutput.createRollingFileHandler;
import static io.airlift.log.SocketMessageOutput.createSocketHandler;

        ROOT.addHandler(consoleHandler);
    }

    public synchronized void disableConsole()
    {
        log.info("Disabling stderr output");
        ROOT.removeHandler(consoleHandler);
        consoleHandler = null;
    }

    public void logToFile(boolean legacyLoggerImplementation, String logPath, int maxHistory, DataSize maxFileSize, DataSize maxTotalSize, CompressionType compressionType, Formatter formatter)
    {
        log.info("Logging to %s", logPath);

        Handler handler;
        if (legacyLoggerImplementation) {
            handler = new LegacyRollingFileHandler(logPath, maxHistory, maxFileSize.toBytes(), formatter);
        }
        else {
            handler = createRollingFileHandler(logPath, maxFileSize, maxTotalSize, compressionType, formatter, new BufferedHandlerErrorManager(stdErr));
        }
        ROOT.addHandler(handler);
    }

    private void logToSocket(String logPath, Formatter formatter)
    {
        if (!logPath.startsWith("tcp://") || logPath.lastIndexOf("/") > 6) {
            throw new IllegalArgumentException("LogPath for sockets must begin with tcp:// and not contain any path component.");
        }
        HostAndPort hostAndPort = HostAndPort.fromString(logPath.replace("tcp://", ""));
        Handler handler = createSocketHandler(hostAndPort, formatter, new BufferedHandlerErrorManager(stdErr));