// Path: src/main/java/net/technolords/micro/model/ResponseContext.java
// public class ResponseContext {
//     public static final String JSON_CONTENT_TYPE = "application/json";
//     public static final String XML_CONTENT_TYPE = "application/xml";
//     public static final String PLAIN_TEXT_CONTENT_TYPE = "text/plain";
//     public static final String HTML_CONTENT_TYPE = "text/html";
//     public static final String DEFAULT_CONTENT_TYPE = JSON_CONTENT_TYPE;
//     private String response;
//     private String errorCode;
//     private String contentType = DEFAULT_CONTENT_TYPE;
// 
//     public String getResponse() {
//         return response;
//     }
// 
//     public void setResponse(String response) {
//         this.response = response;
//     }
// 
//     public String getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(String errorCode) {
//         this.errorCode = errorCode;
//     }
// 
//     public String getContentType() {
//         return contentType;
//     }
// 
//     public void setContentType(String contentType) {
//         this.contentType = contentType;
//     }
// }


import java.net.HttpURLConnection;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.spi.StandardLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.technolords.micro.model.ResponseContext;
package net.technolords.micro.log;




/**
 * This class has the responsibility to interface with the logging library, which is currently
 * log4j-2. All log4j-2 dependencies and classes are used here solely, which limits the impact in
 * case things change.
 *
 * This class supports operations from two angles:
 * - startup time, where end user overrides default configuration (caller class: PropertiesManager)
 * - run time, where end-user changes log level (caller class: LogCommand)
 */
public class LogManager {
    private static final Logger LOGGER = LoggerFactory.getLogger(LogManager.class);

    /**
     * Auxiliary method to (re)initialize the logging. This method is typically called from
     * the PropertiesManager when a external log4j2 configuration is provided, while at the
     * same time no CLI parameter was given.
     *
     * Setting the new config location is enough, as it will trigger a reconfigure
     * automatically.
     *
     * @param pathToLogConfiguration
     *  A path to the external log configuration file.
     */
    public static void initializeLogging(String pathToLogConfiguration) {
        Path path = FileSystems.getDefault().getPath(pathToLogConfiguration);
        LOGGER.trace("Path to log configuration: {} -> file exists: {}", pathToLogConfiguration, Files.exists(path));
        LoggerContext loggerContext = LoggerContext.getContext(false);
        loggerContext.setConfigLocation(path.toUri());
    }

    /**
     * Auxiliary method to change the log level.
     *
     * @param logLevel
     *  The log level to set.
     *
     * @return
     *  A ResponseContext containing the result of the command.
     */
// Path: src/main/java/net/technolords/micro/model/ResponseContext.java
// public class ResponseContext {
//     public static final String JSON_CONTENT_TYPE = "application/json";
//     public static final String XML_CONTENT_TYPE = "application/xml";
//     public static final String PLAIN_TEXT_CONTENT_TYPE = "text/plain";
//     public static final String HTML_CONTENT_TYPE = "text/html";
//     public static final String DEFAULT_CONTENT_TYPE = JSON_CONTENT_TYPE;
//     private String response;
//     private String errorCode;
//     private String contentType = DEFAULT_CONTENT_TYPE;
// 
//     public String getResponse() {
//         return response;
//     }
// 
//     public void setResponse(String response) {
//         this.response = response;
//     }
// 
//     public String getErrorCode() {
//         return errorCode;
//     }
// 
//     public void setErrorCode(String errorCode) {
//         this.errorCode = errorCode;
//     }
// 
//     public String getContentType() {
//         return contentType;
//     }
// 
//     public void setContentType(String contentType) {
//         this.contentType = contentType;
//     }
// }


// Path: src/main/java/net/technolords/micro/log/LogManager.java
import java.net.HttpURLConnection;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.spi.StandardLevel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.technolords.micro.model.ResponseContext;

package net.technolords.micro.log;




/**
 * This class has the responsibility to interface with the logging library, which is currently
 * log4j-2. All log4j-2 dependencies and classes are used here solely, which limits the impact in
 * case things change.
 *
 * This class supports operations from two angles:
 * - startup time, where end user overrides default configuration (caller class: PropertiesManager)
 * - run time, where end-user changes log level (caller class: LogCommand)
 */
public class LogManager {
    private static final Logger LOGGER = LoggerFactory.getLogger(LogManager.class);

    /**
     * Auxiliary method to (re)initialize the logging. This method is typically called from
     * the PropertiesManager when a external log4j2 configuration is provided, while at the
     * same time no CLI parameter was given.
     *
     * Setting the new config location is enough, as it will trigger a reconfigure
     * automatically.
     *
     * @param pathToLogConfiguration
     *  A path to the external log configuration file.
     */
    public static void initializeLogging(String pathToLogConfiguration) {
        Path path = FileSystems.getDefault().getPath(pathToLogConfiguration);
        LOGGER.trace("Path to log configuration: {} -> file exists: {}", pathToLogConfiguration, Files.exists(path));
        LoggerContext loggerContext = LoggerContext.getContext(false);
        loggerContext.setConfigLocation(path.toUri());
    }

    /**
     * Auxiliary method to change the log level.
     *
     * @param logLevel
     *  The log level to set.
     *
     * @return
     *  A ResponseContext containing the result of the command.
     */
    public static ResponseContext changeLogLevel(String logLevel) {