Skip to content

Commit

Permalink
Development: Unify logger usage (#7858)
Browse files Browse the repository at this point in the history
  • Loading branch information
Strohgelaender authored Jan 12, 2024
1 parent d01d014 commit 4382c08
Show file tree
Hide file tree
Showing 313 changed files with 388 additions and 374 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Aspect
public class LoggingAspect {

private final Logger log = LoggerFactory.getLogger(this.getClass());
private static final Logger log = LoggerFactory.getLogger(LoggingAspect.class);

private final Environment env;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@Component
public class ApiVersionFilter implements Filter {

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

public static final String CONTENT_VERSION_HEADER = "Content-Version";

Expand All @@ -44,7 +44,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
final HttpServletRequest httpRequest = (HttpServletRequest) request;
final HttpServletResponse httpResponse = (HttpServletResponse) response;

logger.debug("Adding Version to Request {} {}", httpRequest.getMethod(), httpRequest.getRequestURI());
log.debug("Adding Version to Request {} {}", httpRequest.getMethod(), httpRequest.getRequestURI());

httpResponse.addHeader(CONTENT_VERSION_HEADER, VERSION);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@EnableScheduling
public class AsyncConfiguration implements AsyncConfigurer {

private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class);

private final TaskExecutionProperties taskExecutionProperties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@EnableCaching
public class CacheConfiguration {

private final Logger log = LoggerFactory.getLogger(CacheConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(CacheConfiguration.class);

private GitProperties gitProperties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Configuration
public class LiquibaseConfiguration {

private final Logger log = LoggerFactory.getLogger(LiquibaseConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(LiquibaseConfiguration.class);

private final Environment env;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
@Component
public class MetricsBean {

private final Logger log = LoggerFactory.getLogger(MetricsBean.class);
private static final Logger log = LoggerFactory.getLogger(MetricsBean.class);

private static final String ARTEMIS_HEALTH_NAME = "artemis.health";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@ConfigurationProperties(prefix = "artemis.continuous-integration.build")
public class ProgrammingLanguageConfiguration {

private final Logger log = LoggerFactory.getLogger(ProgrammingLanguageConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(ProgrammingLanguageConfiguration.class);

private static final ProjectType DEFAULT_PROJECT_TYPE = ProjectType.PLAIN;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// https://github.com/ls1intum/Artemis/pull/5721.
public class SAML2Configuration extends WebSecurityConfigurerAdapter {

private final Logger log = LoggerFactory.getLogger(SAML2Configuration.class);
private static final Logger log = LoggerFactory.getLogger(SAML2Configuration.class);

private final SAML2Properties properties;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Profile({ JHipsterConstants.SPRING_PROFILE_PRODUCTION })
public class SentryConfiguration {

private final Logger log = LoggerFactory.getLogger(SentryConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(SentryConfiguration.class);

@Value("${artemis.version}")
private String artemisVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@EnableScheduling
public class TaskSchedulingConfiguration {

private final Logger log = LoggerFactory.getLogger(TaskSchedulingConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(TaskSchedulingConfiguration.class);

@Bean(name = "taskScheduler")
public TaskScheduler taskScheduler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@Configuration
public class WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> {

private final Logger log = LoggerFactory.getLogger(WebConfigurer.class);
private static final Logger log = LoggerFactory.getLogger(WebConfigurer.class);

private final Environment env;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Profile("localvc")
public class JGitServletConfiguration {

private final Logger log = LoggerFactory.getLogger(JGitServletConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(JGitServletConfiguration.class);

private final LocalVCServletService localVCServletService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class LocalCIConfiguration {

private final ProgrammingLanguageConfiguration programmingLanguageConfiguration;

private final Logger log = LoggerFactory.getLogger(LocalCIConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(LocalCIConfiguration.class);

@Value("${artemis.continuous-integration.queue-size-limit:30}")
int queueSizeLimit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Profile("scheduling")
public class MigrationService {

private final Logger log = LoggerFactory.getLogger(MigrationService.class);
private static final Logger log = LoggerFactory.getLogger(MigrationService.class);

@Value("${artemis.version}")
private String artemisVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class BambooMigrationService implements CIVCSMigrationService {

private Optional<Long> sharedCredentialId = Optional.empty();

private final Logger log = LoggerFactory.getLogger(BambooMigrationService.class);
private static final Logger log = LoggerFactory.getLogger(BambooMigrationService.class);

public BambooMigrationService(@Qualifier("bambooRestTemplate") RestTemplate restTemplate, BambooService bambooService, BambooInternalUrlService bambooInternalUrlService) {
this.restTemplate = restTemplate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@Profile("jenkins & gitlab")
public class GitLabJenkinsMigrationService implements CIVCSMigrationService {

private final Logger log = LoggerFactory.getLogger(GitLabJenkinsMigrationService.class);
private static final Logger log = LoggerFactory.getLogger(GitLabJenkinsMigrationService.class);

@Value("${server.url}")
private String artemisServerUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MigrationEntry20230808_203400 extends MigrationEntry {

private static final int TIMEOUT_IN_HOURS = 9;

private final Logger log = LoggerFactory.getLogger(MigrationEntry20230808_203400.class);
private static final Logger log = LoggerFactory.getLogger(MigrationEntry20230808_203400.class);

private final ProgrammingExerciseRepository programmingExerciseRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
public class MigrationEntry20230810_150000 extends MigrationEntry {

private final Logger log = LoggerFactory.getLogger(MigrationEntry20230810_150000.class);
private static final Logger log = LoggerFactory.getLogger(MigrationEntry20230810_150000.class);

private final ProgrammingExerciseRepository programmingExerciseRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class MigrationEntry20230920_181600 extends MigrationEntry {

private static final int TIMEOUT_IN_HOURS = 9;

private final Logger log = LoggerFactory.getLogger(MigrationEntry20230920_181600.class);
private static final Logger log = LoggerFactory.getLogger(MigrationEntry20230920_181600.class);

private final ProgrammingExerciseRepository programmingExerciseRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class MigrationEntry20231206_163000 extends MigrationEntry {

private static final List<String> MIGRATABLE_PROFILES = List.of("bamboo");

private final Logger log = LoggerFactory.getLogger(MigrationEntry20231206_163000.class);
private static final Logger log = LoggerFactory.getLogger(MigrationEntry20231206_163000.class);

private final ProgrammingExerciseRepository programmingExerciseRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
// See https://stackoverflow.com/a/34337731/3802758
public class WebsocketConfiguration extends DelegatingWebSocketMessageBrokerConfiguration {

private final Logger log = LoggerFactory.getLogger(WebsocketConfiguration.class);
private static final Logger log = LoggerFactory.getLogger(WebsocketConfiguration.class);

private static final Pattern EXAM_TOPIC_PATTERN = Pattern.compile("^/topic/exams/(\\d+)/.+$");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public abstract class Notification extends DomainObject {

@Transient
private final Logger log = LoggerFactory.getLogger(Notification.class);
private static final Logger log = LoggerFactory.getLogger(Notification.class);

@Column(name = "title")
private String title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@JsonInclude(NON_NULL) // needed for ObjectMapper to ignore null values
public class NotificationTarget {

private final Logger log = LoggerFactory.getLogger(NotificationTarget.class);
private static final Logger log = LoggerFactory.getLogger(NotificationTarget.class);

private String message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Table(name = "plagiarism_submission")
public class PlagiarismSubmission<E extends PlagiarismSubmissionElement> extends DomainObject {

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

/**
* ID of the wrapped submission object.
Expand Down Expand Up @@ -102,7 +102,7 @@ public static PlagiarismSubmission<TextSubmissionElement> fromJPlagSubmission(Su
submissionId = Long.parseLong(submissionIdAndStudentLogin[0]);
}
catch (NumberFormatException e) {
logger.error("Invalid submissionId: {}", e.getMessage());
log.error("Invalid submissionId: {}", e.getMessage());
}

studentLogin = submissionIdAndStudentLogin[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class DragAndDropQuestion extends QuizQuestion {

@Transient
private final transient Logger log = LoggerFactory.getLogger(DragAndDropQuestion.class);
private static final transient Logger log = LoggerFactory.getLogger(DragAndDropQuestion.class);

@Transient
private final transient FilePathService filePathService = new FilePathService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public class DragItem extends TempIdObject implements QuizQuestionComponent<DragAndDropQuestion> {

@Transient
private final transient Logger log = LoggerFactory.getLogger(DragItem.class);
private static final transient Logger log = LoggerFactory.getLogger(DragItem.class);

@Transient
private final transient FilePathService filePathService = new FilePathService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CustomAuditEventRepository implements AuditEventRepository {

private final AuditEventConverter auditEventConverter;

private final Logger log = LoggerFactory.getLogger(getClass());
private static final Logger log = LoggerFactory.getLogger(CustomAuditEventRepository.class);

public CustomAuditEventRepository(PersistenceAuditEventRepository persistenceAuditEventRepository, AuditEventConverter auditEventConverter) {
this.persistenceAuditEventRepository = persistenceAuditEventRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@Component("userDetailsService")
public class DomainUserDetailsService implements UserDetailsService {

private final Logger log = LoggerFactory.getLogger(DomainUserDetailsService.class);
private static final Logger log = LoggerFactory.getLogger(DomainUserDetailsService.class);

private final UserRepository userRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class OAuth2JWKSService {

private final StringKeyGenerator kidGenerator = new Base64StringKeyGenerator(32);

private final Logger log = LoggerFactory.getLogger(OAuth2JWKSService.class);
private static final Logger log = LoggerFactory.getLogger(OAuth2JWKSService.class);

private final Map<String, String> clientRegistrationIdToKeyId = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Component
public class TokenProvider {

private final Logger log = LoggerFactory.getLogger(TokenProvider.class);
private static final Logger log = LoggerFactory.getLogger(TokenProvider.class);

private static final String AUTHORITIES_KEY = "auth";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Lti13LaunchFilter extends OncePerRequestFilter {

private final AntPathRequestMatcher requestMatcher;

private final Logger log = LoggerFactory.getLogger(Lti13LaunchFilter.class);
private static final Logger log = LoggerFactory.getLogger(Lti13LaunchFilter.class);

public Lti13LaunchFilter(OAuth2LoginAuthenticationFilter defaultFilter, String filterProcessingUrl, Lti13Service lti13Service) {
this.defaultFilter = defaultFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Lti13TokenRetriever {

private final RestTemplate restTemplate;

private final Logger log = LoggerFactory.getLogger(Lti13TokenRetriever.class);
private static final Logger log = LoggerFactory.getLogger(Lti13TokenRetriever.class);

private static final int JWT_LIFETIME = 60;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class AbstractQuizSubmissionService<T extends AbstractQuizSubmis

private final SubmissionVersionService submissionVersionService;

private final Logger log = LoggerFactory.getLogger(AbstractQuizSubmissionService.class);
private static final Logger log = LoggerFactory.getLogger(AbstractQuizSubmissionService.class);

protected AbstractQuizSubmissionService(SubmissionVersionService submissionVersionService) {
this.submissionVersionService = submissionVersionService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@Service
public class AssessmentDashboardService {

private final Logger log = LoggerFactory.getLogger(AssessmentDashboardService.class);
private static final Logger log = LoggerFactory.getLogger(AssessmentDashboardService.class);

private final ComplaintService complaintService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@Service
public class AuditEventService {

private final Logger log = LoggerFactory.getLogger(AuditEventService.class);
private static final Logger log = LoggerFactory.getLogger(AuditEventService.class);

private final PersistenceAuditEventRepository persistenceAuditEventRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Service
public class CompetencyProgressService {

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

private final CompetencyRepository competencyRepository;

Expand Down Expand Up @@ -113,7 +113,7 @@ public void updateProgressByCompetencyAsync(Competency competency) {
* @param users A list of users for which to update the progress
*/
public void updateProgressByLearningObject(LearningObject learningObject, @NotNull Set<User> users) {
logger.debug("Updating competency progress for {} users.", users.size());
log.debug("Updating competency progress for {} users.", users.size());
try {
Set<Competency> competencies;
if (learningObject instanceof Exercise exercise) {
Expand All @@ -128,7 +128,7 @@ else if (learningObject instanceof LectureUnit lectureUnit) {

if (competencies == null) {
// Competencies couldn't be loaded, the exercise/lecture unit might have already been deleted
logger.debug("Competencies could not be fetched, skipping.");
log.debug("Competencies could not be fetched, skipping.");
return;
}

Expand All @@ -139,7 +139,7 @@ else if (learningObject instanceof LectureUnit lectureUnit) {
});
}
catch (Exception e) {
logger.error("Exception while updating progress for competency", e);
log.error("Exception while updating progress for competency", e);
}
}

Expand All @@ -154,7 +154,7 @@ public CompetencyProgress updateCompetencyProgress(Long competencyId, User user)
var competency = competencyRepository.findByIdWithExercisesAndLectureUnitsAndCompletions(competencyId).orElse(null);

if (user == null || competency == null) {
logger.debug("User or competency no longer exist, skipping.");
log.debug("User or competency no longer exist, skipping.");
return null;
}

Expand All @@ -163,7 +163,7 @@ public CompetencyProgress updateCompetencyProgress(Long competencyId, User user)
if (competencyProgress.isPresent()) {
var lastModified = competencyProgress.get().getLastModifiedDate();
if (lastModified != null && lastModified.isAfter(Instant.now().minusSeconds(1))) {
logger.debug("Competency progress has been updated very recently, skipping.");
log.debug("Competency progress has been updated very recently, skipping.");
return competencyProgress.get();
}
}
Expand Down Expand Up @@ -200,8 +200,7 @@ public CompetencyProgress updateCompetencyProgress(Long competencyId, User user)
// This fails the SQL unique constraint and throws an exception. We can safely ignore it.
}

logger.debug("Updated progress for user {} in competency {} to {} / {}.", user.getLogin(), competency.getId(), studentProgress.getProgress(),
studentProgress.getConfidence());
log.debug("Updated progress for user {} in competency {} to {} / {}.", user.getLogin(), competency.getId(), studentProgress.getProgress(), studentProgress.getConfidence());

learningPathService.updateLearningPathProgress(competency.getCourse().getId(), user.getId());
return studentProgress;
Expand Down
Loading

0 comments on commit 4382c08

Please sign in to comment.