Skip to content

Commit

Permalink
Merge pull request #18 from heesane/main
Browse files Browse the repository at this point in the history
Syncronized
  • Loading branch information
heesane authored Aug 3, 2024
2 parents 5508f7e + 465b5e1 commit d734edb
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package hhs.server.api;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;


@Slf4j
@ComponentScan(basePackages = "hhs.server")
@EntityScan(basePackages = "hhs.server.domain")
@EnableJpaRepositories(basePackages = "hhs.server.domain.repository")
@SpringBootApplication
public class ApiApplication {
public static void main(String[] args) {
MDC.put("moduleName","API");
log.info("Starting API module");
SpringApplication.run(ApiApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package hhs.server.batch;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;

@Slf4j
@EntityScan(basePackages = {"hhs.server.domain", "hhs.server.common"})
@SpringBootApplication(scanBasePackages = "hhs.server")
public class BatchApplication {
public static void main(String[] args) {
MDC.put("moduleName","BATCH");
log.info("Starting Batch module");
SpringApplication.run(BatchApplication.class, args);
}
}
3 changes: 3 additions & 0 deletions back/home_server/common-module/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ dependencies {

// Rabbit MQ
implementation 'org.springframework.boot:spring-boot-starter-amqp'

// Loggers
implementation 'ch.qos.logback:logback-classic'
}

jar {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<configuration>
<property name="LOG_DIR" value="./logs" />
<property name="LOG_FILE_NAME" value="serverLog" />

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%X{moduleName}] %d{HH:mm:ss.SSS} %highlight(%-5level) %magenta(%-4relative) --- [ %thread{10} ] %cyan(%logger{29}) - %msg%n</pattern>
</encoder>
</appender>

<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}/${LOG_FILE_NAME}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_DIR}/${LOG_FILE_NAME}-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>10MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>[%X{moduleName}] %d{HH:mm:ss.SSS} [ %thread ] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<logger name="org.springframework" level="INFO"/>
<logger name="org.hibernate" level="INFO"/>
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package hhs.server.discord;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@Slf4j
@SpringBootApplication
public class DiscordApplication {
public static void main(String[] args) {
MDC.put("moduleName","DISCORD");
log.info("Starting Discord module");
SpringApplication.run(DiscordApplication.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.slf4j.MDC;

import java.util.Arrays;

Expand All @@ -14,6 +15,9 @@ public class DiscordCommandListener extends ListenerAdapter {

@Override
public void onMessageReceived(MessageReceivedEvent event) {

MDC.put("moduleName", "DISCORD COMMAND");

User user = event.getAuthor();
TextChannel textChannel = event.getChannel().asTextChannel();
Message message = event.getMessage();
Expand Down Expand Up @@ -42,7 +46,7 @@ public void onMessageReceived(MessageReceivedEvent event) {
private String sendMessage(MessageReceivedEvent event, String message) {
User user = event.getAuthor();

String returnMessage = switch (message) {
return switch (message) {
case "안녕하세요" -> user.getAsMention() + "님 안녕하세요! 좋은 하루 되세요";
case "site" -> "https://www.heesang.pro";
case "hi" -> "Hello " + user.getAsTag();
Expand All @@ -51,7 +55,5 @@ private String sendMessage(MessageReceivedEvent event, String message) {
case "2" -> user.getName() + " / 2번 옵션";
default -> "못 알아 듣겠어요 죄송합니다.";
};

return returnMessage;
}
}

0 comments on commit d734edb

Please sign in to comment.