Skip to content

Commit

Permalink
JDA4/5 submodules, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Scarsz committed Dec 15, 2023
1 parent 3986b95 commit 492f303
Show file tree
Hide file tree
Showing 22 changed files with 709 additions and 85 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ChannelLoggingHandler handler = new ChannelLoggingHandler(() -> jda.getTextChann
<dependency>
<groupId>me.scarsz</groupId>
<artifactId>jdaappender</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.2.0-SNAPSHOT</version>
</dependency>
```

Expand Down
62 changes: 62 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>me.scarsz.jdaappender</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
</parent>

<artifactId>common</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>9.0.4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>

<!-- logging frameworks -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.31</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.32</version>
<scope>provided</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.7</version>
<scope>provided</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta9</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package me.scarsz.jdaappender;

import java.util.concurrent.ScheduledFuture;

public interface IChannelLoggingHandler {

void flush();

void enqueue(LogItem logItem);

ScheduledFuture<?> getScheduledFuture();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import net.dv8tion.jda.api.entities.Message;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -20,7 +19,7 @@
*/
public class LogItem {

public static final int CLIPPING_MAX_LENGTH = Message.MAX_CONTENT_LENGTH - 20;
public static final int CLIPPING_MAX_LENGTH = 2000 - 20;

@Getter private final String logger;
@Getter private final long timestamp;
Expand Down Expand Up @@ -66,7 +65,7 @@ protected String format(@NotNull HandlerConfig config) {
}

/**
* Clip the log item's message content if it exceeds {@link Message#MAX_CONTENT_LENGTH}
* Clip the log item's message content if it exceeds {@link LogItem#CLIPPING_MAX_LENGTH}
* @param config the appender config
* @return a new {@link LogItem} containing excess characters from this LogItem,
* null if no clipping was performed
Expand All @@ -77,7 +76,7 @@ protected LogItem clip(@NotNull HandlerConfig config) {
}
/**
* Clip the log item's message content into a maximum of specified number of log items, if it exceeds
* {@link Message#MAX_CONTENT_LENGTH}
* {@link LogItem#CLIPPING_MAX_LENGTH}
* @param config the appender config
* @param max the maximum amount of {@link LogItem}s to clip from this message
* @return a set containing {@link LogItem}s formed from excess characters in this LogItem,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.scarsz.jdaappender.adapter;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import me.scarsz.jdaappender.IChannelLoggingHandler;
import me.scarsz.jdaappender.LogItem;
import me.scarsz.jdaappender.LogLevel;

Expand All @@ -14,9 +14,9 @@

public class JavaLoggingAdapter extends Handler {

private final ChannelLoggingHandler handler;
private final IChannelLoggingHandler handler;

public JavaLoggingAdapter(ChannelLoggingHandler handler) {
public JavaLoggingAdapter(IChannelLoggingHandler handler) {
this.handler = handler;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.scarsz.jdaappender.adapter;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import me.scarsz.jdaappender.IChannelLoggingHandler;
import me.scarsz.jdaappender.LogItem;
import me.scarsz.jdaappender.LogLevel;
import org.apache.logging.log4j.Level;
Expand Down Expand Up @@ -42,9 +42,9 @@ public class Log4JLoggingAdapter extends AbstractAppender {
}
}

private final ChannelLoggingHandler handler;
private final IChannelLoggingHandler handler;

public Log4JLoggingAdapter(ChannelLoggingHandler handler) {
public Log4JLoggingAdapter(IChannelLoggingHandler handler) {
super("JDAAppender", null, PATTERN_LAYOUT, false);
this.handler = handler;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.ThrowableProxy;
import ch.qos.logback.core.AppenderBase;
import me.scarsz.jdaappender.ChannelLoggingHandler;
import me.scarsz.jdaappender.IChannelLoggingHandler;
import me.scarsz.jdaappender.LogItem;
import me.scarsz.jdaappender.LogLevel;

public class LogbackLoggingAdapter extends AppenderBase<ILoggingEvent> {

private final ChannelLoggingHandler handler;
private final IChannelLoggingHandler handler;

public LogbackLoggingAdapter(ChannelLoggingHandler handler, LoggerContext context) {
public LogbackLoggingAdapter(IChannelLoggingHandler handler, LoggerContext context) {
this.handler = handler;
setContext(context);
this.start();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.scarsz.jdaappender.adapter;

import lombok.Getter;
import me.scarsz.jdaappender.ChannelLoggingHandler;
import me.scarsz.jdaappender.IChannelLoggingHandler;
import me.scarsz.jdaappender.LogItem;
import me.scarsz.jdaappender.LogLevel;
import org.jetbrains.annotations.NotNull;
Expand All @@ -13,7 +13,7 @@ public class SystemLoggingAdapter {
@Getter private final LogStream outStream;
@Getter private final LogStream errStream;

public SystemLoggingAdapter(ChannelLoggingHandler handler) {
public SystemLoggingAdapter(IChannelLoggingHandler handler) {
this.outStream = new LogStream(System.out, "SOUT", LogLevel.INFO, handler);
this.errStream = new LogStream(System.err, "SERR", LogLevel.ERROR, handler);
}
Expand All @@ -22,9 +22,9 @@ static class LogStream extends PrintStream {

private final String loggerName;
private final LogLevel level;
private final ChannelLoggingHandler handler;
private final IChannelLoggingHandler handler;

public LogStream(PrintStream standardStream, String loggerName, LogLevel level, ChannelLoggingHandler handler) {
public LogStream(PrintStream standardStream, String loggerName, LogLevel level, IChannelLoggingHandler handler) {
super(standardStream, true);
this.loggerName = loggerName;
this.level = level;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package me.your.app;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import me.scarsz.jdaappender.ExtensionBuilder;
import net.dv8tion.jda.api.JDA;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package me.your.app;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package me.your.app;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package me.your.app;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package me.your.app;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package me.your.app;

import me.scarsz.jdaappender.ChannelLoggingHandler;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
Expand Down
86 changes: 86 additions & 0 deletions jda4/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>me.scarsz.jdaappender</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
</parent>

<artifactId>jda4</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>dv8tion</id>
<url>https://m2.dv8tion.net/releases</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>me.scarsz.jdaappender</groupId>
<artifactId>common</artifactId>
</dependency>

<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.4.0_351</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit 492f303

Please sign in to comment.