88 lines
2.7 KiB
Java
88 lines
2.7 KiB
Java
/*
|
|
* This file is part of ViaLoader - https://github.com/RaphiMC/ViaLoader
|
|
* Copyright (C) 2020-2024 RK_01/RaphiMC and 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package net.raphimc.vialoader.util;
|
|
|
|
import java.text.MessageFormat;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.LogRecord;
|
|
import java.util.logging.Logger;
|
|
|
|
public class JLoggerToSLF4J extends Logger {
|
|
|
|
private final org.slf4j.Logger base;
|
|
|
|
public JLoggerToSLF4J(org.slf4j.Logger logger) {
|
|
super("logger", null);
|
|
this.base = logger;
|
|
}
|
|
|
|
public void log(LogRecord record) {
|
|
this.log(record.getLevel(), record.getMessage());
|
|
}
|
|
|
|
public void log(Level level, String msg) {
|
|
if (level == Level.FINE) {
|
|
this.base.debug(msg);
|
|
} else if (level == Level.WARNING) {
|
|
this.base.warn(msg);
|
|
} else if (level == Level.SEVERE) {
|
|
this.base.error(msg);
|
|
} else if (level == Level.INFO) {
|
|
this.base.info(msg);
|
|
} else {
|
|
this.base.trace(msg);
|
|
}
|
|
|
|
}
|
|
|
|
public void log(Level level, String msg, Object param1) {
|
|
if (level == Level.FINE) {
|
|
this.base.debug(msg, param1);
|
|
} else if (level == Level.WARNING) {
|
|
this.base.warn(msg, param1);
|
|
} else if (level == Level.SEVERE) {
|
|
this.base.error(msg, param1);
|
|
} else if (level == Level.INFO) {
|
|
this.base.info(msg, param1);
|
|
} else {
|
|
this.base.trace(msg, param1);
|
|
}
|
|
|
|
}
|
|
|
|
public void log(Level level, String msg, Object[] params) {
|
|
log(level, MessageFormat.format(msg, params));
|
|
}
|
|
|
|
public void log(Level level, String msg, Throwable params) {
|
|
if (level == Level.FINE) {
|
|
this.base.debug(msg, params);
|
|
} else if (level == Level.WARNING) {
|
|
this.base.warn(msg, params);
|
|
} else if (level == Level.SEVERE) {
|
|
this.base.error(msg, params);
|
|
} else if (level == Level.INFO) {
|
|
this.base.info(msg, params);
|
|
} else {
|
|
this.base.trace(msg, params);
|
|
}
|
|
|
|
}
|
|
|
|
}
|