mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Cleaned up logging and converted to LogPairs per DK feedback
This commit is contained in:
@ -48,14 +48,15 @@ import static com.kingsrook.qqq.backend.core.logging.LogUtils.logPair;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public class SimpleFileSystemDirectoryRouter implements QJavalinRouteProviderInterface
|
public class SimpleFileSystemDirectoryRouter implements QJavalinRouteProviderInterface
|
||||||
{
|
{
|
||||||
private static final QLogger LOG = QLogger.getLogger(SimpleFileSystemDirectoryRouter.class);
|
|
||||||
public static boolean loadStaticFilesFromJar = false;
|
|
||||||
|
|
||||||
|
|
||||||
private final String hostedPath;
|
|
||||||
private final String fileSystemPath;
|
|
||||||
private QCodeReference routeAuthenticator;
|
private QCodeReference routeAuthenticator;
|
||||||
private QInstance qInstance;
|
private QInstance qInstance;
|
||||||
|
private final String fileSystemPath;
|
||||||
|
private final String hostedPath;
|
||||||
|
|
||||||
|
private static final QLogger LOG = QLogger.getLogger(SimpleFileSystemDirectoryRouter.class);
|
||||||
|
|
||||||
|
public static final String loadStaticFilesFromJarProperty = "qqq.javalin.enableStaticFilesFromJar";
|
||||||
|
public static boolean loadStaticFilesFromJar = false;
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Constructor
|
** Constructor
|
||||||
@ -72,8 +73,7 @@ public class SimpleFileSystemDirectoryRouter implements QJavalinRouteProviderInt
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String propertyName = "qqq.javalin.enableStaticFilesFromJar"; // TODO: make a more general way to handle properties like this system-wide via a central config class
|
String propertyValue = System.getProperty(this.loadStaticFilesFromJarProperty, "");
|
||||||
String propertyValue = System.getProperty(propertyName, "");
|
|
||||||
if(propertyValue.equals("true"))
|
if(propertyValue.equals("true"))
|
||||||
{
|
{
|
||||||
loadStaticFilesFromJar = true;
|
loadStaticFilesFromJar = true;
|
||||||
@ -81,7 +81,8 @@ public class SimpleFileSystemDirectoryRouter implements QJavalinRouteProviderInt
|
|||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
loadStaticFilesFromJar = false;
|
||||||
|
LOG.warn("Exception attemping to read system property, defaulting to false. ", logPair("system property", this.loadStaticFilesFromJarProperty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,18 +118,17 @@ public class SimpleFileSystemDirectoryRouter implements QJavalinRouteProviderInt
|
|||||||
|
|
||||||
if(!hostedPath.startsWith("/"))
|
if(!hostedPath.startsWith("/"))
|
||||||
{
|
{
|
||||||
LOG.warn("hostedPath [" + hostedPath + "] should probably start with a leading slash...");
|
LOG.warn("hostedPath should probably start with a leading slash...", logPair("hostedPath", hostedPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// /////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Handle loading static files from the jar OR the filesystem based on system property //
|
// Handle loading static files from the jar OR the filesystem based on system property //
|
||||||
/// /////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
if(SimpleFileSystemDirectoryRouter.loadStaticFilesFromJar)
|
if(SimpleFileSystemDirectoryRouter.loadStaticFilesFromJar)
|
||||||
{
|
{
|
||||||
staticFileConfig.directory = fileSystemPath;
|
staticFileConfig.directory = fileSystemPath;
|
||||||
staticFileConfig.hostedPath = hostedPath;
|
staticFileConfig.hostedPath = hostedPath;
|
||||||
staticFileConfig.location = Location.CLASSPATH;
|
staticFileConfig.location = Location.CLASSPATH;
|
||||||
LOG.info("Static File Config : hostedPath [" + hostedPath + "] : directory [" + staticFileConfig.directory + "] : location [CLASSPATH]");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -146,9 +146,9 @@ public class SimpleFileSystemDirectoryRouter implements QJavalinRouteProviderInt
|
|||||||
staticFileConfig.directory = resource.getFile();
|
staticFileConfig.directory = resource.getFile();
|
||||||
staticFileConfig.hostedPath = hostedPath;
|
staticFileConfig.hostedPath = hostedPath;
|
||||||
staticFileConfig.location = Location.EXTERNAL;
|
staticFileConfig.location = Location.EXTERNAL;
|
||||||
LOG.info("Static File Config : hostedPath [" + hostedPath + "] : directory [" + staticFileConfig.directory + "] : location [EXTERNAL]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG.info("Static File Config", logPair("hostedPath", hostedPath), logPair("directory", staticFileConfig.directory), logPair("location", staticFileConfig.location));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user