All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.ext.interactivelauncher.DebugLoggingSupport Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
package org.opentripplanner.ext.interactivelauncher;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.slf4j.LoggerFactory;

/**
 * Responsible for integration with the OTP Debug log configuraton, reading loggers from the slf4j
 * context and setting DEBUG level on selected loggers back.
 * 

* The log names are transformed to be more human readable: *

org.opentripplanner.routing.algorithm  -->  o.o.routing.algorithm
*/ public class DebugLoggingSupport { public static List getLogs() { List result = new ArrayList<>(); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); for (Logger log : context.getLoggerList()) { var name = log.getName(); if ( name.matches("(org\\.opentripplanner\\..*|[A-Z0-9_]*)") && !name.equals("ROOT") ) { result.add(logDisplayName(name)); } } return result; } public static void configureDebugLogging(Map loggers) { LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); for (Logger log : context.getLoggerList()) { var name = logDisplayName(log.getName()); if(loggers.getOrDefault(name, false)) { log.setLevel(Level.DEBUG); } } } private static String logDisplayName(String name) { return name.replace("org.opentripplanner.", "o.o."); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy