Add configurable log level, Add more debug logging
All checks were successful
Build and push container / Build-Docker-Container (push) Successful in 4m28s
All checks were successful
Build and push container / Build-Docker-Container (push) Successful in 4m28s
This commit is contained in:
parent
9f07cecc51
commit
e41e0abec8
@ -3,6 +3,7 @@ package me.mrletsplay.videobase;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.Level;
|
||||||
import me.mrletsplay.mrcore.json.JSONType;
|
import me.mrletsplay.mrcore.json.JSONType;
|
||||||
import me.mrletsplay.mrcore.json.converter.JSONConstructor;
|
import me.mrletsplay.mrcore.json.converter.JSONConstructor;
|
||||||
import me.mrletsplay.mrcore.json.converter.JSONConvertible;
|
import me.mrletsplay.mrcore.json.converter.JSONConvertible;
|
||||||
@ -26,6 +27,9 @@ public class Config implements JSONConvertible {
|
|||||||
@JSONListType(JSONType.STRING)
|
@JSONListType(JSONType.STRING)
|
||||||
private List<String> includeFileTypes;
|
private List<String> includeFileTypes;
|
||||||
|
|
||||||
|
@JSONValue
|
||||||
|
private String logLevel;
|
||||||
|
|
||||||
@JSONConstructor
|
@JSONConstructor
|
||||||
private Config() {}
|
private Config() {}
|
||||||
|
|
||||||
@ -45,6 +49,10 @@ public class Config implements JSONConvertible {
|
|||||||
return includeFileTypes == null ? DEFAULT_FILE_TYPES : includeFileTypes;
|
return includeFileTypes == null ? DEFAULT_FILE_TYPES : includeFileTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLogLevel() {
|
||||||
|
return logLevel == null ? Level.INFO.toString() : logLevel;
|
||||||
|
}
|
||||||
|
|
||||||
public void validate() {
|
public void validate() {
|
||||||
Objects.requireNonNull(libraryPath, "libraryPath");
|
Objects.requireNonNull(libraryPath, "libraryPath");
|
||||||
}
|
}
|
||||||
@ -55,6 +63,7 @@ public class Config implements JSONConvertible {
|
|||||||
config.readOnly = false;
|
config.readOnly = false;
|
||||||
config.cachePath = "cache";
|
config.cachePath = "cache";
|
||||||
config.includeFileTypes = DEFAULT_FILE_TYPES;
|
config.includeFileTypes = DEFAULT_FILE_TYPES;
|
||||||
|
config.logLevel = Level.INFO.toString();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +54,18 @@ public class VideoBase {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Level logLevel = Level.toLevel(config.getLogLevel(), null);
|
||||||
|
if(logLevel == null) {
|
||||||
|
LOGGER.warn("Invalid log level '" + config.getLogLevel() + "' configured, falling back to INFO");
|
||||||
|
logLevel = Level.INFO;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGGER.info("Using log level " + logLevel);
|
||||||
|
((ch.qos.logback.classic.Logger) LOGGER).setLevel(logLevel);
|
||||||
|
|
||||||
loadLibrary();
|
loadLibrary();
|
||||||
executor.scheduleWithFixedDelay(VideoBase::loadLibrary, 10, 10, TimeUnit.MINUTES);
|
executor.scheduleWithFixedDelay(VideoBase::loadLibrary, 10, 10, TimeUnit.MINUTES);
|
||||||
|
|
||||||
((ch.qos.logback.classic.Logger) LOGGER).setLevel(Level.INFO);
|
|
||||||
|
|
||||||
HttpServer server = new HttpServer(HttpServer.newConfigurationBuilder()
|
HttpServer server = new HttpServer(HttpServer.newConfigurationBuilder()
|
||||||
.hostBindAll()
|
.hostBindAll()
|
||||||
.port(6969)
|
.port(6969)
|
||||||
@ -72,6 +79,7 @@ public class VideoBase {
|
|||||||
new LibraryAPI().register(server.getDocumentProvider());
|
new LibraryAPI().register(server.getDocumentProvider());
|
||||||
|
|
||||||
server.start();
|
server.start();
|
||||||
|
LOGGER.info("Server is running");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Config getConfig() {
|
public static Config getConfig() {
|
||||||
@ -83,9 +91,12 @@ public class VideoBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void loadLibrary() {
|
private static void loadLibrary() {
|
||||||
library = Library.load(Path.of(config.getLibraryPath()), config.isReadOnly());
|
Path libraryPath = Path.of(config.getLibraryPath());
|
||||||
|
LOGGER.debug("Loading library from path: " + libraryPath);
|
||||||
|
library = Library.load(libraryPath, config.isReadOnly());
|
||||||
ThumbnailCreator.clearCache();
|
ThumbnailCreator.clearCache();
|
||||||
ThumbnailCreator.createThumbnails();
|
ThumbnailCreator.createThumbnails();
|
||||||
|
LOGGER.debug("Loaded " + library.getVideos().size() + " videos");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,14 @@ public class Library {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void load(Path rootPath, Path path, List<Video> videos, VideoMetadata parentDefaultMetadata) {
|
private static void load(Path rootPath, Path path, List<Video> videos, VideoMetadata parentDefaultMetadata) {
|
||||||
if(!Files.isDirectory(path)) return;
|
if(!Files.isDirectory(path)) {
|
||||||
|
if(path.equals(rootPath)) {
|
||||||
|
VideoBase.LOGGER.warn("Ignoring root path: Not a directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(Files.isRegularFile(path.resolve(".nomedia"))) {
|
if(Files.isRegularFile(path.resolve(".nomedia"))) {
|
||||||
VideoBase.LOGGER.debug("Ignoring folder at " + path + ": .nomedia file exists");
|
VideoBase.LOGGER.debug("Ignoring folder at " + path + ": .nomedia file exists");
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user