Skip to content

Commit

Permalink
improve format of second-level cache log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Dec 4, 2024
1 parent 1405fb1 commit a83b08a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package org.hibernate.cache.spi;

import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.metamodel.model.domain.NavigableRole;

import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
Expand Down Expand Up @@ -37,15 +36,15 @@ public interface SecondLevelCacheLogger extends BasicLogger {

@LogMessage(level = WARN)
@Message(
value = "Attempt to restart an already started RegionFactory. Use sessionFactory.close() between " +
"repeated calls to buildSessionFactory. Using previously created RegionFactory.",
value = "Attempt to start an already-started RegionFactory, probably because a SessionFactory was not closed." +
" Using previously created RegionFactory.",
id = NAMESPACE + 1
)
void attemptToStartAlreadyStartedCacheProvider();

@LogMessage(level = WARN)
@Message(
value = "Attempt to restop an already stopped JCacheRegionFactory.",
value = "Attempt to stop an already-stopped JCacheRegionFactory.",
id = NAMESPACE + 2
)
void attemptToStopAlreadyStoppedCacheProvider();
Expand All @@ -55,33 +54,27 @@ public interface SecondLevelCacheLogger extends BasicLogger {
value = "Read-only caching was requested for mutable entity [%s]",
id = NAMESPACE + 3
)
void readOnlyCachingMutableEntity(NavigableRole navigableRole);
void readOnlyCachingMutableEntity(String entity);

@LogMessage( level = WARN )
@Message(
value = "Read-only caching was requested for mutable natural-id for entity [%s]",
id = NAMESPACE + 4
)
void readOnlyCachingMutableNaturalId(NavigableRole navigableRole);
void readOnlyCachingMutableNaturalId(String entity);

/**
* Log a message (WARN) about expiry of soft-locked region.
*/
@LogMessage(level = INFO)
@Message(
value = "Cache[%s] Key[%s]\n" +
"A soft-locked cache entry was expired by the underlying cache. If this happens regularly you " +
"should consider increasing the cache timeouts and/or capacity limits",
value = "A soft-locked cache entry in region [%s] with key [%s] was expired by the underlying cache." +
" If this happens regularly, consider increasing the cache timeouts and/or capacity limits.",
id = NAMESPACE + 5
)
void softLockedCacheExpired(String regionName, Object key);

@LogMessage(level = WARN)
@Message(
value = "Missing cache[%1$s] was created on-the-fly." +
" The created cache will use a provider-specific default configuration:" +
" make sure you defined one." +
" You can disable this warning by setting '%2$s' to '%3$s'.",
value = "Missing cache region [%1$s] was created with provider-specific default policies." +
" Explicitly configure the region and its policies, or disable this warning by setting '%2$s' to '%3$s'.",
id = NAMESPACE + 6
)
@SuppressWarnings( "unused" ) // used by hibernate-jcache
Expand All @@ -90,19 +83,19 @@ public interface SecondLevelCacheLogger extends BasicLogger {
@LogMessage(level = WARN)
@Message(
value = "Using legacy cache name [%2$s] because configuration could not be found for cache [%1$s]." +
" Update your configuration to rename cache [%2$s] to [%1$s].",
" Update configuration to rename cache [%2$s] to [%1$s].",
id = NAMESPACE + 7
)
@SuppressWarnings( "unused" ) // used by hibernate-jcache
void usingLegacyCacheName(String currentName, String legacyName);

@LogMessage(level = WARN)
@Message(
value = "Cache [%1$s] uses the [%2$s] access type, but [%3$s] does not support it natively." +
" Make sure your cache implementation supports JTA transactions.",
value = "Cache region [%1$s] has the access type '%2$s' which is not supported by [%3$s]." +
" Ensure cache implementation supports JTA transactions.",
id = NAMESPACE + 8
)
@SuppressWarnings( "unused" ) // used by hibernate-jcache
void nonStandardSupportForAccessType(String key, String accessType, String regionName);
void nonStandardSupportForAccessType(String regionName, String accessType, String regionFactoryClass);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public EntityReadOnlyAccess(
EntityDataCachingConfig config) {
super( region, cacheKeysFactory, storageAccess );
if ( config.isMutable() ) {
L2CACHE_LOGGER.readOnlyCachingMutableEntity( config.getNavigableRole() );
L2CACHE_LOGGER.readOnlyCachingMutableEntity( config.getNavigableRole().getFullPath() );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public NaturalIdReadOnlyAccess(
NaturalIdDataCachingConfig config) {
super( region, keysFactory, storageAccess, config );
if ( config.isMutable() ) {
L2CACHE_LOGGER.readOnlyCachingMutableNaturalId( config.getNavigableRole() );
L2CACHE_LOGGER.readOnlyCachingMutableNaturalId( config.getNavigableRole().getFullPath() );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@ValidIdRange( min = 10005001, max = 10010000 )
@SubSystemLogging(
name = BeansMessageLogger.LOGGER_NAME,
description = "Logging related to Hibernate's support for managed beans (CDI, etc)"
description = "Logging related to managed beans and the BeanContainer (CDI, etc)"
)
public interface BeansMessageLogger {
String LOGGER_NAME = SubSystemLogging.BASE + ".beans";
Expand All @@ -37,8 +37,8 @@ public interface BeansMessageLogger {
@Message(
id = 10005001,
value = "An explicit CDI BeanManager reference [%s] was passed to Hibernate, " +
"but CDI is not available on the Hibernate ClassLoader. This is likely " +
"going to lead to exceptions later on in bootstrap"
"but CDI is not available on the Hibernate ClassLoader. This is likely " +
"going to lead to exceptions later on in bootstrap."
)
void beanManagerButCdiNotAvailable(Object cdiBeanManagerReference);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void doTestMissingCacheStrategyCreateWarn(Consumer<StandardServiceRegist
triggerables.put(
regionName,
logInspection.watchForLogMessages(
"HHH90001006: Missing cache[" + TestHelper.prefix( regionName ) + "] was created on-the-fly"
"HHH90001006: Missing cache region [" + TestHelper.prefix( regionName ) + "] was created"
)
);
}
Expand Down

0 comments on commit a83b08a

Please sign in to comment.