Skip to content
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
Expand Up @@ -5,6 +5,7 @@
import com.vaadin.flow.component.page.Push;
import com.vaadin.flow.server.PWA;
import com.vaadin.flow.theme.Theme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down Expand Up @@ -34,9 +35,11 @@
@Push
public class Application extends SpringBootServletInitializer implements AppShellConfigurator {

private static final Logger applicationLogger = LoggerFactory.getLogger(Application.class);

public static void main(String[] args) {
if (args.length > 1) {
LoggerFactory.getLogger(Application.class)
applicationLogger
.error("Usage: Provide a single Argument, containing the Path to the Config-File");
System.exit(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.togetherjava.tjbot.logwatcher;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.config.BeanDefinition;
Expand All @@ -21,6 +22,8 @@ public class DatabaseProvider {
private final Database db;
private final Config config;

private static final Logger logger = LoggerFactory.getLogger(DatabaseProvider.class);

public DatabaseProvider(final Config config) {
this.config = config;
this.db = createDB();
Expand All @@ -34,8 +37,7 @@ private Database createDB() {
try {
return new Database("jdbc:sqlite:%s".formatted(dbPath.toAbsolutePath()));
} catch (final SQLException e) {
LoggerFactory.getLogger(DatabaseProvider.class)
.error("Exception while creating Database.", e);
logger.error("Exception while creating Database.", e);
throw new FatalBeanException("Could not create Database.", e);
}
}
Expand All @@ -46,8 +48,7 @@ private Path getDBPath() {
try {
Files.createDirectories(dbPath.getParent());
} catch (final IOException e) {
LoggerFactory.getLogger(DatabaseProvider.class)
.error("Exception while creating Database-Path.", e);
logger.error("Exception while creating Database-Path.", e);
}

return dbPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.vaadin.flow.component.html.*;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.RouterLink;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.togetherjava.tjbot.logwatcher.accesscontrol.AllowedRoles;
import org.togetherjava.tjbot.logwatcher.accesscontrol.Role;
Expand All @@ -33,6 +34,7 @@ public class MainLayout extends AppLayout {

private final transient AuthenticatedUser authenticatedUser;
private H1 viewTitle;
private static final Logger logger = LoggerFactory.getLogger(MainLayout.class);

public MainLayout(AuthenticatedUser authUser) {
this.authenticatedUser = authUser;
Expand Down Expand Up @@ -124,8 +126,7 @@ private boolean checkAccess(MenuItemInfo menuItemInfo) {
final AllowedRoles annotation = view.getAnnotation(AllowedRoles.class);

if (annotation == null) {
LoggerFactory.getLogger(MainLayout.class)
.warn("Class {} not properly secured with Annotation", view);
logger.warn("Class {} not properly secured with Annotation", view);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouteAlias;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.togetherjava.tjbot.logwatcher.accesscontrol.AllowedRoles;
import org.togetherjava.tjbot.logwatcher.accesscontrol.Role;
Expand Down Expand Up @@ -43,6 +44,8 @@
@PermitAll
public class LogsView extends VerticalLayout {

private static final Logger logger = LoggerFactory.getLogger(LogsView.class);

private static final Pattern LOGLEVEL_MATCHER =
Pattern.compile("(%s)".formatted(String.join("|", LogUtils.LogLevel.getAllNames())));

Expand Down Expand Up @@ -156,7 +159,7 @@ private List<Path> getLogFiles() {
try {
return this.watcher.getLogs();
} catch (final UncheckedIOException e) {
LoggerFactory.getLogger(LogsView.class).error("Exception while gathering LogFiles", e);
logger.error("Exception while gathering LogFiles", e);
NotificationUtils.getNotificationForError(e).open();
return Collections.emptyList();
}
Expand All @@ -172,7 +175,7 @@ private List<String> getLogEntries(final Path logFile) {
try {
return this.watcher.readLog(logFile);
} catch (final UncheckedIOException e) {
LoggerFactory.getLogger(LogsView.class).error("Exception while gathering LogFiles", e);
logger.error("Exception while gathering LogFiles", e);
NotificationUtils.getNotificationForError(e).open();
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.vaadin.flow.data.provider.Query;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.togetherjava.tjbot.logwatcher.accesscontrol.AllowedRoles;
import org.togetherjava.tjbot.logwatcher.accesscontrol.Role;
Expand Down Expand Up @@ -42,6 +43,7 @@ public class UserManagement extends VerticalLayout {

private final transient UserRepository repo;
private final Grid<UserWrapper> grid = new Grid<>(UserWrapper.class, false);
private static final Logger logger = LoggerFactory.getLogger(UserManagement.class);

public UserManagement(UserRepository repository) {
this.repo = repository;
Expand Down Expand Up @@ -81,8 +83,7 @@ private Stream<UserWrapper> onAll(Query<UserWrapper, Void> query) {
.map(user -> new UserWrapper(user.getDiscordid(), user.getUsername(),
this.repo.fetchRolesForUser(user)));
} catch (final DatabaseException e) {
LoggerFactory.getLogger(UserManagement.class)
.error("Exception occurred while fetching.", e);
logger.error("Exception occurred while fetching.", e);
NotificationUtils.getNotificationForError(e).open();
return Stream.empty();
}
Expand Down Expand Up @@ -133,8 +134,7 @@ private void doUpdate(UserWrapper user) {

UserManagement.this.repo.saveRolesForUser(toSave, user.getRoles());
} catch (DatabaseException e) {
LoggerFactory.getLogger(UserManagement.class)
.error("Exception occurred while saving.", e);
logger.error("Exception occurred while saving.", e);
NotificationUtils.getNotificationForError(e).open();
}

Expand Down Expand Up @@ -193,8 +193,7 @@ private void doRemove(UserWrapper user) {
try {
UserManagement.this.repo.delete(new Users(user.getDiscordID(), user.getUserName()));
} catch (DatabaseException e) {
LoggerFactory.getLogger(UserManagement.class)
.error("Exception occurred while removing.", e);
logger.error("Exception occurred while removing.", e);
NotificationUtils.getNotificationForError(e).open();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.togetherjava.tjbot.logwatcher.watcher;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
Expand All @@ -10,6 +11,7 @@ public class StreamWatcher {
private static final int EXPECTED_CONCURRENT_LOG_WATCHERS = 3;
private static final Map<UUID, Runnable> consumerMap =
new ConcurrentHashMap<>(EXPECTED_CONCURRENT_LOG_WATCHERS);
private static final Logger logger = LoggerFactory.getLogger(StreamWatcher.class);

private StreamWatcher() {}

Expand Down Expand Up @@ -48,7 +50,7 @@ private static void notifySubscriber(Runnable run) {
try {
run.run();
} catch (final Exception e) {
LoggerFactory.getLogger(StreamWatcher.class).error("Runnable threw Exception.", e);
logger.error("Runnable threw Exception.", e);
}
}
}