Git Product home page Git Product logo

jdaappender's Introduction

JDA Appender

Library for Java applications that use JDA to easily stream the logging output of the application to a text channel on Discord.

[insert screenshot here]

Usage

Using default values:

ChannelLoggingHandler handler = new ChannelLoggingHandler(() -> jda.getTextChannelById(System.getenv("CHANNEL")))
        .attach() // attach to SLF4J JDK logging if present, else Log4j if present, else standard out/err
        .schedule(); // schedule handler to flush output asynchronously every 1.5 seconds

Customizing config values, such as adding a logger name mapping:

ChannelLoggingHandler handler = new ChannelLoggingHandler(() -> jda.getTextChannelById(System.getenv("CHANNEL")), config -> {
    config.setColored(true); // enable coloring of different log levels, default true
    config.setSplitCodeBlockForLinks(false); // split the output code blocks when a link is present, default false
    config.setAllowLinkEmbeds(true); // when splitting code blocks for links, allow the links to have an embed, default true
    config.mapLoggerName("net.dv8tion.jda", "JDA"); // add a mapping for logger names "net.dv8tion.jda*" to just be "JDA"
}).attach().schedule();

Artifact

<repository>
    <id>scarsz</id>
    <url>https://nexus.scarsz.me/content/repositories/releases/</url>
</repository>
<dependency>
    <groupId>me.scarsz</groupId>
    <artifactId>jdaappender</artifactId>
    <version>1.0.2-SNAPSHOT</version>
</dependency>

Using with SLF4J-backed apps with minimal effort (JDA, ...)

Use slf4j-jdk14 as your SLF4J logging backend. This will forward SLF4J messages to java.util.logging and can be picked up by JDAAppender with ChannelLoggingHandler#attachJavaLogging.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-jdk14</artifactId>
    <version>1.7.31</version>
</dependency>

jdaappender's People

Contributors

scarsz avatar vankka avatar actions-user avatar nightpool avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.