mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-12-25 17:08:27 +01:00
Route slf4j from our dependencies directly to our logging handler
This commit is contained in:
parent
e7d93a4176
commit
082116c02a
@ -5,7 +5,4 @@ apply from: rootProject.file('buildscript/final.gradle')
|
||||
shadowJar {
|
||||
// Include the bootstrap
|
||||
from parent.tasks.shadowJar.archiveFile
|
||||
|
||||
// Relocate the dependency
|
||||
relocate 'dev.vankka.mcdependencydownload', 'com.discordsrv.dependencies.dev.vankka.mcdependencydownload'
|
||||
}
|
||||
|
@ -2,11 +2,18 @@
|
||||
|
||||
shadowJar {
|
||||
[
|
||||
// JDA, Trove, WS, okhttp
|
||||
// JDA, WS
|
||||
'net.dv8tion.jda',
|
||||
'com.iwebpp',
|
||||
'gnu.trove',
|
||||
'com.neovisionaries.ws',
|
||||
|
||||
// Trove
|
||||
'gnu.trove',
|
||||
|
||||
// Jackson
|
||||
'com.fasterxml.jackson',
|
||||
|
||||
// okhttp
|
||||
'okhttp3',
|
||||
'okio',
|
||||
|
||||
@ -46,4 +53,11 @@ shadowJar {
|
||||
].each {
|
||||
relocate it, 'com.discordsrv.dependencies.' + it
|
||||
}
|
||||
|
||||
// SLF4J
|
||||
relocate('org.slf4j', 'com.discordsrv.dependencies.org.slf4j') {
|
||||
include('*')
|
||||
exclude('com.discordsrv.logging.impl.SLF4JLoggerImpl')
|
||||
exclude('com.discordsrv.velocity.DiscordSRVVelocityBootstrap')
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
// Common
|
||||
implementation project(':common:common-server')
|
||||
compileOnly project(':common:common-server')
|
||||
implementation project(path: ':common:common-server', configuration: 'runtimeElements')
|
||||
|
||||
// DependencyDownload
|
||||
implementation 'dev.vankka.minecraftdependencydownload:bukkit:' + rootProject.mddVersion
|
||||
|
@ -4,7 +4,7 @@ apply from: rootProject.file('buildscript/loader.gradle')
|
||||
|
||||
dependencies {
|
||||
// API
|
||||
implementation project(':api')
|
||||
implementation project(':common:common-api')
|
||||
|
||||
// DependencyDownload
|
||||
implementation 'dev.vankka.minecraftdependencydownload:bukkit-loader:' + rootProject.mddVersion
|
||||
|
@ -29,7 +29,7 @@ import com.discordsrv.bukkit.player.BukkitPlayerProvider;
|
||||
import com.discordsrv.bukkit.scheduler.BukkitScheduler;
|
||||
import com.discordsrv.common.config.manager.ConnectionConfigManager;
|
||||
import com.discordsrv.common.config.manager.MainConfigManager;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.common.server.ServerDiscordSRV;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bukkit.Server;
|
||||
|
@ -19,8 +19,8 @@
|
||||
package com.discordsrv.bukkit;
|
||||
|
||||
import com.discordsrv.common.dependency.InitialDependencyLoader;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.logging.impl.JavaLoggerImpl;
|
||||
import dev.vankka.mcdependencydownload.bukkit.bootstrap.BukkitBootstrap;
|
||||
import dev.vankka.mcdependencydownload.classloader.JarInJarClassLoader;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -20,9 +20,9 @@ package com.discordsrv.bukkit.console;
|
||||
|
||||
import com.discordsrv.bukkit.BukkitDiscordSRV;
|
||||
import com.discordsrv.common.console.Console;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
|
||||
import com.discordsrv.logging.backend.LoggingBackend;
|
||||
import com.discordsrv.logging.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.logging.impl.Log4JLoggerImpl;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -4,7 +4,7 @@ apply from: rootProject.file('buildscript/loader.gradle')
|
||||
|
||||
dependencies {
|
||||
// API
|
||||
implementation project(':api')
|
||||
implementation project(':common:common-api')
|
||||
|
||||
// DependencyDownload
|
||||
implementation 'dev.vankka.minecraftdependencydownload:bungee-loader:' + rootProject.mddVersion
|
||||
|
@ -24,7 +24,7 @@ import com.discordsrv.common.config.connection.ConnectionConfig;
|
||||
import com.discordsrv.common.config.main.MainConfig;
|
||||
import com.discordsrv.common.config.manager.ConnectionConfigManager;
|
||||
import com.discordsrv.common.config.manager.MainConfigManager;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.common.proxy.ProxyDiscordSRV;
|
||||
import com.discordsrv.common.scheduler.StandardScheduler;
|
||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||
|
@ -19,8 +19,8 @@
|
||||
package com.discordsrv.bungee;
|
||||
|
||||
import com.discordsrv.common.dependency.InitialDependencyLoader;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.logging.impl.JavaLoggerImpl;
|
||||
import dev.vankka.mcdependencydownload.bungee.bootstrap.BungeeBootstrap;
|
||||
import dev.vankka.mcdependencydownload.classloader.JarInJarClassLoader;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
@ -20,8 +20,8 @@ package com.discordsrv.bungee.console;
|
||||
|
||||
import com.discordsrv.bungee.BungeeDiscordSRV;
|
||||
import com.discordsrv.common.console.Console;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.logging.backend.LoggingBackend;
|
||||
import com.discordsrv.logging.impl.JavaLoggerImpl;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
8
common/api/build.gradle
Normal file
8
common/api/build.gradle
Normal file
@ -0,0 +1,8 @@
|
||||
dependencies {
|
||||
// API
|
||||
api project(':api')
|
||||
|
||||
// Logging
|
||||
api 'org.slf4j:slf4j-api:1.6.99'
|
||||
compileOnly 'org.apache.logging.log4j:log4j-core:2.0-beta9'
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger;
|
||||
package com.discordsrv.logging;
|
||||
|
||||
public interface LogLevel {
|
||||
|
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger;
|
||||
package com.discordsrv.logging;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -67,6 +67,6 @@ public interface Logger {
|
||||
log(LogLevel.TRACE, message, throwable);
|
||||
}
|
||||
|
||||
void log(@NotNull LogLevel LogLevel, @Nullable String message, @Nullable Throwable throwable);
|
||||
void log(@NotNull LogLevel logLevel, @Nullable String message, @Nullable Throwable throwable);
|
||||
|
||||
}
|
@ -0,0 +1,217 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.logging.adapter;
|
||||
|
||||
import com.discordsrv.logging.LogLevel;
|
||||
import com.discordsrv.logging.backend.LogAppender;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.helpers.MarkerIgnoringBase;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
public class DependencyLoggerAdapter extends MarkerIgnoringBase implements LocationAwareLogger {
|
||||
|
||||
private static LogAppender APPENDER;
|
||||
|
||||
public static void setAppender(LogAppender appender) {
|
||||
APPENDER = appender;
|
||||
}
|
||||
|
||||
private final String name;
|
||||
|
||||
public DependencyLoggerAdapter(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Marker marker, String fqcn, int level, String message, Object[] argArray, Throwable t) {
|
||||
if (APPENDER == null) {
|
||||
// Adapter isn't set, do nothing
|
||||
return;
|
||||
}
|
||||
APPENDER.append(name, getLevel(level), String.format(message, argArray), t);
|
||||
}
|
||||
|
||||
private LogLevel getLevel(int level) {
|
||||
switch (level) {
|
||||
case LocationAwareLogger.TRACE_INT:
|
||||
return LogLevel.TRACE;
|
||||
case LocationAwareLogger.DEBUG_INT:
|
||||
return LogLevel.DEBUG;
|
||||
case LocationAwareLogger.INFO_INT:
|
||||
return LogLevel.INFO;
|
||||
case LocationAwareLogger.WARN_INT:
|
||||
return LogLevel.WARNING;
|
||||
case LocationAwareLogger.ERROR_INT:
|
||||
return LogLevel.ERROR;
|
||||
default:
|
||||
throw new IllegalStateException("Level number " + level + " is not recognized.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTraceEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String msg) {
|
||||
trace(msg, (Throwable) null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object arg) {
|
||||
trace(String.format(format, arg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object arg1, Object arg2) {
|
||||
trace(String.format(format, arg1, arg2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String format, Object... arguments) {
|
||||
trace(String.format(format, arguments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void trace(String msg, Throwable t) {
|
||||
APPENDER.append(name, LogLevel.TRACE, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebugEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg) {
|
||||
debug(msg, (Throwable) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object arg) {
|
||||
debug(String.format(format, arg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object arg1, Object arg2) {
|
||||
debug(String.format(format, arg1, arg2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String format, Object... arguments) {
|
||||
debug(String.format(format, arguments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String msg, Throwable t) {
|
||||
APPENDER.append(name, LogLevel.DEBUG, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInfoEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String msg) {
|
||||
info(msg, (Throwable) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object arg) {
|
||||
info(String.format(format, arg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object arg1, Object arg2) {
|
||||
info(String.format(format, arg1, arg2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String format, Object... arguments) {
|
||||
info(String.format(format, arguments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String msg, Throwable t) {
|
||||
APPENDER.append(name, LogLevel.INFO, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWarnEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String msg) {
|
||||
warn(msg, (Throwable) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object arg) {
|
||||
warn(String.format(format, arg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object... arguments) {
|
||||
warn(String.format(format, arguments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String format, Object arg1, Object arg2) {
|
||||
warn(String.format(format, arg1, arg2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String msg, Throwable t) {
|
||||
APPENDER.append(name, LogLevel.WARNING, msg, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isErrorEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg) {
|
||||
error(msg, (Throwable) null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object arg) {
|
||||
error(String.format(format, arg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object arg1, Object arg2) {
|
||||
error(String.format(format, arg1, arg2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String format, Object... arguments) {
|
||||
error(String.format(format, arguments));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String msg, Throwable t) {
|
||||
APPENDER.append(name, LogLevel.ERROR, msg, t);
|
||||
}
|
||||
}
|
@ -16,9 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger.backend;
|
||||
package com.discordsrv.logging.backend;
|
||||
|
||||
import com.discordsrv.common.logging.logger.LogLevel;
|
||||
import com.discordsrv.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -16,9 +16,9 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger.backend;
|
||||
package com.discordsrv.logging.backend;
|
||||
|
||||
import com.discordsrv.common.logging.logger.LogLevel;
|
||||
import com.discordsrv.logging.LogLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger.backend;
|
||||
package com.discordsrv.logging.backend;
|
||||
|
||||
public interface LoggingBackend {
|
||||
|
@ -16,13 +16,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger.impl;
|
||||
package com.discordsrv.logging.impl;
|
||||
|
||||
import com.discordsrv.common.logging.logger.LogLevel;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.common.logging.logger.backend.LogAppender;
|
||||
import com.discordsrv.common.logging.logger.backend.LogFilter;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.logging.LogLevel;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.logging.backend.LogAppender;
|
||||
import com.discordsrv.logging.backend.LogFilter;
|
||||
import com.discordsrv.logging.backend.LoggingBackend;
|
||||
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
@ -16,13 +16,13 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger.impl;
|
||||
package com.discordsrv.logging.impl;
|
||||
|
||||
import com.discordsrv.common.logging.logger.LogLevel;
|
||||
import com.discordsrv.common.logging.logger.backend.LogAppender;
|
||||
import com.discordsrv.common.logging.logger.backend.LogFilter;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.LogLevel;
|
||||
import com.discordsrv.logging.backend.LogAppender;
|
||||
import com.discordsrv.logging.backend.LogFilter;
|
||||
import com.discordsrv.logging.backend.LoggingBackend;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import org.apache.commons.collections4.bidimap.DualHashBidiMap;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
@ -16,10 +16,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.discordsrv.common.logging.logger.impl;
|
||||
package com.discordsrv.logging.impl;
|
||||
|
||||
import com.discordsrv.common.logging.logger.LogLevel;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.LogLevel;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import com.discordsrv.logging.adapter.DependencyLoggerAdapter;
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
public class DiscordSRVLoggerFactory implements ILoggerFactory {
|
||||
|
||||
private final ConcurrentMap<String, DependencyLoggerAdapter> loggerMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public Logger getLogger(String s) {
|
||||
return loggerMap.computeIfAbsent(s.toLowerCase(Locale.ROOT), DependencyLoggerAdapter::new);
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.spi.LoggerFactoryBinder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class StaticLoggerBinder implements LoggerFactoryBinder {
|
||||
|
||||
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
|
||||
|
||||
public static StaticLoggerBinder getSingleton() {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
// to avoid constant folding by the compiler, this field must *not* be final
|
||||
public static String REQUESTED_API_VERSION = "1.6.99"; // !final
|
||||
|
||||
private static final String loggerFactoryClassStr = DiscordSRVLoggerFactory.class.getName();
|
||||
|
||||
private final ILoggerFactory loggerFactory;
|
||||
|
||||
private StaticLoggerBinder() {
|
||||
loggerFactory = new DiscordSRVLoggerFactory();
|
||||
}
|
||||
|
||||
public ILoggerFactory getLoggerFactory() {
|
||||
return loggerFactory;
|
||||
}
|
||||
|
||||
public String getLoggerFactoryClassStr() {
|
||||
return loggerFactoryClassStr;
|
||||
}
|
||||
}
|
42
common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java
Normal file
42
common/api/src/main/java/org/slf4j/impl/StaticMDCBinder.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.helpers.BasicMDCAdapter;
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class StaticMDCBinder {
|
||||
|
||||
public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
|
||||
|
||||
private StaticMDCBinder() {}
|
||||
|
||||
public static StaticMDCBinder getSingleton() {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
public MDCAdapter getMDCA() {
|
||||
return new BasicMDCAdapter();
|
||||
}
|
||||
|
||||
public String getMDCAdapterClassStr() {
|
||||
return BasicMDCAdapter.class.getName();
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is part of DiscordSRV, licensed under the GPLv3 License
|
||||
* Copyright (c) 2016-2021 Austin "Scarsz" Shapiro, Henri "Vankka" Schubin and DiscordSRV contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.IMarkerFactory;
|
||||
import org.slf4j.helpers.BasicMarkerFactory;
|
||||
import org.slf4j.spi.MarkerFactoryBinder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class StaticMarkerBinder implements MarkerFactoryBinder {
|
||||
|
||||
public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
|
||||
|
||||
final IMarkerFactory markerFactory = new BasicMarkerFactory();
|
||||
|
||||
private StaticMarkerBinder() {}
|
||||
|
||||
public static StaticMarkerBinder getSingleton() {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
public IMarkerFactory getMarkerFactory() {
|
||||
return markerFactory;
|
||||
}
|
||||
|
||||
public String getMarkerFactoryClassStr() {
|
||||
return BasicMarkerFactory.class.getName();
|
||||
}
|
||||
|
||||
}
|
@ -20,8 +20,8 @@ task generateResourceForMySQLDriver(type: GenerateDependencyDownloadResourceTask
|
||||
dependencies {
|
||||
// API
|
||||
annotationProcessor project(':api')
|
||||
compileOnlyApi project(':api')
|
||||
testImplementation project(':api')
|
||||
compileOnlyApi project(':common:common-api')
|
||||
testImplementation project(':common:common-api')
|
||||
|
||||
// DependencyDownload
|
||||
api 'dev.vankka.dependencydownload:runtime:' + rootProject.ddVersion
|
||||
@ -51,10 +51,6 @@ dependencies {
|
||||
// Database Drivers
|
||||
h2Driver 'com.h2database:h2:1.4.200'
|
||||
mysqlDriver 'mysql:mysql-connector-java:8.0.25'
|
||||
|
||||
// Logging (provided by platforms)
|
||||
compileOnlyApi 'org.apache.logging.log4j:log4j-core:2.0-beta9'
|
||||
compileOnlyApi 'org.slf4j:slf4j-api:1.7.32'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -40,11 +40,11 @@ import com.discordsrv.common.listener.ChannelLookupListener;
|
||||
import com.discordsrv.common.listener.DiscordAPIListener;
|
||||
import com.discordsrv.common.listener.DiscordChatListener;
|
||||
import com.discordsrv.common.listener.GameChatListener;
|
||||
import com.discordsrv.common.logging.DependencyLoggingFilter;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.common.logging.DependencyLoggingHandler;
|
||||
import com.discordsrv.common.placeholder.ComponentResultStringifier;
|
||||
import com.discordsrv.common.placeholder.PlaceholderServiceImpl;
|
||||
import com.discordsrv.common.placeholder.context.GlobalTextHandlingContext;
|
||||
import com.discordsrv.logging.adapter.DependencyLoggerAdapter;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -79,7 +79,6 @@ public abstract class AbstractDiscordSRV<C extends MainConfig, CC extends Connec
|
||||
|
||||
// Internal
|
||||
private final ReentrantLock lifecycleLock = new ReentrantLock();
|
||||
private final DependencyLoggingFilter dependencyLoggingFilter = new DependencyLoggingFilter(this);
|
||||
|
||||
public AbstractDiscordSRV() {
|
||||
ApiInstanceUtil.setInstance(this);
|
||||
@ -224,6 +223,9 @@ public abstract class AbstractDiscordSRV<C extends MainConfig, CC extends Connec
|
||||
+ getClass().getName() + " constructor");
|
||||
}
|
||||
|
||||
// Logging
|
||||
DependencyLoggerAdapter.setAppender(new DependencyLoggingHandler(this));
|
||||
|
||||
// Config
|
||||
try {
|
||||
connectionConfigManager().load();
|
||||
@ -238,10 +240,6 @@ public abstract class AbstractDiscordSRV<C extends MainConfig, CC extends Connec
|
||||
throw t;
|
||||
}
|
||||
|
||||
// Logging
|
||||
LoggingBackend backend = console().loggingBackend();
|
||||
backend.addFilter(dependencyLoggingFilter);
|
||||
|
||||
discordConnectionManager = new JDAConnectionManager(this);
|
||||
discordConnectionManager.connect().join();
|
||||
|
||||
@ -270,10 +268,6 @@ public abstract class AbstractDiscordSRV<C extends MainConfig, CC extends Connec
|
||||
}
|
||||
this.status.set(Status.SHUTTING_DOWN);
|
||||
eventBus().publish(new DiscordSRVShuttingDownEvent());
|
||||
|
||||
// Logging
|
||||
LoggingBackend backend = console().loggingBackend();
|
||||
backend.removeFilter(dependencyLoggingFilter);
|
||||
}
|
||||
|
||||
@OverridingMethodsMustInvokeSuper
|
||||
|
@ -29,7 +29,7 @@ import com.discordsrv.common.config.manager.MainConfigManager;
|
||||
import com.discordsrv.common.console.Console;
|
||||
import com.discordsrv.common.discord.api.DiscordAPIImpl;
|
||||
import com.discordsrv.common.discord.connection.DiscordConnectionManager;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.common.placeholder.PlaceholderServiceImpl;
|
||||
import com.discordsrv.common.player.provider.AbstractPlayerProvider;
|
||||
import com.discordsrv.common.scheduler.Scheduler;
|
||||
|
@ -19,7 +19,7 @@
|
||||
package com.discordsrv.common.console;
|
||||
|
||||
import com.discordsrv.common.command.game.sender.ICommandSender;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.logging.backend.LoggingBackend;
|
||||
|
||||
public interface Console extends ICommandSender {
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
package com.discordsrv.common.dependency;
|
||||
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.common.scheduler.threadfactory.CountingForkJoinWorkerThreadFactory;
|
||||
import dev.vankka.dependencydownload.classpath.ClasspathAppender;
|
||||
|
||||
|
@ -19,14 +19,14 @@
|
||||
package com.discordsrv.common.logging;
|
||||
|
||||
import com.discordsrv.common.DiscordSRV;
|
||||
import com.discordsrv.common.logging.logger.LogLevel;
|
||||
import com.discordsrv.common.logging.logger.backend.LogFilter;
|
||||
import com.discordsrv.logging.LogLevel;
|
||||
import com.discordsrv.logging.backend.LogAppender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class DependencyLoggingFilter implements LogFilter {
|
||||
public class DependencyLoggingHandler implements LogAppender {
|
||||
|
||||
private static final Map<String, List<String>> BLACKLISTED_MESSAGES = new HashMap<>();
|
||||
private static final Map<String, String> LOGGER_MAPPINGS = new HashMap<>();
|
||||
@ -46,14 +46,15 @@ public class DependencyLoggingFilter implements LogFilter {
|
||||
|
||||
private final DiscordSRV discordSRV;
|
||||
|
||||
public DependencyLoggingFilter(DiscordSRV discordSRV) {
|
||||
public DependencyLoggingHandler(DiscordSRV discordSRV) {
|
||||
this.discordSRV = discordSRV;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result filter(@Nullable String loggerName, @NotNull LogLevel logLevel, @Nullable String message, @Nullable Throwable throwable) {
|
||||
public void append(@Nullable String loggerName, @NotNull LogLevel logLevel, @Nullable String message,
|
||||
@Nullable Throwable throwable) {
|
||||
if (loggerName == null || !loggerName.startsWith("com.discordsrv.dependencies")) {
|
||||
return Result.IGNORE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
@ -69,7 +70,7 @@ public class DependencyLoggingFilter implements LogFilter {
|
||||
// Go through the blacklisted messages we gathered
|
||||
for (String blacklistedMessage : blacklistedMessages) {
|
||||
if (message.contains(blacklistedMessage)) {
|
||||
return Result.BLOCK;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,6 +85,5 @@ public class DependencyLoggingFilter implements LogFilter {
|
||||
}
|
||||
|
||||
discordSRV.logger().log(logLevel, "[" + name + "]" + (message != null ? " " + message : ""), throwable);
|
||||
return Result.BLOCK;
|
||||
}
|
||||
}
|
@ -23,8 +23,8 @@ import com.discordsrv.common.config.main.MainConfig;
|
||||
import com.discordsrv.common.config.manager.ConnectionConfigManager;
|
||||
import com.discordsrv.common.config.manager.MainConfigManager;
|
||||
import com.discordsrv.common.console.Console;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.common.logging.logger.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.logging.impl.JavaLoggerImpl;
|
||||
import com.discordsrv.common.player.provider.AbstractPlayerProvider;
|
||||
import com.discordsrv.common.scheduler.Scheduler;
|
||||
import com.discordsrv.common.scheduler.StandardScheduler;
|
||||
|
@ -9,7 +9,7 @@ pluginManagement {
|
||||
rootProject.name = 'DiscordSRV2'
|
||||
|
||||
[
|
||||
'common', 'common:server', 'common:proxy',
|
||||
'common', 'common:api', 'common:server', 'common:proxy',
|
||||
'i18n',
|
||||
'api',
|
||||
'bukkit', 'bukkit:loader',
|
||||
|
@ -9,7 +9,7 @@ apply from: rootProject.file('buildscript/loader.gradle')
|
||||
|
||||
dependencies {
|
||||
// API
|
||||
implementation project(':api')
|
||||
implementation project(':common:common-api')
|
||||
|
||||
// DependencyDownload
|
||||
implementation 'dev.vankka.minecraftdependencydownload:jarinjar-loader:' + rootProject.mddVersion
|
||||
|
@ -19,8 +19,8 @@
|
||||
package com.discordsrv.sponge;
|
||||
|
||||
import com.discordsrv.common.dependency.InitialDependencyLoader;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.logging.impl.Log4JLoggerImpl;
|
||||
import com.discordsrv.sponge.bootstrap.ISpongeBootstrap;
|
||||
import dev.vankka.mcdependencydownload.bootstrap.AbstractBootstrap;
|
||||
import dev.vankka.mcdependencydownload.bootstrap.classpath.JarInJarClasspathAppender;
|
||||
|
@ -23,7 +23,7 @@ import com.discordsrv.common.config.connection.ConnectionConfig;
|
||||
import com.discordsrv.common.config.main.MainConfig;
|
||||
import com.discordsrv.common.config.manager.ConnectionConfigManager;
|
||||
import com.discordsrv.common.config.manager.MainConfigManager;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.common.server.ServerDiscordSRV;
|
||||
import com.discordsrv.sponge.console.SpongeConsole;
|
||||
import com.discordsrv.sponge.player.SpongePlayerProvider;
|
||||
|
@ -19,8 +19,8 @@
|
||||
package com.discordsrv.sponge.console;
|
||||
|
||||
import com.discordsrv.common.console.Console;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
|
||||
import com.discordsrv.logging.backend.LoggingBackend;
|
||||
import com.discordsrv.logging.impl.Log4JLoggerImpl;
|
||||
import com.discordsrv.sponge.SpongeDiscordSRV;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -9,7 +9,7 @@ var velocityVersion = '3.0.0'
|
||||
dependencies {
|
||||
// API
|
||||
annotationProcessor project(':api')
|
||||
implementation project(':api')
|
||||
implementation project(':common:common-api')
|
||||
|
||||
// Common
|
||||
implementation project(':common:common-proxy')
|
||||
|
@ -19,8 +19,8 @@
|
||||
package com.discordsrv.velocity;
|
||||
|
||||
import com.discordsrv.common.dependency.InitialDependencyLoader;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.common.logging.logger.impl.SLF4JLoggerImpl;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.logging.impl.SLF4JLoggerImpl;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
|
@ -22,7 +22,7 @@ import com.discordsrv.common.config.connection.ConnectionConfig;
|
||||
import com.discordsrv.common.config.main.MainConfig;
|
||||
import com.discordsrv.common.config.manager.ConnectionConfigManager;
|
||||
import com.discordsrv.common.config.manager.MainConfigManager;
|
||||
import com.discordsrv.common.logging.logger.Logger;
|
||||
import com.discordsrv.logging.Logger;
|
||||
import com.discordsrv.common.proxy.ProxyDiscordSRV;
|
||||
import com.discordsrv.common.scheduler.StandardScheduler;
|
||||
import com.discordsrv.velocity.console.VelocityConsole;
|
||||
|
@ -19,8 +19,8 @@
|
||||
package com.discordsrv.velocity.console;
|
||||
|
||||
import com.discordsrv.common.console.Console;
|
||||
import com.discordsrv.common.logging.logger.backend.LoggingBackend;
|
||||
import com.discordsrv.common.logging.logger.impl.Log4JLoggerImpl;
|
||||
import com.discordsrv.logging.backend.LoggingBackend;
|
||||
import com.discordsrv.logging.impl.Log4JLoggerImpl;
|
||||
import com.discordsrv.velocity.VelocityDiscordSRV;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
Loading…
Reference in New Issue
Block a user