added logging to initializer service

This commit is contained in:
Rohan Sircar 2019-11-21 22:14:46 +05:30
parent f72f1b76fe
commit bee90dcef0

View File

@ -15,6 +15,8 @@ import java.util.stream.Collectors;
import org.ros.chatto.model.ApplicationStatus;
import org.ros.chatto.model.UserSession;
import org.ros.chatto.repository.UserSessionRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@ -53,6 +55,8 @@ public class DBInitializerService {
@Autowired
private UserSessionRepository userSessionRepository;
private final Logger logger = LoggerFactory.getLogger(DBInitializerService.class);
public void connectDB() throws SQLException {
connection = DriverManager.getConnection(url, userName, password);
@ -79,13 +83,14 @@ public class DBInitializerService {
connectDB();
System.out.println("Hello world, I have just started up");
logger.info("Application Started - running initializer service");
// System.out.println("Checking database and application state");
//
if (getNumTables() == 0)
if (getNumTables() == 0) {
logger.info("Database is empty. Populating tables and roles");
populateDB();
}
closeConnection();
resetAllUserSessions(userSessionRepository.findAll());