Skip to content

Commit 69b4075

Browse files
author
TheProgramSrc
committed
Change log:
• Added a way to register the LogsFilter • Added option to hide or not the HikariCP Logs
1 parent 60278a6 commit 69b4075

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>xyz.theprogramsrc</groupId>
88
<artifactId>SuperCoreAPI</artifactId>
9-
<version>3.3.1</version>
9+
<version>3.3.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SuperCoreAPI</name>

src/main/java/xyz/theprogramsrc/supercoreapi/SuperPlugin.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package xyz.theprogramsrc.supercoreapi;
22

3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.core.Logger;
5+
import xyz.theprogramsrc.supercoreapi.global.LogsFilter;
36
import xyz.theprogramsrc.supercoreapi.global.dependencies.DependencyManager;
47
import xyz.theprogramsrc.supercoreapi.global.translations.TranslationManager;
58
import xyz.theprogramsrc.supercoreapi.global.translations.TranslationPack;
@@ -158,4 +161,13 @@ default String getPluginMessagingChannelName(){
158161
* Stops the plugin
159162
*/
160163
void emergencyStop();
164+
165+
/**
166+
* Registers a log filter
167+
* @param logsFilter the filter
168+
*/
169+
default void registerLogFilter(LogsFilter logsFilter){
170+
Logger consoleLogger = (Logger) LogManager.getRootLogger();
171+
consoleLogger.addFilter(logsFilter);
172+
}
161173
}

src/main/java/xyz/theprogramsrc/supercoreapi/global/storage/MySQLDataBase.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public abstract class MySQLDataBase implements DataBase{
1717
public MySQLDataBase(SuperPlugin<?> plugin){
1818
this.plugin = plugin;
1919
this.plugin.log("Connecting to '" + getDataBaseSettings().host() + ":" + getDataBaseSettings().port()+"'...");
20-
new LogsFilter(LogsFilter.FilterResult.DENY, "com.zaxxer.hikari");
20+
if(this.hideHikariLogs()){
21+
this.plugin.registerLogFilter(new LogsFilter(LogsFilter.FilterResult.DENY, "com.zaxxer.hikari"));
22+
}
2123
HikariConfig cfg = new HikariConfig();
2224
cfg.setJdbcUrl("jdbc:mysql://" + getDataBaseSettings().host() + ":" + getDataBaseSettings().port() + "/" + getDataBaseSettings().database() + "?useSSL=" + getDataBaseSettings().useSSL());
2325
cfg.setUsername(getDataBaseSettings().username());
@@ -70,4 +72,11 @@ public void connect(ConnectionCall call) {
7072
ex.printStackTrace();
7173
}
7274
}
75+
76+
/**
77+
* @return true to hide the hikaricp logs, otherwise false
78+
*/
79+
public boolean hideHikariLogs(){
80+
return true;
81+
}
7382
}

0 commit comments

Comments
 (0)