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

Ensure JUL OFF level is respected in liquibase logger #21

Merged
merged 2 commits into from
Nov 20, 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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '*'
pull_request:
branches:
- $default-branch
- '*'

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2023 Matt Bertolini
* Copyright (c) 2012-2024 Matt Bertolini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
Expand Down Expand Up @@ -60,12 +60,13 @@
* @author Matt Bertolini
* @see liquibase.logging.Logger
*/
public class Slf4jLogger extends AbstractLogger {
public class Slf4jLogger extends AbstractLogger implements liquibase.logging.Logger {

private static final int TRACE_THRESHOLD = Level.FINEST.intValue();
private static final int DEBUG_THRESHOLD = Level.FINE.intValue();
private static final int INFO_THRESHOLD = Level.INFO.intValue();
private static final int WARN_THRESHOLD = Level.WARNING.intValue();
private static final int ERROR_THRESHOLD = Level.SEVERE.intValue();

private final Logger logger;

Expand All @@ -85,7 +86,7 @@ public void log(Level level, String message, Throwable e) {
logger.info(message, e);
} else if (levelValue <= WARN_THRESHOLD) {
logger.warn(message, e);
} else {
} else if (levelValue <= ERROR_THRESHOLD) {
logger.error(message, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2023 Matt Bertolini
* Copyright (c) 2012-2024 Matt Bertolini
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
Expand Down Expand Up @@ -28,6 +28,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

/**
Expand Down Expand Up @@ -88,6 +89,12 @@ void logWithFinestLevel() {
verify(delegate).trace(message, (Throwable) null);
}

@Test
void doesNotLogWithOffLevel() {
logger.log(Level.OFF, "should not log", null);
verifyNoInteractions(delegate);
}

// Severe level

@Test
Expand Down