Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncronized #18

Merged
merged 7 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading