Skip to content

Commit e64d22a

Browse files
authored
Standardize use of Logger (#94)
1 parent 72346cf commit e64d22a

File tree

18 files changed

+129
-108
lines changed

18 files changed

+129
-108
lines changed

extension/persistence/eclipselink/src/main/java/io/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreSessionImpl.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
* Polaris metadata from/to the configured database systems.
8282
*/
8383
public class PolarisEclipseLinkMetaStoreSessionImpl implements PolarisMetaStoreSession {
84-
private static final Logger LOG =
84+
private static final Logger LOGGER =
8585
LoggerFactory.getLogger(PolarisEclipseLinkMetaStoreSessionImpl.class);
8686

8787
// Cache to hold the EntityManagerFactory for each realm. Each realm needs a separate
@@ -108,7 +108,7 @@ public PolarisEclipseLinkMetaStoreSessionImpl(
108108
@NotNull RealmContext realmContext,
109109
@Nullable String confFile,
110110
@Nullable String persistenceUnitName) {
111-
LOG.debug("Create EclipseLink Meta Store Session for {}", realmContext.getRealmIdentifier());
111+
LOGGER.debug("Create EclipseLink Meta Store Session for {}", realmContext.getRealmIdentifier());
112112
emf = createEntityManagerFactory(realmContext, confFile, persistenceUnitName);
113113

114114
// init store
@@ -150,14 +150,14 @@ private EntityManagerFactory createEntityManagerFactory(
150150
prefixUrl = new File(jarPrefixPath).toURI().toURL();
151151
}
152152

153-
LOG.info(
153+
LOGGER.info(
154154
"Created a new ClassLoader with the jar {} in classpath to load the config file",
155155
prefixUrl);
156156

157157
URLClassLoader currentClassLoader =
158158
new URLClassLoader(new URL[] {prefixUrl}, this.getClass().getClassLoader());
159159

160-
LOG.debug("Update ClassLoader in current thread temporarily");
160+
LOGGER.debug("Update ClassLoader in current thread temporarily");
161161
Thread.currentThread().setContextClassLoader(currentClassLoader);
162162
}
163163

@@ -215,7 +215,7 @@ private Map<String, String> loadProperties(
215215
String.format(
216216
"Cannot find or parse the configuration file %s for persistence-unit %s",
217217
confFile, persistenceUnitName);
218-
LOG.error(str, e);
218+
LOGGER.error(str, e);
219219
throw new IOException(str);
220220
}
221221
}
@@ -237,13 +237,13 @@ public <T> T runInTransaction(
237237
// Commit when it's not rolled back by the client
238238
if (session.getTransaction().isActive()) {
239239
tr.commit();
240-
LOG.debug("transaction committed");
240+
LOGGER.debug("transaction committed");
241241
}
242242

243243
return result;
244244
} catch (Exception e) {
245245
tr.rollback();
246-
LOG.debug("transaction rolled back", e);
246+
LOGGER.debug("transaction rolled back", e);
247247

248248
if (e instanceof OptimisticLockException
249249
|| e.getCause() instanceof OptimisticLockException) {
@@ -274,11 +274,11 @@ public void runActionInTransaction(
274274
// Commit when it's not rolled back by the client
275275
if (session.getTransaction().isActive()) {
276276
tr.commit();
277-
LOG.debug("transaction committed");
277+
LOGGER.debug("transaction committed");
278278
}
279279
} catch (Exception e) {
280280
tr.rollback();
281-
LOG.debug("transaction rolled back", e);
281+
LOGGER.debug("transaction rolled back", e);
282282

283283
if (e instanceof OptimisticLockException
284284
|| e.getCause() instanceof OptimisticLockException) {

extension/persistence/eclipselink/src/main/java/io/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* with EclipseLink support
4646
*/
4747
public class PolarisEclipseLinkStore {
48-
private static final Logger LOG = LoggerFactory.getLogger(PolarisEclipseLinkStore.class);
48+
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisEclipseLinkStore.class);
4949

5050
// diagnostic services
5151
private final PolarisDiagnostics diagnosticServices;
@@ -195,7 +195,7 @@ void deleteAll(EntityManager session) {
195195
session.createQuery("DELETE from ModelGrantRecord").executeUpdate();
196196
session.createQuery("DELETE from ModelPrincipalSecrets").executeUpdate();
197197

198-
LOG.debug("All entities deleted.");
198+
LOGGER.debug("All entities deleted.");
199199
}
200200

201201
ModelEntity lookupEntity(EntityManager session, long catalogId, long entityId) {

polaris-core/src/main/java/io/polaris/core/auth/PolarisAuthorizer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
* which translates into a cross-catalog permission.
115115
*/
116116
public class PolarisAuthorizer {
117-
private static final Logger LOG = LoggerFactory.getLogger(PolarisAuthorizer.class);
117+
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisAuthorizer.class);
118118

119119
private static final SetMultimap<PolarisPrivilege, PolarisPrivilege> SUPER_PRIVILEGES =
120120
HashMultimap.create();
@@ -605,7 +605,7 @@ public boolean hasTransitivePrivilege(
605605
desiredPrivilege, PolarisPrivilege.fromCode(grantRecord.getPrivilegeCode()))) {
606606
// Found a potential candidate for satisfying our authz goal.
607607
if (activatedGranteeIds.contains(grantRecord.getGranteeId())) {
608-
LOG.debug(
608+
LOGGER.debug(
609609
"Satisfied privilege {} with grantRecord {} from securable {} for "
610610
+ "principalName {} and activatedIds {}",
611611
desiredPrivilege,
@@ -619,7 +619,7 @@ public boolean hasTransitivePrivilege(
619619
}
620620
}
621621

622-
LOG.debug(
622+
LOGGER.debug(
623623
"Failed to satisfy privilege {} for principalName {} on resolvedPath {}",
624624
desiredPrivilege,
625625
authenticatedPolarisPrincipal.getName(),

polaris-core/src/main/java/io/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public abstract class LocalPolarisMetaStoreManagerFactory<StoreType>
5151

5252
protected PolarisStorageIntegrationProvider storageIntegration;
5353

54-
private final Logger logger =
54+
private final Logger LOGGER =
5555
org.slf4j.LoggerFactory.getLogger(LocalPolarisMetaStoreManagerFactory.class);
5656

5757
protected abstract StoreType createBackingStore(@NotNull PolarisDiagnostics diagnostics);
@@ -197,7 +197,7 @@ private void checkPolarisServiceBootstrappedForRealm(
197197
PolarisEntityConstants.getRootPrincipalName());
198198

199199
if (!rootPrincipalLookup.isSuccess()) {
200-
logger.error(
200+
LOGGER.error(
201201
"\n\n Realm {} is not bootstrapped, could not load root principal. Please run Bootstrap command. \n\n",
202202
realmContext.getRealmIdentifier());
203203
throw new IllegalStateException(

polaris-core/src/main/java/io/polaris/core/persistence/resolver/PolarisResolutionManifest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* function as a lookup manifest for downstream callers.
4949
*/
5050
public class PolarisResolutionManifest implements PolarisResolutionManifestCatalogView {
51-
private static final Logger LOG = LoggerFactory.getLogger(PolarisResolutionManifest.class);
51+
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisResolutionManifest.class);
5252

5353
private final PolarisEntityManager entityManager;
5454
private final CallContext callContext;
@@ -195,14 +195,14 @@ public PolarisResolvedPathWrapper getPassthroughResolvedPath(Object key) {
195195
ResolverStatus status = passthroughResolver.resolveAll();
196196

197197
if (status.getStatus() != ResolverStatus.StatusEnum.SUCCESS) {
198-
LOG.debug("Returning null for key {} due to resolver status {}", key, status.getStatus());
198+
LOGGER.debug("Returning null for key {} due to resolver status {}", key, status.getStatus());
199199
return null;
200200
}
201201

202202
List<EntityCacheEntry> resolvedPath = passthroughResolver.getResolvedPath();
203203
if (requestedPath.isOptional()) {
204204
if (resolvedPath.size() != requestedPath.getEntityNames().size()) {
205-
LOG.debug(
205+
LOGGER.debug(
206206
"Returning null for key {} due to size mismatch from getPassthroughResolvedPath "
207207
+ "resolvedPath: {}, requestedPath.getEntityNames(): {}",
208208
key,
@@ -216,7 +216,8 @@ public PolarisResolvedPathWrapper getPassthroughResolvedPath(Object key) {
216216
resolvedEntities.add(
217217
new ResolvedPolarisEntity(passthroughResolver.getResolvedReferenceCatalog()));
218218
resolvedPath.forEach(cacheEntry -> resolvedEntities.add(new ResolvedPolarisEntity(cacheEntry)));
219-
LOG.debug("Returning resolvedEntities from getPassthroughResolvedPath: {}", resolvedEntities);
219+
LOGGER.debug(
220+
"Returning resolvedEntities from getPassthroughResolvedPath: {}", resolvedEntities);
220221
return new PolarisResolvedPathWrapper(resolvedEntities);
221222
}
222223

@@ -276,7 +277,7 @@ private ResolvedPolarisEntity getResolvedRootContainerEntity() {
276277
primaryResolver.getResolvedEntity(
277278
PolarisEntityType.ROOT, PolarisEntityConstants.getRootContainerName());
278279
if (resolvedCacheEntry == null) {
279-
LOG.debug("Failed to find rootContainer, so using simulated rootContainer instead.");
280+
LOGGER.debug("Failed to find rootContainer, so using simulated rootContainer instead.");
280281
return simulatedResolvedRootContainerEntity;
281282
}
282283
return new ResolvedPolarisEntity(resolvedCacheEntry);

polaris-core/src/test/java/io/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
public class AzureCredentialStorageIntegrationTest {
6363

64-
private final Logger LOGGER =
64+
private static final Logger LOGGER =
6565
LoggerFactory.getLogger(AzureCredentialStorageIntegrationTest.class);
6666

6767
private final String clientId = System.getenv("AZURE_CLIENT_ID");

polaris-service/src/main/java/io/polaris/service/IcebergExceptionMapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444
import org.slf4j.LoggerFactory;
4545

4646
public class IcebergExceptionMapper implements ExceptionMapper<RuntimeException> {
47-
private static final Logger LOG = LoggerFactory.getLogger(IcebergExceptionMapper.class);
47+
private static final Logger LOGGER = LoggerFactory.getLogger(IcebergExceptionMapper.class);
4848

4949
public IcebergExceptionMapper() {}
5050

5151
@Override
5252
public Response toResponse(RuntimeException runtimeException) {
53-
LOG.info("Handling runtimeException {}", runtimeException.getMessage());
53+
LOGGER.info("Handling runtimeException {}", runtimeException.getMessage());
5454
int responseCode =
5555
switch (runtimeException) {
5656
case NoSuchNamespaceException e -> Response.Status.NOT_FOUND.getStatusCode();
@@ -80,7 +80,7 @@ public Response toResponse(RuntimeException runtimeException) {
8080
default -> Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
8181
};
8282
if (responseCode == Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
83-
LOG.error("Unhandled exception returning INTERNAL_SERVER_ERROR", runtimeException);
83+
LOGGER.error("Unhandled exception returning INTERNAL_SERVER_ERROR", runtimeException);
8484
}
8585

8686
ErrorResponse icebergErrorResponse =
@@ -94,7 +94,7 @@ public Response toResponse(RuntimeException runtimeException) {
9494
.entity(icebergErrorResponse)
9595
.type(MediaType.APPLICATION_JSON_TYPE)
9696
.build();
97-
LOG.debug("Mapped exception to errorResp: {}", errorResp);
97+
LOGGER.debug("Mapped exception to errorResp: {}", errorResp);
9898
return errorResp;
9999
}
100100
}

polaris-service/src/main/java/io/polaris/service/admin/PolarisAdminService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
* the persistence layer.
9494
*/
9595
public class PolarisAdminService {
96-
private static final Logger LOG = LoggerFactory.getLogger(PolarisAdminService.class);
96+
private static final Logger LOGGER = LoggerFactory.getLogger(PolarisAdminService.class);
9797
public static final String CLEANUP_ON_CATALOG_DROP = "CLEANUP_ON_CATALOG_DROP";
9898

9999
private final CallContext callContext;
@@ -187,7 +187,8 @@ private void authorizeBasicTopLevelEntityOperationOrThrow(
187187
== authenticatedPrincipal.getPrincipalEntity().getId()
188188
&& (op.equals(PolarisAuthorizableOperation.ROTATE_CREDENTIALS)
189189
|| op.equals(PolarisAuthorizableOperation.RESET_CREDENTIALS))) {
190-
LOG.atDebug()
190+
LOGGER
191+
.atDebug()
191192
.addKeyValue("principalName", topLevelEntityName)
192193
.log("Allowing rotate own credentials");
193194
return;

0 commit comments

Comments
 (0)