logging report

This commit is contained in:
Steve Ebersole 2022-03-11 14:45:43 -06:00
parent 7a1d6f13dd
commit 741b6b71f1
85 changed files with 1034 additions and 538 deletions

View File

@ -63,144 +63,44 @@ public interface MappingModelCreationLogger extends BasicLogger {
}
----
== Sub-system logging registry
== `@ValidIdRange` registry
[width="50%",cols=">s,>s,^2m",options="header"]
|===
|Channel (category)
|Id Range (?)
|Purpose
|[[connections-pooling]]org.hibernate.orm.connections.pooling
|<<ConnectionPoolingLogger>>
|Logging related to connection pooling
|org.hibernate.orm.boot
|n/a
|Logging related to bootstrapping of a SessionFactory / EntityManagerFactory
|===
== MessageLogger id registry
[width="50%",cols=">s,>s,^2m,^2m",options="header"]
|===
|`ValidIdRange#min`
|`ValidIdRange#max`
|Channel
|Logger
|Sub-system (?)
|[[ConnectionPoolingLogger]]10001001
|10001500
|org.hibernate.internal.log.ConnectionPoolingLogger
| <<connections-pooling>>
|1
|10000
|2
|org.hibernate.TheLogger
|n/a
|org.hibernate.internal.CoreMessageLogger
|10001
|15000
|n/a
|org.hibernate.c3p0.internal.C3P0MessageLogger (extends ConnectionPoolingLogger)
|15000
|20000
|n/a
|org.hibernate.internal.EntityManagerMessageLogger
|20001
|25000
|n/a
|org.hibernate.cache.ehcache.EhCacheMessageLogger (extends CoreMessageLogger)
|25001
|30000
|n/a
|org.hibernate.envers.internal.EnversMessageLogger
|25001
|30000
|n/a
|org.hibernate.cache.infinispan.util.InfinispanMessageLogger
|30001
|35000
|n/a
|org.hibernate.proxool.internal.ProxoolMessageLogger (extends ConnectionPoolingLogger)
|10000001
|10001000
|org.hibernate.orm.url
|org.hibernate.internal.log.UrlMessageBundle
|10001001
|10001500
|org.hibernate.orm.connections.pooling
|org.hibernate.internal.log.ConnectionPoolingLogger
|10005001
|10010000
|org.hibernate.orm.beans
|org.hibernate.resource.beans.internal.BeansMessageLogger
|80000001
|80001000
|n/a
|org.hibernate.spatial.HSMessageLogger
|90000001
|90001000
|org.hibernate.orm.deprecation
|org.hibernate.internal.log.DeprecationLogger
|90001001
|90002000
|org.hibernate.orm.cache
|org.hibernate.cache.spi.SecondLevelCacheLogger
|90002001
|90003000
|n/a
|org.hibernate.internal.log.UnsupportedLogger
|90003001
|90003500
|org.hibernate.orm.query
|org.hibernate.query.spi.QueryLogger
|90003501
|90004000
|org.hibernate.orm.query.hql
|org.hibernate.query.hql.HqlLogging
|90004001
|90005000
|org.hibernate.orm.sql.exec
|org.hibernate.sql.exec.SqlExecLogger
|90005001
|90005100
|org.hibernate.orm.sql.results
|org.hibernate.sql.results.ResultsLogger
|90005101
|90005200
|org.hibernate.orm.sql.results.loading.collection
|org.hibernate.sql.results.graph.collection.CollectionLoadingLogger
|90005201
|90005300
|org.hibernate.orm.sql.results.loading.entity
|org.hibernate.sql.results.graph.entity.EntityLoadingLogger
|90005301
|90005400
|org.hibernate.orm.sql.results.loading.composite
|org.hibernate.sql.results.graph.embeddable.EmbeddableLoadingLogger
|90005401
|90005500
|org.hibernate.orm.sql.ast.tree
|org.hibernate.sql.ast.tree.SqlAstTreeLogger
|90005501
|90005600
|org.hibernate.orm.boot.jaxb
|org.hibernate.boot.jaxb.JaxbLogger
|90005601
|90005700
|org.hibernate.envers.boot
|org.hibernate.envers.boot.EnversBootLogger
|90005701
|90005800
|org.hibernate.orm.model.mapping.creation
|org.hibernate.metamodel.mapping.MappingModelCreationLogger
|90005801
|90005900
|org.hibernate.orm.sql.results.loading
|org.hibernate.sql.results.LoadingLogger
|===

View File

@ -235,6 +235,8 @@ task renderMigrationGuide(type: AsciidoctorTask, group: 'Documentation') {task->
}
}
tasks.buildDocsForPublishing.dependsOn generateHibernateReports
tasks.withType(AsciidoctorTask).all {
baseDirFollowsSourceDir()
outputOptions {

View File

@ -29,7 +29,8 @@ import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.Stoppable;
import org.jboss.logging.Logger;
import static org.hibernate.c3p0.internal.C3P0MessageLogger.C3P0_LOGGER;
import static org.hibernate.c3p0.internal.C3P0MessageLogger.C3P0_MSG_LOGGER;
/**
* A connection provider that uses a C3P0 connection pool. Hibernate will use this by
@ -41,11 +42,6 @@ import org.jboss.logging.Logger;
public class C3P0ConnectionProvider
implements ConnectionProvider, Configurable, Stoppable, ServiceRegistryAwareService {
private static final C3P0MessageLogger LOG = Logger.getMessageLogger(
C3P0MessageLogger.class,
C3P0ConnectionProvider.class.getName()
);
//swaldman 2006-08-28: define c3p0-style configuration parameters for properties with
// hibernate-specific overrides to detect and warn about conflicting
// declarations
@ -112,21 +108,21 @@ public class C3P0ConnectionProvider
final String jdbcUrl = (String) props.get( Environment.URL );
final Properties connectionProps = ConnectionProviderInitiator.getConnectionProperties( props );
LOG.c3p0UsingDriver( jdbcDriverClass, jdbcUrl );
LOG.connectionProperties( ConfigurationHelper.maskOut( connectionProps, "password" ) );
C3P0_MSG_LOGGER.c3p0UsingDriver( jdbcDriverClass, jdbcUrl );
C3P0_MSG_LOGGER.connectionProperties( ConfigurationHelper.maskOut( connectionProps, "password" ) );
autocommit = ConfigurationHelper.getBoolean( Environment.AUTOCOMMIT, props );
LOG.autoCommitMode( autocommit );
C3P0_MSG_LOGGER.autoCommitMode( autocommit );
if ( jdbcDriverClass == null ) {
LOG.jdbcDriverNotSpecified( Environment.DRIVER );
C3P0_MSG_LOGGER.jdbcDriverNotSpecified( Environment.DRIVER );
}
else {
try {
serviceRegistry.getService( ClassLoaderService.class ).classForName( jdbcDriverClass );
}
catch (ClassLoadingException e) {
throw new ClassLoadingException( LOG.jdbcDriverNotFound( jdbcDriverClass ), e );
throw new ClassLoadingException( C3P0_MSG_LOGGER.jdbcDriverNotFound( jdbcDriverClass ), e );
}
}
@ -187,12 +183,12 @@ public class C3P0ConnectionProvider
ds = DataSources.pooledDataSource( unpooled, allProps );
}
catch (Exception e) {
LOG.error( LOG.unableToInstantiateC3p0ConnectionPool(), e );
throw new HibernateException( LOG.unableToInstantiateC3p0ConnectionPool(), e );
C3P0_LOGGER.error( C3P0_MSG_LOGGER.unableToInstantiateC3p0ConnectionPool(), e );
throw new HibernateException( C3P0_MSG_LOGGER.unableToInstantiateC3p0ConnectionPool(), e );
}
isolation = ConnectionProviderInitiator.extractIsolation( props );
LOG.jdbcIsolationLevel( ConnectionProviderInitiator.toIsolationNiceName( isolation ) );
C3P0_MSG_LOGGER.jdbcIsolationLevel( ConnectionProviderInitiator.toIsolationNiceName( isolation ) );
}
@Override
@ -220,7 +216,7 @@ public class C3P0ConnectionProvider
}
private void warnPropertyConflict(String hibernateStyle, String c3p0Style) {
LOG.bothHibernateAndC3p0StylesSet( hibernateStyle, c3p0Style );
C3P0_MSG_LOGGER.bothHibernateAndC3p0StylesSet( hibernateStyle, c3p0Style );
}
@Override
@ -229,7 +225,7 @@ public class C3P0ConnectionProvider
DataSources.destroy( ds );
}
catch (SQLException sqle) {
LOG.unableToDestroyC3p0ConnectionPool( sqle );
C3P0_MSG_LOGGER.unableToDestroyC3p0ConnectionPool( sqle );
}
}

View File

@ -9,11 +9,14 @@ package org.hibernate.c3p0.internal;
import java.sql.SQLException;
import org.hibernate.internal.log.ConnectionPoolingLogger;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.ValidIdRange;
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;
@ -25,7 +28,16 @@ import static org.jboss.logging.Logger.Level.WARN;
* New messages must be added after the last message defined to ensure message codes are unique.
*/
@MessageLogger(projectCode = "HHH")
@ValidIdRange( min = 10001, max = 15000 )
@SubSystemLogging(
name = C3P0MessageLogger.NAME,
description = "Logging related to the C3P0 connection pool"
)
public interface C3P0MessageLogger extends ConnectionPoolingLogger {
String NAME = ConnectionPoolingLogger.LOGGER_NAME + ".c3p0";
Logger C3P0_LOGGER = Logger.getLogger( NAME );
C3P0MessageLogger C3P0_MSG_LOGGER = Logger.getMessageLogger( C3P0MessageLogger.class, NAME );
/**
* Log a message (WARN) about conflicting {@code hibernate.c3p0.XYZ} and {@code c3p0.XYZ} settings

View File

@ -6,26 +6,22 @@
*/
package org.hibernate.boot;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
import static org.hibernate.internal.CoreLogging.subsystemLoggerName;
/**
* Logging related to Hibernate bootstrapping
*/
public class BootLogging {
public static String NAME = subsystemLoggerName( "boot" );
@SubSystemLogging(
name = BootLogging.NAME,
description = "Logging related to bootstrapping of a SessionFactory / EntityManagerFactory"
)
public interface BootLogging {
String NAME = SubSystemLogging.BASE + ".boot";
Logger BOOT_LOGGER = Logger.getLogger( NAME );
public static final Logger LOGGER = Logger.getLogger( NAME );
public static String subLoggerName(String subPath) {
return NAME + "." + subPath;
}
public static Logger subLogger(String subPath) {
return Logger.getLogger( subLoggerName( subPath ) );
}
public static final boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
public static final boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = BOOT_LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = BOOT_LOGGER.isTraceEnabled();
}

View File

@ -6,6 +6,9 @@
*/
package org.hibernate.boot.jaxb;
import org.hibernate.boot.BootLogging;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;
@ -16,13 +19,14 @@ import org.jboss.logging.annotations.ValidIdRange;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90005501, max = 90005600 )
@SubSystemLogging(
name = JaxbLogger.LOGGER_NAME,
description = "Logging related to JAXB processing"
)
public interface JaxbLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.boot.jaxb";
String LOGGER_NAME = BootLogging.NAME + "jaxb";
JaxbLogger JAXB_LOGGER = Logger.getMessageLogger(
JaxbLogger.class,
LOGGER_NAME
);
JaxbLogger JAXB_LOGGER = Logger.getMessageLogger( JaxbLogger.class, LOGGER_NAME );
boolean TRACE_ENABLED = JAXB_LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = JAXB_LOGGER.isDebugEnabled();

View File

@ -7,15 +7,21 @@
package org.hibernate.boot.query;
import org.hibernate.boot.BootLogging;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
public class BootQueryLogging {
public static final Logger LOGGER = BootLogging.subLogger( "query" );
@SubSystemLogging(
name = BootQueryLogging.NAME,
description = "Logging related to processing of named-queries"
)
public interface BootQueryLogging {
String NAME = BootLogging.NAME + ".query";
Logger BOOT_QUERY_LOGGER = Logger.getLogger( NAME );
public static final boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
public static final boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = BOOT_QUERY_LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = BOOT_QUERY_LOGGER.isTraceEnabled();
}

View File

@ -85,7 +85,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
MetadataBuildingContext context) {
this.registrationName = hbmResultSetMapping.getName();
BootLogging.LOGGER.debugf(
BootLogging.BOOT_LOGGER.debugf(
"Creating explicit HbmResultSetMappingDescriptor : %s",
registrationName
);
@ -260,7 +260,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public NamedResultSetMappingMemento resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Resolving HbmResultSetMappingDescriptor into memento for [%s]",
registrationName
);
@ -349,7 +349,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
);
}
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Creating EntityResultDescriptor (%s : %s) for ResultSet mapping - %s",
tableAlias,
entityName,
@ -373,7 +373,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public ResultMemento resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Resolving HBM EntityResultDescriptor into memento - %s : %s (%s)",
tableAlias,
entityName,
@ -527,7 +527,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
}
}
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Creating PropertyFetchDescriptor (%s : %s) for ResultSet mapping - %s",
parent,
propertyPath,
@ -645,7 +645,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public FetchMemento resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Resolving HBM PropertyFetchDescriptor into memento - %s : %s",
parent,
propertyPath
@ -758,7 +758,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public FetchMemento resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Resolving HBM JoinDescriptor into memento - %s : %s . %s",
tableAlias,
ownerTableAlias,
@ -873,7 +873,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
);
}
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Creating CollectionResultDescriptor (%s : %s)",
tableAlias,
collectionPath
@ -895,7 +895,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public ResultMemento resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Resolving HBM CollectionResultDescriptor into memento - %s : %s",
tableAlias,
collectionPath
@ -942,7 +942,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
this.columnName = columnName;
this.hibernateTypeName = hibernateTypeName;
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Creating ScalarDescriptor (%s)",
columnName
);
@ -954,7 +954,7 @@ public class HbmResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public ResultMementoBasicStandard resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Resolving HBM ScalarDescriptor into memento - %s",
columnName
);

View File

@ -46,7 +46,7 @@ public class ImplicitHbmResultSetMappingDescriptorBuilder {
public ImplicitHbmResultSetMappingDescriptorBuilder(String queryRegistrationName, MetadataBuildingContext metadataBuildingContext) {
this.registrationName = queryRegistrationName;
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Creating implicit HbmResultSetMappingDescriptor for named-native-query : %s",
registrationName
);

View File

@ -151,7 +151,7 @@ public class SqlResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public ResultMemento resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Generating ScalarResultMappingMemento for JPA ColumnResult(%s) for ResultSet mapping `%s`",
columnResult.name(),
mappingName
@ -207,7 +207,7 @@ public class SqlResultSetMappingDescriptor implements NamedResultSetMappingDescr
@Override
public ResultMemento resolve(ResultSetMappingResolutionContext resolutionContext) {
BootQueryLogging.LOGGER.debugf(
BootQueryLogging.BOOT_QUERY_LOGGER.debugf(
"Generating InstantiationResultMappingMemento for JPA ConstructorResult(%s) for ResultSet mapping `%s`",
targetJavaType.getName(),
mappingName

View File

@ -6,19 +6,22 @@
*/
package org.hibernate.bytecode;
import org.hibernate.boot.jaxb.JaxbLogger;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
@SubSystemLogging(
name = BytecodeLogging.LOGGER_NAME,
description = "Logging related to bytecode handling"
)
public interface BytecodeLogging {
String NAME = "org.hibernate.orm.bytecode";
String LOGGER_NAME = SubSystemLogging.BASE + "bytecode";
Logger LOGGER = Logger.getLogger( NAME );
static String subLoggerName(String subName) {
return NAME + "." + subName;
}
Logger LOGGER = Logger.getLogger( LOGGER_NAME );
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();

View File

@ -7,6 +7,7 @@
package org.hibernate.bytecode.enhance.spi.interceptor;
import org.hibernate.bytecode.BytecodeLogging;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
@ -22,12 +23,16 @@ import static org.jboss.logging.Logger.Level.WARN;
*/
@MessageLogger(projectCode = "HHH")
@ValidIdRange(min = 90005901, max = 90006000)
@SubSystemLogging(
name = BytecodeInterceptorLogging.LOGGER_NAME,
description = "Logging related to bytecode-based interception"
)
public interface BytecodeInterceptorLogging extends BasicLogger {
String SUB_NAME = "interceptor";
String NAME = BytecodeLogging.subLoggerName(SUB_NAME);
String LOGGER_NAME = BytecodeLogging.LOGGER_NAME + "." + SUB_NAME;
Logger LOGGER = Logger.getLogger(NAME);
BytecodeInterceptorLogging MESSAGE_LOGGER = Logger.getMessageLogger(BytecodeInterceptorLogging.class, NAME);
Logger LOGGER = Logger.getLogger( LOGGER_NAME );
BytecodeInterceptorLogging MESSAGE_LOGGER = Logger.getMessageLogger(BytecodeInterceptorLogging.class, LOGGER_NAME );
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();

View File

@ -19,6 +19,9 @@ import org.hibernate.cache.spi.SecondLevelCacheLogger;
import org.hibernate.cache.spi.TimestampsCache;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.DEBUG_ENABLED;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
/**
* The standard implementation of the Hibernate QueryCache interface. Works
* hind-in-hand with {@link TimestampsCache} to help in recognizing
@ -49,8 +52,8 @@ public class QueryResultsCacheImpl implements QueryResultsCache {
final QueryKey key,
final List<?> results,
final SharedSessionContractImplementor session) throws HibernateException {
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debugf( "Caching query results in region: %s; timestamp=%s", cacheRegion.getName(), session.getTransactionStartTimestamp() );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debugf( "Caching query results in region: %s; timestamp=%s", cacheRegion.getName(), session.getTransactionStartTimestamp() );
}
final CacheItem cacheItem = new CacheItem(
@ -78,27 +81,27 @@ public class QueryResultsCacheImpl implements QueryResultsCache {
final QueryKey key,
final Set<String> spaces,
final SharedSessionContractImplementor session) throws HibernateException {
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debugf( "Checking cached query results in region: %s", cacheRegion.getName() );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debugf( "Checking cached query results in region: %s", cacheRegion.getName() );
}
final CacheItem cacheItem = getCachedData( key, session );
if ( cacheItem == null ) {
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debug( "Query results were not found in cache" );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debug( "Query results were not found in cache" );
}
return null;
}
if ( !timestampsCache.isUpToDate( spaces, cacheItem.timestamp, session ) ) {
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debug( "Cached query results were not up-to-date" );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debug( "Cached query results were not up-to-date" );
}
return null;
}
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debug( "Returning cached query results" );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debug( "Returning cached query results" );
}
return deepCopy( cacheItem.results );
@ -109,27 +112,27 @@ public class QueryResultsCacheImpl implements QueryResultsCache {
final QueryKey key,
final String[] spaces,
final SharedSessionContractImplementor session) throws HibernateException {
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debugf( "Checking cached query results in region: %s", cacheRegion.getName() );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debugf( "Checking cached query results in region: %s", cacheRegion.getName() );
}
final CacheItem cacheItem = getCachedData( key, session );
if ( cacheItem == null ) {
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debug( "Query results were not found in cache" );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debug( "Query results were not found in cache" );
}
return null;
}
if ( !timestampsCache.isUpToDate( spaces, cacheItem.timestamp, session ) ) {
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debug( "Cached query results were not up-to-date" );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debug( "Cached query results were not up-to-date" );
}
return null;
}
if ( SecondLevelCacheLogger.DEBUG_ENABLED ) {
SecondLevelCacheLogger.INSTANCE.debug( "Returning cached query results" );
if ( DEBUG_ENABLED ) {
L2CACHE_LOGGER.debug( "Returning cached query results" );
}
return deepCopy( cacheItem.results );

View File

@ -17,6 +17,8 @@ import org.hibernate.cache.spi.support.RegionNameQualifier;
import org.hibernate.cache.spi.support.SimpleTimestamper;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
/**
* @author Steve Ebersole
*/
@ -95,7 +97,7 @@ public abstract class AbstractRegionFactory implements RegionFactory {
}
}
else {
SecondLevelCacheLogger.INSTANCE.attemptToStartAlreadyStartedCacheProvider();
L2CACHE_LOGGER.attemptToStartAlreadyStartedCacheProvider();
}
}
@ -115,7 +117,7 @@ public abstract class AbstractRegionFactory implements RegionFactory {
}
}
else {
SecondLevelCacheLogger.INSTANCE.attemptToStopAlreadyStoppedCacheProvider();
L2CACHE_LOGGER.attemptToStopAlreadyStoppedCacheProvider();
}
}

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.cache.spi;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.metamodel.model.domain.NavigableRole;
import org.jboss.logging.BasicLogger;
@ -23,13 +24,17 @@ import static org.jboss.logging.Logger.Level.WARN;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90001001, max = 90002000 )
@SubSystemLogging(
name = SecondLevelCacheLogger.LOGGER_NAME,
description = "Logging related to Hibernate second-level caching"
)
public interface SecondLevelCacheLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.cache";
String LOGGER_NAME = SubSystemLogging.BASE + ".cache";
SecondLevelCacheLogger INSTANCE = Logger.getMessageLogger( SecondLevelCacheLogger.class, LOGGER_NAME );
SecondLevelCacheLogger L2CACHE_LOGGER = Logger.getMessageLogger( SecondLevelCacheLogger.class, LOGGER_NAME );
boolean DEBUG_ENABLED = INSTANCE.isDebugEnabled();
boolean TRACE_ENABLED = INSTANCE.isTraceEnabled();
boolean DEBUG_ENABLED = L2CACHE_LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = L2CACHE_LOGGER.isTraceEnabled();
int NAMESPACE = 90001000;

View File

@ -21,6 +21,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.jboss.logging.Logger;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
/**
* @author Steve Ebersole
*/
@ -181,7 +183,7 @@ public abstract class AbstractReadWriteAccess extends AbstractCachedDomainDataAc
}
protected void handleLockExpiry(SharedSessionContractImplementor session, Object key, Lockable lock) {
SecondLevelCacheLogger.INSTANCE.softLockedCacheExpired( getRegion().getName(), key );
L2CACHE_LOGGER.softLockedCacheExpired( getRegion().getName(), key );
log.info( "Cached entry expired : " + key );
// create new lock that times out immediately

View File

@ -16,6 +16,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.jboss.logging.Logger;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
/**
* Standard support for {@link org.hibernate.cache.spi.access.EntityDataAccess}
* using the {@link AccessType#READ_ONLY} access type.
@ -32,7 +34,7 @@ public class EntityReadOnlyAccess extends AbstractEntityDataAccess {
EntityDataCachingConfig config) {
super( region, cacheKeysFactory, storageAccess );
if ( config.isMutable() ) {
SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableEntity( config.getNavigableRole() );
L2CACHE_LOGGER.readOnlyCachingMutableEntity( config.getNavigableRole() );
}
}

View File

@ -14,6 +14,8 @@ import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
/**
* Standard support for {@link org.hibernate.cache.spi.access.NaturalIdDataAccess}
* using the {@link AccessType#READ_ONLY} access type.
@ -28,7 +30,7 @@ public class NaturalIdReadOnlyAccess extends AbstractNaturalIdDataAccess {
NaturalIdDataCachingConfig config) {
super( region, keysFactory, storageAccess, config );
if ( config.isMutable() ) {
SecondLevelCacheLogger.INSTANCE.readOnlyCachingMutableNaturalId( config.getNavigableRole() );
L2CACHE_LOGGER.readOnlyCachingMutableNaturalId( config.getNavigableRole() );
}
}

View File

@ -365,7 +365,7 @@ public abstract class CollectionBinder {
}
else {
// log a "warning"
BootLogging.LOGGER.debugf(
BootLogging.BOOT_LOGGER.debugf(
"Custom collection-type (`%s`) assigned to attribute (`%s`) does not implement `%s`, but its `@CollectionType` defined parameters",
implementation.getName(),
role,
@ -427,7 +427,7 @@ public abstract class CollectionBinder {
}
else {
// log a "warning"
BootLogging.LOGGER.debugf(
BootLogging.BOOT_LOGGER.debugf(
"Custom collection-type (`%s`) assigned to attribute (`%s`) does not implement `%s`, but its `@CollectionType` defined parameters",
typeImpl.getName(),
attributeKey,

View File

@ -67,7 +67,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
@Override
public void cacheResolutionFromLoad(Object id, Object naturalId, EntityMappingType entityDescriptor) {
NaturalIdLogging.LOGGER.debugf(
NaturalIdLogging.NATURAL_ID_LOGGER.debugf(
"Caching resolution natural-id resolution from load (%s) : `%s` -> `%s`",
entityDescriptor.getEntityName(),
naturalId,
@ -101,7 +101,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
assert entityDescriptor.getNaturalIdMapping() != null;
assert isValidValue( naturalId, entityDescriptor );
NaturalIdLogging.LOGGER.debugf(
NaturalIdLogging.NATURAL_ID_LOGGER.debugf(
"Locally caching natural-id resolution (%s) : `%s` -> `%s`",
entityDescriptor.getEntityName(),
naturalId,
@ -172,7 +172,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
@Override
public Object removeLocalResolution(Object id, Object naturalId, EntityMappingType entityDescriptor) {
NaturalIdLogging.LOGGER.debugf(
NaturalIdLogging.NATURAL_ID_LOGGER.debugf(
"Removing locally cached natural-id resolution (%s) : `%s` -> `%s`",
entityDescriptor.getEntityName(),
naturalId,

View File

@ -0,0 +1,27 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.graph.internal;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
@SubSystemLogging(
name = GraphParserLogging.LOGGER_NAME,
description = "Logging related to Hibernate's `GraphParser` for parsing entity-graphs from String representations"
)
public interface GraphParserLogging {
String LOGGER_NAME = SubSystemLogging.BASE + ".graph.parsing";
Logger PARSING_LOGGER = Logger.getLogger( LOGGER_NAME );
boolean DEBUG_ENABLED = PARSING_LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = PARSING_LOGGER.isTraceEnabled();
}

View File

@ -23,11 +23,12 @@ import org.jboss.logging.Logger;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import static org.hibernate.graph.internal.GraphParserLogging.PARSING_LOGGER;
/**
* @author Steve Ebersole
*/
public class GraphParser extends GraphLanguageParserBaseVisitor {
public static final Logger PARSING_LOGGER = Logger.getLogger( "org.hibernate.orm.graph.parsing" );
/**
* Parse the passed graph textual representation into the passed Graph.

View File

@ -6,14 +6,21 @@
*/
package org.hibernate.id.factory;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
/**
* Logging related to IdentifierGeneratorFactory
*/
public class IdGenFactoryLogging {
public static final Logger ID_GEN_FAC_LOGGER = Logger.getLogger( "org.hibernate.orm.idgen.factory" );
@SubSystemLogging(
name = IdGenFactoryLogging.LOGGER_NAME,
description = "Logging related to creation of IdentifierGenerator instances"
)
public interface IdGenFactoryLogging {
String LOGGER_NAME = SubSystemLogging.BASE + ".idgen.factory";
Logger ID_GEN_FAC_LOGGER = Logger.getLogger( LOGGER_NAME );
public static final boolean IS_TRACE_ENABLE = ID_GEN_FAC_LOGGER.isTraceEnabled();
public static final boolean IS_DEBUG_ENABLE = ID_GEN_FAC_LOGGER.isDebugEnabled();
boolean IS_TRACE_ENABLE = ID_GEN_FAC_LOGGER.isTraceEnabled();
boolean IS_DEBUG_ENABLE = ID_GEN_FAC_LOGGER.isDebugEnabled();
}

View File

@ -11,6 +11,7 @@ import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import jakarta.persistence.GenerationType;
import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
@ -20,7 +21,6 @@ import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.id.Assigned;
import org.hibernate.id.ForeignGenerator;
@ -33,7 +33,6 @@ import org.hibernate.id.UUIDGenerator;
import org.hibernate.id.UUIDHexGenerator;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.id.enhanced.TableGenerator;
import org.hibernate.id.factory.IdGenFactoryLogging;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
import org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration;
@ -43,7 +42,6 @@ import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.container.spi.ExtendedBeanManager;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.internal.Helper;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
@ -51,8 +49,6 @@ import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.JavaType;
import jakarta.persistence.GenerationType;
import static org.hibernate.id.factory.IdGenFactoryLogging.ID_GEN_FAC_LOGGER;
/**
@ -112,7 +108,7 @@ public class StandardIdentifierGeneratorFactory
generationTypeStrategy
);
if ( previous != null ) {
IdGenFactoryLogging.ID_GEN_FAC_LOGGER.debugf(
ID_GEN_FAC_LOGGER.debugf(
"GenerationTypeStrategyRegistration [%s] overrode previous registration for GenerationType#%s : %s",
registration,
generationType.name(),

View File

@ -14,9 +14,6 @@ import org.jboss.logging.Logger;
* @author Steve Ebersole
*/
public class CoreLogging {
public static String subsystemLoggerName(String subsystem) {
return "org.hibernate.orm." + subsystem;
}
/**
* Disallow instantiation

View File

@ -13,6 +13,7 @@ import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.ValidIdRange;
import static org.jboss.logging.Logger.Level.DEBUG;
import static org.jboss.logging.Logger.Level.ERROR;
@ -20,12 +21,10 @@ import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;
/**
* The jboss-logging {@link MessageLogger} for the hibernate-entitymanager module. It reserves message ids ranging from
* 15001 to 20000 inclusively.
* <p/>
* New messages must be added after the last message defined to ensure message codes are unique.
* {@link MessageLogger} originally for the no-longer existing hibernate-entitymanager module.
*/
@MessageLogger(projectCode = "HHH")
@ValidIdRange( min = 15001, max = 20000 )
public interface EntityManagerMessageLogger extends CoreMessageLogger {
@LogMessage(level = INFO)

View File

@ -22,8 +22,12 @@ import static org.jboss.logging.Logger.Level.INFO;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 10001501, max = 10002000 )
@SubSystemLogging(
name = ConnectionAccessLogger.LOGGER_NAME,
description = "Used to log details around use of `JdbcConnectionAccess`"
)
public interface ConnectionAccessLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.connections.access";
String LOGGER_NAME = SubSystemLogging.BASE + ".connections.access";
/**
* Static access to the logging instance

View File

@ -26,8 +26,12 @@ import static org.jboss.logging.Logger.Level.WARN;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 10001001, max = 10001500 )
@SubSystemLogging(
name = ConnectionPoolingLogger.LOGGER_NAME,
description = "Logging related to connection pooling"
)
public interface ConnectionPoolingLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.connections.pooling";
String LOGGER_NAME = SubSystemLogging.BASE + ".connections.pooling";
/**
* Static access to the logging instance

View File

@ -13,7 +13,6 @@ import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.ValidIdRange;
import static org.jboss.logging.Logger.Level.INFO;
import static org.jboss.logging.Logger.Level.WARN;
/**
@ -23,13 +22,14 @@ import static org.jboss.logging.Logger.Level.WARN;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90000001, max = 90001000 )
@SubSystemLogging(
name = DeprecationLogger.CATEGORY,
description = "Logging related to uses of deprecated features"
)
public interface DeprecationLogger extends BasicLogger {
String CATEGORY = "org.hibernate.orm.deprecation";
String CATEGORY = SubSystemLogging.BASE + ".deprecation";
DeprecationLogger DEPRECATION_LOGGER = Logger.getMessageLogger(
DeprecationLogger.class,
CATEGORY
);
DeprecationLogger DEPRECATION_LOGGER = Logger.getMessageLogger( DeprecationLogger.class, CATEGORY );
@LogMessage(level = WARN)
@Message(

View File

@ -0,0 +1,53 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.internal.log;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Used to annotate classes which define sub-system style logging where
* loggers are hierarchically defined around functionalities rather than
* class and package names
* <p/>
* This is helpful to find such classes and is used to generate report
* (as a release artifact) describing logger names for logging configuration
* by the application.
* <p/>
* At the moment Hibernate uses a mix sub-system logging and the more traditional
* package and class name based logging. This annotation focuses on the classes
* defining the sub-system approach
*
* @author Steve Ebersole
*/
@Target(TYPE)
@Retention(RUNTIME)
public @interface SubSystemLogging {
/**
* Base category name for sub-system style logging
*/
String BASE = "org.hibernate.orm";
/**
* The sub-system name, which is used as the "logger name"
*/
String name();
/**
* Description of the information logged
*/
String description();
/**
* Aside from test usage, is the associated logger always used
* through the sub-system category name?
*/
boolean mixed() default false;
}

View File

@ -1,31 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.internal.log;
import org.hibernate.cfg.AvailableSettings;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.ValidIdRange;
import static org.jboss.logging.Logger.Level.WARN;
/**
* Class to consolidate logging about usage of features which should
* never be used.
* Such features might have been introduced for practical reasons so
* that people who really know what they want can use them, with the
* understanding that they should find a better alternative.
*
* @author Sanne Grinovero
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90002001, max = 90003000 )
public interface UnsupportedLogger {
}

View File

@ -27,8 +27,12 @@ import static org.jboss.logging.Logger.Level.WARN;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 10000001, max = 10001000 )
@SubSystemLogging(
name = UrlMessageBundle.LOGGER_NAME,
description = "Logging related to URL handling"
)
public interface UrlMessageBundle {
String LOGGER_NAME = "org.hibernate.orm.url";
String LOGGER_NAME = SubSystemLogging.BASE + ".url";
Logger URL_LOGGER = Logger.getLogger( LOGGER_NAME );
UrlMessageBundle URL_MESSAGE_LOGGER = Logger.getMessageLogger( UrlMessageBundle.class, LOGGER_NAME );

View File

@ -6,13 +6,24 @@
*/
package org.hibernate.loader;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
/**
* Logging for loaders
*
* @see org.hibernate.loader.ast.spi.Loader
*
* @author Steve Ebersole
*/
@SubSystemLogging(
name = LoaderLogging.LOGGER_NAME,
description = "Logging related to loaders of domain model references (`org.hibernate.loader.ast.spi.Loader`); " +
"see also `" + SubSystemLogging.BASE + ".results`"
)
public interface LoaderLogging {
String LOGGER_NAME = "org.hibernate.orm.loader";
String LOGGER_NAME = SubSystemLogging.BASE + ".loader";
Logger LOADER_LOGGER = Logger.getLogger( LOGGER_NAME );

View File

@ -1,21 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.loader.ast;
import org.jboss.logging.Logger;
/**
* Logging for loaders
*/
public interface LoaderLogging {
String LOGGER_NAME = "org.hibernate.orm.loader";
Logger LOADER_LOGGER = Logger.getLogger( LOGGER_NAME );
boolean DEBUG_ENABLED = LOADER_LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = LOADER_LOGGER.isTraceEnabled();
}

View File

@ -14,7 +14,7 @@ import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.loader.ast.LoaderLogging;
import org.hibernate.loader.LoaderLogging;
import org.hibernate.persister.entity.EntityPersister;
/**

View File

@ -155,7 +155,7 @@ public enum CollectionClassification {
return BAG;
}
BootLogging.LOGGER.debugf(
BootLogging.BOOT_LOGGER.debugf(
"Unexpected Class specified for CollectionClassification resolution (`%s`) - " +
"should be one of `%s`, `%s`, `%s`, `%s`, `%s` or `%s` (or subclass of)",
configuredClass.getName(),

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.metamodel.mapping;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;
@ -18,8 +20,12 @@ import org.jboss.logging.annotations.ValidIdRange;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90005701, max = 90005800 )
@SubSystemLogging(
name = MappingModelCreationLogger.LOGGER_NAME,
description = "Logging related to building of Hibernate's runtime metamodel descriptors of the domain model"
)
public interface MappingModelCreationLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.model.mapping.creation";
String LOGGER_NAME = SubSystemLogging.BASE + ".model.mapping.creation";
MappingModelCreationLogger LOGGER = Logger.getMessageLogger( MappingModelCreationLogger.class, LOGGER_NAME );

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.metamodel.mapping;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
@ -15,10 +15,14 @@ import org.jboss.logging.Logger;
*
* @author Steve Ebersole
*/
@SubSystemLogging(
name = NaturalIdLogging.LOGGER_NAME,
description = "Logging related to handling of natural-id mappings"
)
public interface NaturalIdLogging {
String LOGGER_NAME = CoreLogging.subsystemLoggerName( "mapping.natural_id" );
Logger LOGGER = Logger.getLogger( LOGGER_NAME );
String LOGGER_NAME = SubSystemLogging.BASE + ".mapping.natural_id";
Logger NATURAL_ID_LOGGER = Logger.getLogger( LOGGER_NAME );
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = NATURAL_ID_LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = NATURAL_ID_LOGGER.isTraceEnabled();
}

View File

@ -249,7 +249,7 @@ public class BasicValuedCollectionPart
boolean selected,
String resultVariable,
DomainResultCreationState creationState) {
ResultsLogger.LOGGER.debugf(
ResultsLogger.RESULTS_LOGGER.debugf(
"Generating Fetch for collection-part : `%s` -> `%s`",
collectionDescriptor.getRole(),
nature.getName()

View File

@ -7,6 +7,7 @@
package org.hibernate.query;
import org.hibernate.HibernateException;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
@ -25,8 +26,12 @@ import static org.jboss.logging.Logger.Level.WARN;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90003001, max = 90003500 )
@SubSystemLogging(
name = QueryLogging.LOGGER_NAME,
description = "Logging related to Query processing"
)
public interface QueryLogging extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.query";
String LOGGER_NAME = SubSystemLogging.BASE + ".query";
Logger QUERY_LOGGER = Logger.getLogger( LOGGER_NAME );
QueryLogging QUERY_MESSAGE_LOGGER = Logger.getMessageLogger( QueryLogging.class, LOGGER_NAME );

View File

@ -7,6 +7,7 @@
package org.hibernate.query.hql;
import org.hibernate.HibernateException;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.query.QueryLogging;
import org.jboss.logging.BasicLogger;
@ -24,8 +25,12 @@ import static org.jboss.logging.Logger.Level.ERROR;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90003501, max = 90004000 )
@SubSystemLogging(
name = HqlLogging.LOGGER_NAME,
description = "Logging related to HQL parsing"
)
public interface HqlLogging extends BasicLogger {
String LOGGER_NAME = QueryLogging.subLoggerName( "hql" );
String LOGGER_NAME = QueryLogging.LOGGER_NAME + ".hql";
HqlLogging QUERY_LOGGER = Logger.getMessageLogger( HqlLogging.class, LOGGER_NAME );

View File

@ -118,7 +118,7 @@ public class DomainResultCreationStateImpl
}
public void disallowPositionalSelections() {
ResultsLogger.LOGGER.debugf( "Disallowing positional selections : %s", stateIdentifier );
ResultsLogger.RESULTS_LOGGER.debugf( "Disallowing positional selections : %s", stateIdentifier );
this.allowPositionalSelections = false;
}

View File

@ -140,7 +140,7 @@ public abstract class AbstractCdiBeanContainer implements CdiBasedBeanContainer
@Override
public final void stop() {
BeansMessageLogger.BEANS_MESSAGE_LOGGER.stoppingBeanContainer( this );
BeansMessageLogger.BEANS_MSG_LOGGER.stoppingBeanContainer( this );
forEachBean( ContainedBeanImplementor::release );
registeredBeans.clear();
beanCache.clear();

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.resource.beans.internal;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
@ -23,14 +24,15 @@ import static org.jboss.logging.Logger.Level.WARN;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 10005001, max = 10010000 )
@SubSystemLogging(
name = BeansMessageLogger.LOGGER_NAME,
description = "Logging related to Hibernate's support for managed beans (CDI, etc)"
)
public interface BeansMessageLogger {
String LOGGER_NAME = "org.hibernate.orm.beans";
String LOGGER_NAME = SubSystemLogging.BASE + ".beans";
/**
* The BeansMessageLogger instance
*/
Logger BEANS_LOGGER = Logger.getLogger( LOGGER_NAME );
BeansMessageLogger BEANS_MESSAGE_LOGGER = Logger.getMessageLogger( BeansMessageLogger.class, LOGGER_NAME );
BeansMessageLogger BEANS_MSG_LOGGER = Logger.getMessageLogger( BeansMessageLogger.class, LOGGER_NAME );
@LogMessage( level = WARN )
@Message(

View File

@ -66,14 +66,14 @@ public class ManagedBeanRegistryInitiator implements StandardServiceInitiator<Ma
}
if ( beanManagerRef != null ) {
if ( !isCdiAvailable ) {
BeansMessageLogger.BEANS_MESSAGE_LOGGER.beanManagerButCdiNotAvailable( beanManagerRef );
BeansMessageLogger.BEANS_MSG_LOGGER.beanManagerButCdiNotAvailable( beanManagerRef );
}
return CdiBeanContainerBuilder.fromBeanManagerReference( beanManagerRef, serviceRegistry );
}
else {
if ( isCdiAvailable ) {
BeansMessageLogger.BEANS_MESSAGE_LOGGER.noBeanManagerButCdiAvailable();
BeansMessageLogger.BEANS_MSG_LOGGER.noBeanManagerButCdiAvailable();
}
}

View File

@ -6,13 +6,19 @@
*/
package org.hibernate.sql.ast;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
@SubSystemLogging(
name = SqlTreeCreationLogger.LOGGER_NAME,
description = "Logging related to the creation of SQL AST trees"
)
public interface SqlTreeCreationLogger {
String LOGGER_NAME = "org.hibernate.orm.sql.ast.create";
String LOGGER_NAME = SubSystemLogging.BASE + ".sql.ast.create";
Logger LOGGER = Logger.getLogger( LOGGER_NAME );

View File

@ -6,6 +6,9 @@
*/
package org.hibernate.sql.ast.tree;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.sql.ast.SqlTreeCreationLogger;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;
@ -18,8 +21,12 @@ import org.jboss.logging.annotations.ValidIdRange;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90005401, max = 90005500 )
@SubSystemLogging(
name = SqlAstTreeLogger.LOGGER_NAME,
description = "Logging related to the processing of SQL AST trees"
)
public interface SqlAstTreeLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.sql.ast.tree";
String LOGGER_NAME = SubSystemLogging.BASE + ".sql.ast.tree";
/**
* Static access to the logging instance

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.sql.exec;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;
@ -16,16 +18,12 @@ import org.jboss.logging.annotations.ValidIdRange;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90004001, max = 90005000 )
@SubSystemLogging(
name = SqlExecLogger.LOGGER_NAME,
description = "Logging related to the execution of SQL statements"
)
public interface SqlExecLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.sql.exec";
String LOGGER_NAME = SubSystemLogging.BASE + ".sql.exec";
/**
* Static access to the logging instance
*/
SqlExecLogger INSTANCE = Logger.getMessageLogger(
SqlExecLogger.class,
LOGGER_NAME
);
// todo (6.0) : make sure sql execution classes use this logger
SqlExecLogger SQL_EXEC_LOGGER = Logger.getMessageLogger( SqlExecLogger.class, LOGGER_NAME );
}

View File

@ -474,13 +474,13 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor {
final QueryKey queryResultsCacheKey;
if ( cacheable && cacheMode.isGetEnabled() ) {
SqlExecLogger.INSTANCE.debugf( "Reading Query result cache data per CacheMode#isGetEnabled [%s]", cacheMode.name() );
SqlExecLogger.SQL_EXEC_LOGGER.debugf( "Reading Query result cache data per CacheMode#isGetEnabled [%s]", cacheMode.name() );
final Set<String> querySpaces = jdbcSelect.getAffectedTableNames();
if ( querySpaces == null || querySpaces.size() == 0 ) {
SqlExecLogger.INSTANCE.tracef( "Unexpected querySpaces is empty" );
SqlExecLogger.SQL_EXEC_LOGGER.tracef( "Unexpected querySpaces is empty" );
}
else {
SqlExecLogger.INSTANCE.tracef( "querySpaces is `%s`", querySpaces );
SqlExecLogger.SQL_EXEC_LOGGER.tracef( "querySpaces is `%s`", querySpaces );
}
final QueryResultsCache queryCache = factory.getCache()
@ -520,7 +520,7 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor {
}
}
else {
SqlExecLogger.INSTANCE.debugf( "Skipping reading Query result cache data: cache-enabled = %s, cache-mode = %s",
SqlExecLogger.SQL_EXEC_LOGGER.debugf( "Skipping reading Query result cache data: cache-enabled = %s, cache-mode = %s",
queryCacheEnabled,
cacheMode.name()
);

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.sql.results;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;
@ -16,8 +18,12 @@ import org.jboss.logging.annotations.ValidIdRange;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90005801, max = 90005900 )
@SubSystemLogging(
name = LoadingLogger.LOGGER_NAME,
description = "Logging related to building parts of the domain model from JDBC or from cache"
)
public interface LoadingLogger extends BasicLogger {
String LOGGER_NAME = ResultsLogger.subLoggerName( "loading" );
String LOGGER_NAME = ResultsLogger.LOGGER_NAME + ".loading";
Logger LOGGER = Logger.getLogger( LOGGER_NAME );
LoadingLogger MESSAGE_LOGGER = Logger.getMessageLogger( LoadingLogger.class, LOGGER_NAME );

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.sql.results;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.MessageLogger;
@ -18,22 +20,26 @@ import org.jboss.logging.annotations.ValidIdRange;
*
* * creation of the DomainResult / Fetch nodes
* * creation of Initializer / DomainResultAssembler delegates
* * processing of JDBC values via Initializer / DomainResultAssembler
* * processing of values from JDBC and cache via Initializer / DomainResultAssembler
*
* @author Steve Ebersole
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90005001, max = 90005100 )
@SubSystemLogging(
name = ResultsLogger.LOGGER_NAME,
description = "Logging related to `DomainResult` graphs which build individual parts of the domain model from JDBC or from cache"
)
public interface ResultsLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.orm.sql.results";
String LOGGER_NAME = SubSystemLogging.BASE + ".results";
/**
* Static access to the logging instance
*/
ResultsLogger LOGGER = Logger.getMessageLogger(
ResultsLogger.class,
LOGGER_NAME
);
Logger RESULTS_LOGGER = Logger.getLogger( LOGGER_NAME );
ResultsLogger RESULTS_MESSAGE_LOGGER = Logger.getMessageLogger( ResultsLogger.class, LOGGER_NAME );
// todo (6.0) : make sure sql result processing classes use this logger
boolean TRACE_ENABLED = RESULTS_LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = RESULTS_LOGGER.isDebugEnabled();
static String subLoggerName(String subName) {
return LOGGER_NAME + "." + subName;
@ -43,9 +49,4 @@ public interface ResultsLogger extends BasicLogger {
return Logger.getLogger( subLoggerName( subName ) );
}
// todo (6.0) : make sure sql result processing classes use this logger
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
boolean INFO_ENABLED = LOGGER.isInfoEnabled();
}

View File

@ -1,21 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.sql.results.graph;
import org.hibernate.sql.results.ResultsLogger;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
public interface AssemblerLogger {
Logger LOGGER = ResultsLogger.subLogger( "assembler" );
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
}

View File

@ -8,30 +8,39 @@ package org.hibernate.sql.results.graph;
import java.util.List;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.internal.util.collections.Stack;
import org.hibernate.internal.util.collections.StandardStack;
import org.hibernate.sql.results.ResultsLogger;
import org.jboss.logging.Logger;
import static org.hibernate.sql.results.graph.DomainResultGraphPrinter.Logging.AST_LOGGER;
import static org.hibernate.sql.results.graph.DomainResultGraphPrinter.Logging.TRACE_ENABLED;
/**
* Printer for DomainResult graphs
*
* todo (6.0) : implement / use this
*
* @author Steve Ebersole
*/
public class DomainResultGraphPrinter {
private static final Logger log = ResultsLogger.subLogger( "graph.AST" );
private static final boolean DEBUG_ENABLED = log.isDebugEnabled();
private static final boolean TRACE_ENABLED = log.isTraceEnabled();
@SubSystemLogging(
name = Logging.LOGGER_NAME,
description = "Logging of `DomainResult` graphs"
)
interface Logging {
String LOGGER_NAME = ResultsLogger.LOGGER_NAME + ".graph.AST";
Logger AST_LOGGER = Logger.getLogger( LOGGER_NAME );
boolean DEBUG_ENABLED = AST_LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = AST_LOGGER.isTraceEnabled();
}
public static void logDomainResultGraph(List<DomainResult<?>> domainResults) {
logDomainResultGraph( "DomainResult Graph", domainResults );
}
public static void logDomainResultGraph(String header, List<DomainResult<?>> domainResults) {
if ( ! DEBUG_ENABLED ) {
if ( ! Logging.DEBUG_ENABLED ) {
return;
}
@ -57,10 +66,10 @@ public class DomainResultGraphPrinter {
visitGraphNode( domainResult, lastInBranch );
}
log.debug( buffer.toString() );
AST_LOGGER.debug( buffer.toString() );
if ( TRACE_ENABLED ) {
log.tracef( new Exception(), "Stack trace calling DomainResultGraphPrinter" );
AST_LOGGER.tracef( new Exception(), "Stack trace calling DomainResultGraphPrinter" );
}
}

View File

@ -1,21 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.sql.results.graph;
import org.hibernate.sql.results.ResultsLogger;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
public interface ResultGraphLogging {
Logger LOGGER = ResultsLogger.subLogger( "graph" );
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
}

View File

@ -58,7 +58,7 @@ public class BasicResultAssembler<J> implements DomainResultAssembler<J> {
JdbcValuesSourceProcessingOptions options) {
final Object jdbcValue = extractRawValue( rowProcessingState );
ResultsLogger.LOGGER.debugf( "Extracted JDBC value [%d] - [%s]", valuesArrayPosition, jdbcValue );
ResultsLogger.RESULTS_MESSAGE_LOGGER.debugf( "Extracted JDBC value [%d] - [%s]", valuesArrayPosition, jdbcValue );
if ( valueConverter != null ) {
if ( jdbcValue != null ) {

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.sql.results.graph.collection;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.sql.results.LoadingLogger;
import org.jboss.logging.BasicLogger;
@ -14,15 +15,17 @@ import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
@SubSystemLogging(
name = CollectionLoadingLogger.LOGGER_NAME,
description = "Logging related to collection loading"
)
public interface CollectionLoadingLogger extends BasicLogger {
String LOCAL_NAME = "collection";
String LOGGER_NAME = LoadingLogger.subLoggerName( LOCAL_NAME );
String LOGGER_NAME = LoadingLogger.LOGGER_NAME + ".collection";
/**
* Static access to the logging instance
*/
Logger COLL_LOAD_LOGGER = LoadingLogger.subLogger( LOCAL_NAME );
Logger COLL_LOAD_LOGGER = LoadingLogger.subLogger( LOGGER_NAME );
boolean TRACE_ENABLED = COLL_LOAD_LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = COLL_LOAD_LOGGER.isDebugEnabled();

View File

@ -150,7 +150,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
@Override
public void initializeInstance(RowProcessingState processingState) {
EmbeddableLoadingLogger.INSTANCE.debugf( "Initializing composite instance [%s]", navigablePath );
EmbeddableLoadingLogger.EMBEDDED_LOAD_LOGGER.debugf( "Initializing composite instance [%s]", navigablePath );
if ( compositeInstance == NULL_MARKER ) {
// we already know it is null
@ -245,7 +245,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
);
}
EmbeddableLoadingLogger.INSTANCE.debugf(
EmbeddableLoadingLogger.EMBEDDED_LOAD_LOGGER.debugf(
"Created composite instance [%s]",
navigablePath
);
@ -323,7 +323,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
final Object instance = representationStrategy.getInstantiator().instantiate( this, sessionFactory );
stateInjected = true;
EmbeddableLoadingLogger.INSTANCE.debugf( "Created composite instance [%s] : %s", navigablePath, instance );
EmbeddableLoadingLogger.EMBEDDED_LOAD_LOGGER.debugf( "Created composite instance [%s] : %s", navigablePath, instance );
return instance;
}
@ -348,7 +348,7 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
// we want to avoid injection for `NULL_MARKER`
if ( compositeInstance == null || compositeInstance == NULL_MARKER ) {
EmbeddableLoadingLogger.INSTANCE.debugf(
EmbeddableLoadingLogger.EMBEDDED_LOAD_LOGGER.debugf(
"Skipping parent injection for null embeddable [%s]",
navigablePath
);
@ -363,14 +363,14 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
final Object parent = determineParentInstance( processingState );
if ( parent == null ) {
EmbeddableLoadingLogger.INSTANCE.debugf(
EmbeddableLoadingLogger.EMBEDDED_LOAD_LOGGER.debugf(
"Unable to determine parent for injection into embeddable [%s]",
navigablePath
);
return;
}
EmbeddableLoadingLogger.INSTANCE.debugf(
EmbeddableLoadingLogger.EMBEDDED_LOAD_LOGGER.debugf(
"Injecting parent into embeddable [%s] : `%s` -> `%s`",
navigablePath,
parent,

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.sql.results.graph.embeddable;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.sql.results.LoadingLogger;
import org.jboss.logging.BasicLogger;
@ -18,17 +19,19 @@ import org.jboss.logging.annotations.ValidIdRange;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90005301, max = 90005400 )
@SubSystemLogging(
name = EmbeddableLoadingLogger.LOGGER_NAME,
description = "Logging related to embeddable loading"
)
public interface EmbeddableLoadingLogger extends BasicLogger {
String LOCAL_NAME = "composite";
String LOGGER_NAME = LoadingLogger.subLoggerName( LOCAL_NAME );
String LOGGER_NAME = LoadingLogger.LOGGER_NAME + ".embeddable";
/**
* Static access to the logging instance
*/
Logger INSTANCE = LoadingLogger.subLogger( LOCAL_NAME );
Logger EMBEDDED_LOAD_LOGGER = LoadingLogger.subLogger( LOGGER_NAME );
boolean TRACE_ENABLED = INSTANCE.isTraceEnabled();
boolean DEBUG_ENABLED = INSTANCE.isDebugEnabled();
boolean TRACE_ENABLED = EMBEDDED_LOAD_LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = EMBEDDED_LOAD_LOGGER.isDebugEnabled();
}

View File

@ -6,17 +6,22 @@
*/
package org.hibernate.sql.results.graph.entity;
import org.hibernate.internal.log.SubSystemLogging;
import org.hibernate.sql.results.LoadingLogger;
import org.hibernate.sql.results.graph.embeddable.EmbeddableLoadingLogger;
import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
@SubSystemLogging(
name = EmbeddableLoadingLogger.LOGGER_NAME,
description = "Logging related to entity loading"
)
public interface EntityLoadingLogging {
String LOCAL_NAME = "entity";
String LOGGER_NAME = LoadingLogger.subLoggerName( LOCAL_NAME );
Logger ENTITY_LOADING_LOGGER = LoadingLogger.subLogger( LOCAL_NAME );
String LOGGER_NAME = LoadingLogger.LOGGER_NAME + ".entity";
Logger ENTITY_LOADING_LOGGER = Logger.getLogger( LOGGER_NAME );
boolean TRACE_ENABLED = ENTITY_LOADING_LOGGER.isTraceEnabled();
boolean DEBUG_ENABLED = ENTITY_LOADING_LOGGER.isDebugEnabled();

View File

@ -44,9 +44,9 @@ public class TupleResultAssembler<J> implements DomainResultAssembler<J> {
JdbcValuesSourceProcessingOptions options) {
final Object[] jdbcValues = extractRawValue( rowProcessingState );
if ( ResultsLogger.LOGGER.isDebugEnabled() ) {
if ( ResultsLogger.RESULTS_MESSAGE_LOGGER.isDebugEnabled() ) {
for ( int i = 0; i < valuesArrayPositions.length; i++ ) {
ResultsLogger.LOGGER.debugf(
ResultsLogger.RESULTS_MESSAGE_LOGGER.debugf(
"Extracted JDBC value [%d] - [%s]",
valuesArrayPositions[i],
jdbcValues[i]

View File

@ -78,7 +78,7 @@ public class ResultsHelper {
if ( existing != null ) {
if ( fetchedModelPart.getNavigableRole().equals(
existing.getInitializedPart().getNavigableRole() ) ) {
ResultsLogger.LOGGER.tracef(
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef(
"Returning previously-registered initializer : %s",
existing
);
@ -87,7 +87,7 @@ public class ResultsHelper {
}
final Initializer initializer = producer.get();
ResultsLogger.LOGGER.tracef(
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef(
"Registering initializer : %s",
initializer
);
@ -115,9 +115,9 @@ public class ResultsHelper {
return;
}
ResultsLogger.LOGGER.debug( "Initializer list" );
ResultsLogger.RESULTS_MESSAGE_LOGGER.debug( "Initializer list" );
initializerMap.forEach( (navigablePath, initializer) -> {
ResultsLogger.LOGGER.debugf(
ResultsLogger.RESULTS_MESSAGE_LOGGER.debugf(
" %s -> %s@%s (%s)",
navigablePath.getFullPath(),
initializer,

View File

@ -71,7 +71,7 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
@Override
protected boolean processNext(RowProcessingState rowProcessingState) {
ResultsLogger.LOGGER.tracef( "JdbcValuesCacheHit#processNext : position = %i; numberOfRows = %i", position, numberOfRows );
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processNext : position = %i; numberOfRows = %i", position, numberOfRows );
// NOTE : explicitly skipping limit handling because the cached state ought
// already be the limited size since the cache key includes limits
@ -88,7 +88,7 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
@Override
protected boolean processPrevious(RowProcessingState rowProcessingState) {
ResultsLogger.LOGGER.tracef( "JdbcValuesCacheHit#processPrevious : position = %i; numberOfRows = %i", position, numberOfRows );
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processPrevious : position = %i; numberOfRows = %i", position, numberOfRows );
// NOTE : explicitly skipping limit handling because the cached state ought
// already be the limited size since the cache key includes limits
@ -105,7 +105,7 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
@Override
protected boolean processScroll(int numberOfRows, RowProcessingState rowProcessingState) {
ResultsLogger.LOGGER.tracef( "JdbcValuesCacheHit#processScroll(%i) : position = %i; numberOfRows = %i", numberOfRows, position, this.numberOfRows );
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processScroll(%i) : position = %i; numberOfRows = %i", numberOfRows, position, this.numberOfRows );
// NOTE : explicitly skipping limit handling because the cached state should
// already be the limited size since the cache key includes limits
@ -127,7 +127,7 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
@Override
protected boolean processPosition(int position, RowProcessingState rowProcessingState) {
ResultsLogger.LOGGER.tracef( "JdbcValuesCacheHit#processPosition(%i) : position = %i; numberOfRows = %i", position, this.position, this.numberOfRows );
ResultsLogger.RESULTS_MESSAGE_LOGGER.tracef( "JdbcValuesCacheHit#processPosition(%i) : position = %i; numberOfRows = %i", position, this.position, this.numberOfRows );
// NOTE : explicitly skipping limit handling because the cached state should
// already be the limited size since the cache key includes limits
@ -135,7 +135,7 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
if ( position < 0 ) {
// we need to subtract it from `numberOfRows`
final int newPosition = numberOfRows + position;
ResultsLogger.LOGGER.debugf(
ResultsLogger.RESULTS_MESSAGE_LOGGER.debugf(
"Translated negative absolute position `%i` into `%` based on `%i` number of rows",
position,
newPosition,
@ -145,7 +145,7 @@ public class JdbcValuesCacheHit extends AbstractJdbcValues {
}
if ( position > numberOfRows ) {
ResultsLogger.LOGGER.debugf(
ResultsLogger.RESULTS_MESSAGE_LOGGER.debugf(
"Absolute position `%i` exceeded number of rows `%i`",
position,
numberOfRows

View File

@ -1,31 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tool.schema.ast;
import org.jboss.logging.Logger;
/**
* Logging specific to parsing of SQL import scripts used in schema export.
*
* These scripts are processed using Antlr and this logging relates to
* that parsing.
*
* @todo (6.0) - implement usage of this
*/
public class SqlScriptLogging {
public static final String SCRIPT_LOGGER_NAME = "org.hibernate.orm.tooling.schema.script";
public static final Logger SCRIPT_LOGGER = Logger.getLogger( SCRIPT_LOGGER_NAME );
public static final boolean TRACE_ENABLED = SCRIPT_LOGGER.isTraceEnabled();
public static final boolean DEBUG_ENABLED = SCRIPT_LOGGER.isDebugEnabled();
public static final String AST_LOGGER_NAME = SCRIPT_LOGGER_NAME + ".graph";
public static final Logger AST_LOGGER = Logger.getLogger( AST_LOGGER_NAME );
public static final boolean AST_TRACE_ENABLED = AST_LOGGER.isTraceEnabled();
}

View File

@ -6,10 +6,16 @@
*/
package org.hibernate.type.descriptor;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
@SubSystemLogging(
name = JdbcBindingLogging.NAME,
description = "Logging of JDBC parameter value binding"
)
public interface JdbcBindingLogging {
String NAME = "org.hibernate.orm.jdbc.bind";
String NAME = SubSystemLogging.BASE + ".jdbc.bind";
Logger LOGGER = Logger.getLogger( NAME );

View File

@ -6,10 +6,16 @@
*/
package org.hibernate.type.descriptor;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
@SubSystemLogging(
name = JdbcExtractingLogging.NAME,
description = "Logging of JDBC value extraction"
)
public interface JdbcExtractingLogging {
String NAME = "org.hibernate.orm.jdbc.extract";
String NAME = SubSystemLogging.BASE + ".jdbc.extract";
Logger LOGGER = Logger.getLogger( NAME );

View File

@ -40,16 +40,6 @@ logger.jdbc-extract.level=trace
logger.graph.name=org.hibernate.orm.graph
#logger.graph.level=debug
# SQL import script processing
# NOTE : see org.hibernate.tool.schema.ast.SqlScriptLogging
logger.tooling-schema-script.name=org.hibernate.orm.tooling.schema.script
#logger.tooling-schema-script.level=trace
# SQL import script parsed AST logging
# NOTE : see org.hibernate.tool.schema.ast.SqlScriptLogging
logger.tooling-schema-script-graph.name=org.hibernate.orm.tooling.schema.script.graph
#logger.tooling-schema-script-graph.level=trace
# Logging related to the creation of DomainResult/Fetch graphs
logger.sql-result-graph.name=org.hibernate.orm.sql.results
#logger.sql-result-graph.level=debug

View File

@ -6,6 +6,8 @@
*/
package org.hibernate.envers.boot;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.LogMessage;
@ -20,6 +22,11 @@ import static org.jboss.logging.Logger.Level.INFO;
*/
@MessageLogger( projectCode = "HHH" )
@ValidIdRange( min = 90005601, max = 90005700 )
@SubSystemLogging(
name = EnversBootLogger.LOGGER_NAME,
description = "Logging related to bootstrapping an Envers (currently just its in-flight generation " +
"of `hbm.xml` mappings for Hibernate ORM to process)"
)
public interface EnversBootLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.envers.boot";

View File

@ -8,6 +8,7 @@ package org.hibernate.envers.internal;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.annotations.MessageLogger;
import org.jboss.logging.annotations.ValidIdRange;
/**
* The jboss-logging {@link MessageLogger} for the hibernate-envers module. It reserves message ids ranging from
@ -16,6 +17,7 @@ import org.jboss.logging.annotations.MessageLogger;
* New messages must be added after the last message defined to ensure message codes are unique.
*/
@MessageLogger(projectCode = "HHH")
@ValidIdRange(min = 25001, max = 30000)
public interface EnversMessageLogger extends BasicLogger {
}

View File

@ -21,6 +21,8 @@ import org.hibernate.cache.spi.support.DomainDataRegionImpl;
import org.hibernate.cache.spi.support.DomainDataStorageAccess;
import org.hibernate.cache.spi.support.RegionFactoryTemplate;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
/**
* @author Vlad Mihalcea
*/
@ -37,7 +39,7 @@ public class JCacheDomainDataRegionImpl extends DomainDataRegionImpl {
@Override
protected EntityDataAccess generateTransactionalEntityDataAccess(EntityDataCachingConfig entityAccessConfig) {
SecondLevelCacheLogger.INSTANCE.nonStandardSupportForAccessType(
L2CACHE_LOGGER.nonStandardSupportForAccessType(
getName(),
AccessType.TRANSACTIONAL.getExternalName(),
getRegionFactory().getClass().getSimpleName()
@ -47,7 +49,7 @@ public class JCacheDomainDataRegionImpl extends DomainDataRegionImpl {
@Override
protected NaturalIdDataAccess generateTransactionalNaturalIdDataAccess(NaturalIdDataCachingConfig accessConfig) {
SecondLevelCacheLogger.INSTANCE.nonStandardSupportForAccessType(
L2CACHE_LOGGER.nonStandardSupportForAccessType(
getName(),
AccessType.TRANSACTIONAL.getExternalName(),
getRegionFactory().getClass().getSimpleName()
@ -57,7 +59,7 @@ public class JCacheDomainDataRegionImpl extends DomainDataRegionImpl {
@Override
protected CollectionDataAccess generateTransactionalCollectionDataAccess(CollectionDataCachingConfig accessConfig) {
SecondLevelCacheLogger.INSTANCE.nonStandardSupportForAccessType(
L2CACHE_LOGGER.nonStandardSupportForAccessType(
getName(),
AccessType.TRANSACTIONAL.getExternalName(),
getRegionFactory().getClass().getSimpleName()

View File

@ -35,6 +35,8 @@ import org.hibernate.cache.spi.support.RegionNameQualifier;
import org.hibernate.cache.spi.support.StorageAccess;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
/**
* @author Alex Snaps
*/
@ -103,7 +105,7 @@ public class JCacheRegionFactory extends RegionFactoryTemplate {
protected Cache<Object, Object> createCache(String regionName) {
switch ( missingCacheStrategy ) {
case CREATE_WARN:
SecondLevelCacheLogger.INSTANCE.missingCacheCreated(
L2CACHE_LOGGER.missingCacheCreated(
regionName,
ConfigSettings.MISSING_CACHE_STRATEGY, MissingCacheStrategy.CREATE.getExternalRepresentation()
);
@ -163,7 +165,7 @@ public class JCacheRegionFactory extends RegionFactoryTemplate {
for ( String legacyDefaultRegionName : legacyDefaultRegionNames ) {
if ( cacheExists( legacyDefaultRegionName, sessionFactory ) ) {
SecondLevelCacheLogger.INSTANCE.usingLegacyCacheName( defaultRegionName, legacyDefaultRegionName );
L2CACHE_LOGGER.usingLegacyCacheName( defaultRegionName, legacyDefaultRegionName );
return legacyDefaultRegionName;
}
}

View File

@ -15,7 +15,6 @@ import org.hibernate.cache.CacheException;
import org.hibernate.cache.jcache.ConfigSettings;
import org.hibernate.cache.spi.SecondLevelCacheLogger;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.orm.test.jcache.TestHelper;
import org.hibernate.service.spi.ServiceException;
import org.hibernate.testing.junit4.BaseUnitTestCase;
@ -42,7 +41,7 @@ import static org.junit.Assert.fail;
public class MissingCacheStrategyTest extends BaseUnitTestCase {
@Rule
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SecondLevelCacheLogger.INSTANCE );
public LoggerInspectionRule logInspection = new LoggerInspectionRule( SecondLevelCacheLogger.L2CACHE_LOGGER );
@Test
public void testMissingCacheStrategyDefault() {

View File

@ -12,7 +12,9 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@ -27,6 +29,7 @@ import org.gradle.api.provider.Provider;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexReader;
import org.jboss.jandex.IndexWriter;
import org.jboss.jandex.Indexer;
@ -48,10 +51,10 @@ public class IndexManager {
this.artifactsToProcess = artifactsToProcess;
this.indexFileReferenceAccess = project.getLayout()
.getBuildDirectory()
.file( "reports/orm/indexing/jandex.idx" );
.file( "orm/reports/indexing/jandex.idx" );
this.packageFileReferenceAccess = project.getLayout()
.getBuildDirectory()
.file( "reports/orm/indexing/internal-packages.txt" );
.file( "orm/reports/indexing/internal-packages.txt" );
this.project = project;
}
@ -73,19 +76,60 @@ public class IndexManager {
public Index getIndex() {
if ( index == null ) {
throw new IllegalStateException( "Index has not been created yet" );
index = loadIndex( indexFileReferenceAccess );
internalPackageNames = loadInternalPackageNames( packageFileReferenceAccess );
}
return index;
}
private static Index loadIndex(Provider<RegularFile> indexFileReferenceAccess) {
final File indexFile = indexFileReferenceAccess.get().getAsFile();
if ( !indexFile.exists() ) {
throw new IllegalStateException( "Cannot load index; the stored file does not exist - " + indexFile.getAbsolutePath() );
}
try ( final FileInputStream stream = new FileInputStream( indexFile ) ) {
final IndexReader indexReader = new IndexReader( stream );
return indexReader.read();
}
catch (FileNotFoundException e) {
throw new IllegalStateException( "Cannot load index; the stored file does not exist - " + indexFile.getAbsolutePath(), e );
}
catch (IOException e) {
throw new IllegalStateException( "Cannot load index; unable to read stored file - " + indexFile.getAbsolutePath(), e );
}
}
private static TreeSet<Inclusion> loadInternalPackageNames(Provider<RegularFile> packageFileReferenceAccess) {
final File packageNameFile = packageFileReferenceAccess.get().getAsFile();
if ( !packageNameFile.exists() ) {
throw new IllegalStateException( "Cannot load internal packages; the stored file does not exist - " + packageNameFile.getAbsolutePath() );
}
final TreeSet<Inclusion> inclusions = new TreeSet<>( Comparator.comparing( Inclusion::getPath ) );
try {
final List<String> lines = Files.readAllLines( packageNameFile.toPath() );
lines.forEach( (line) -> {
if ( line == null || line.isEmpty() ) {
return;
}
inclusions.add( new Inclusion( line, true ) );
} );
return inclusions;
}
catch (IOException e) {
throw new RuntimeException( "Unable to read package-name file - " + packageNameFile.getAbsolutePath(), e );
}
}
/**
* Used from {@link IndexerTask} as its action
*/
void index() {
if ( index != null ) {
assert internalPackageNames != null;
return;
throw new IllegalStateException( "Index was already created or loaded" );
}
final Indexer indexer = new Indexer();

View File

@ -6,25 +6,147 @@
*/
package org.hibernate.orm.post;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.List;
import java.util.TreeMap;
import javax.inject.Inject;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskAction;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import static org.jboss.jandex.DotName.createSimple;
/**
* @author Steve Ebersole
*/
public abstract class LoggingReportTask extends AbstractJandexAwareTask {
public static final DotName SUB_SYS_ANN_NAME = createSimple( "org.hibernate.internal.log.SubSystemLogging" );
@Inject
public LoggingReportTask(IndexManager indexManager, Project project) {
super(
indexManager,
project.getLayout().getBuildDirectory().file( "reports/orm/logging.txt" )
project.getLayout().getBuildDirectory().file( "reports/orm/logging.adoc" )
);
}
@TaskAction
public void generateLoggingReport() {
getProject().getLogger().lifecycle( "Logging report not implemented yet" );
final TreeMap<String, SubSystem> subSystemByName = new TreeMap<>();
final Index index = getIndexManager().getIndex();
final List<AnnotationInstance> subSysAnnUsages = index.getAnnotations( SUB_SYS_ANN_NAME );
subSysAnnUsages.forEach( (ann) -> {
final SubSystem subSystem = new SubSystem(
ann.value( "name" ).asString(),
ann.value( "description" ).asString(),
ann.target().asClass().simpleName()
);
subSystemByName.put( subSystem.name, subSystem );
} );
generateReport( subSystemByName );
}
private void generateReport(TreeMap<String, SubSystem> subSystemByName) {
final File reportFile = prepareReportFile();
assert reportFile.exists();
try ( final OutputStreamWriter fileWriter = new OutputStreamWriter( new FileOutputStream( reportFile ) ) ) {
writeReport( subSystemByName, fileWriter );
}
catch (FileNotFoundException e) {
throw new RuntimeException( "Should never happen" );
}
catch (IOException e) {
throw new RuntimeException( "Error writing to report file", e );
}
}
private void writeReport(TreeMap<String, SubSystem> subSystemByName, OutputStreamWriter fileWriter) {
// for the moment, just dump these to a file in simple text format.
//
// ultimately come back and create an asciidoctor-formatted file
// and run through the asciidoctor task
try {
fileWriter.write( "= Hibernate logging\n\n" );
fileWriter.write( "== Sub-system logging\n\n" );
subSystemByName.forEach( (name, subSystem) -> {
try {
fileWriter.write( "[[" + subSystem.getAnchorName() + "]]\n" );
fileWriter.write( "`" + subSystem.getName() + "`::\n" );
fileWriter.write( " * Logging class-name = `" + subSystem.getLoggingClassName() + "`\n" );
fileWriter.write( " * Description = " + subSystem.getDescription() + "\n" );
}
catch (IOException e) {
throw new RuntimeException( "Error writing sub-system entry (" + subSystem.getAnchorName() + ") to report file", e );
}
} );
}
catch (IOException e) {
throw new RuntimeException( "Error writing to report file", e );
}
}
private static class SubSystem {
private final String name;
private final String description;
private final String loggingClassName;
private final String anchorName;
public SubSystem(String name, String description, String loggingClassName) {
this.name = name;
this.description = description;
this.loggingClassName = loggingClassName;
this.anchorName = determineAnchorName( name );
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public String getLoggingClassName() {
return loggingClassName;
}
public String getAnchorName() {
return anchorName;
}
private static String determineAnchorName(final String name) {
final String baseName;
if ( name.startsWith( "org.hibernate.orm." ) ) {
baseName = name.substring( "org.hibernate.orm.".length() );
}
else if ( name.startsWith( "org.hibernate." ) ) {
baseName = name.substring( "org.hibernate.".length() );
}
else {
baseName = name;
}
return baseName.replace( '.', '_' );
}
}
}

View File

@ -0,0 +1,317 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.orm.post;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.lang.annotation.RetentionPolicy;
import java.util.Comparator;
import java.util.List;
import java.util.TreeMap;
import java.util.TreeSet;
import javax.inject.Inject;
import org.gradle.api.Project;
import org.gradle.api.tasks.TaskAction;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import static org.jboss.jandex.DotName.createSimple;
/**
* This one would be nice to support, but Jandex is unable to read the annotations
* from JBoss Logging because it defines those annotations with {@link RetentionPolicy#CLASS};
* Jandex can only read annotations marked with {@link RetentionPolicy#RUNTIME}
*
* @see LoggingReportTask
*
* @author Steve Ebersole
*/
public abstract class LoggingReportTask2 extends AbstractJandexAwareTask {
public static final DotName SUB_SYS_ANN_NAME = createSimple( "org.hibernate.internal.log.SubSystemLogging" );
public static final DotName MSG_LOGGER_ANN_NAME = createSimple( "org.jboss.logging.annotations.MessageLogger" );
public static final DotName ID_RANGE_ANN_NAME = createSimple( "org.jboss.logging.annotations.ValidIdRange" );
public static final DotName MSG_ANN_NAME = createSimple( "org.jboss.logging.annotations.Message" );
@Inject
public LoggingReportTask2(IndexManager indexManager, Project project) {
super(
indexManager,
project.getLayout().getBuildDirectory().file( "reports/orm/logging.adoc" )
);
}
@TaskAction
public void generateLoggingReport() {
final TreeMap<String, SubSystem> subSystemByName = new TreeMap<>();
final TreeSet<IdRange> idRanges = new TreeSet<>( Comparator.comparing( IdRange::getMinValue ) );
final Index index = getIndexManager().getIndex();
final List<AnnotationInstance> subSysAnnUsages = index.getAnnotations( SUB_SYS_ANN_NAME );
final List<AnnotationInstance> msgLoggerAnnUsages = index.getAnnotations( MSG_LOGGER_ANN_NAME );
subSysAnnUsages.forEach( (ann) -> {
final SubSystem subSystem = new SubSystem(
ann.value( "name" ).asString(),
ann.value( "description" ).asString(),
ann.target().asClass().simpleName()
);
subSystemByName.put( subSystem.name, subSystem );
} );
msgLoggerAnnUsages.forEach( (msgLoggerAnnUsage) -> {
// find its id-range annotation, if one
final ClassInfo loggerClassInfo = msgLoggerAnnUsage.target().asClass();
final AnnotationInstance subSystemAnnUsage = loggerClassInfo.classAnnotation( SUB_SYS_ANN_NAME );
final SubSystem subSystem;
if ( subSystemAnnUsage != null ) {
subSystem = subSystemByName.get( subSystemAnnUsage.value( "name" ).asString() );
}
else {
subSystem = null;
}
final IdRange idRange;
final AnnotationInstance idRangeAnnUsage = loggerClassInfo.classAnnotation( ID_RANGE_ANN_NAME );
if ( idRangeAnnUsage == null ) {
idRange = calculateIdRange( msgLoggerAnnUsage, subSystem );
}
else {
idRange = new IdRange(
idRangeAnnUsage.value( "min" ).asInt(),
idRangeAnnUsage.value( "maz" ).asInt(),
loggerClassInfo.simpleName(),
true,
subSystem
);
if ( subSystem != null ) {
subSystem.idRange = idRange;
}
}
if ( idRange != null ) {
idRanges.add( idRange );
}
} );
generateReport( subSystemByName, idRanges );
}
private IdRange calculateIdRange(AnnotationInstance msgLoggerAnnUsage, SubSystem subSystem) {
final ClassInfo loggerClassInfo = msgLoggerAnnUsage.target().asClass();
getProject().getLogger().lifecycle( "MessageLogger (`%s`) missing id-range", loggerClassInfo.simpleName() );
final List<AnnotationInstance> messageAnnUsages = loggerClassInfo.annotations().get( MSG_ANN_NAME );
if ( messageAnnUsages.isEmpty() ) {
return null;
}
int minId = Integer.MAX_VALUE;
int maxId = Integer.MIN_VALUE;
for ( int i = 0; i < messageAnnUsages.size(); i++ ) {
final AnnotationInstance msgAnnUsage = messageAnnUsages.get( i );
final int msgId = msgAnnUsage.value( "id" ).asInt();
if ( msgId < minId ) {
minId = msgId;
}
else if ( msgId > maxId ) {
maxId = msgId;
}
}
return new IdRange( minId, maxId, loggerClassInfo.simpleName(), false, subSystem );
}
private void generateReport(TreeMap<String, SubSystem> subSystemByName, TreeSet<IdRange> idRanges) {
final File reportFile = prepareReportFile();
assert reportFile.exists();
try ( final OutputStreamWriter fileWriter = new OutputStreamWriter( new FileOutputStream( reportFile ) ) ) {
writeReport( subSystemByName, idRanges, fileWriter );
}
catch (FileNotFoundException e) {
throw new RuntimeException( "Should never happen" );
}
catch (IOException e) {
throw new RuntimeException( "Error writing to report file", e );
}
}
private void writeReport(TreeMap<String, SubSystem> subSystemByName, TreeSet<IdRange> idRanges, OutputStreamWriter fileWriter) {
// for the moment, just dump these to a file in simple text format.
//
// ultimately come back and create an asciidoctor-formatted file
// and run through the asciidoctor task
try {
fileWriter.write( "= Hibernate logging\n\n" );
fileWriter.write( "== Sub-system logging\n\n" );
subSystemByName.forEach( (name, subSystem) -> {
try {
fileWriter.write( "[[" + subSystem.getAnchorName() + "]]\n" );
fileWriter.write( "`" + subSystem.getName() + "`::\n" );
fileWriter.write( " * Logging class-name = `" + subSystem.getLoggingClassName() + "`\n" );
fileWriter.write( " * Description = " + subSystem.getDescription() + "\n" );
if ( subSystem.getIdRange() == null ) {
fileWriter.write( " * id-range = no\n" );
}
else {
fileWriter.write( " * id-range = <<" + subSystem.getIdRange().anchorName + ",yes>>\n" );
}
}
catch (IOException e) {
throw new RuntimeException( "Error writing sub-system entry (" + subSystem.getAnchorName() + ") to report file", e );
}
} );
fileWriter.write( "\n\n" );
fileWriter.write( "== Keyed message logging\n\n" );
idRanges.forEach( (idRange) -> {
try {
fileWriter.write( "[[" + idRange.getAnchorName() + "]]\n" );
fileWriter.write( "`" + idRange.getLabel() + "`::\n" );
fileWriter.write( " * MessageLogger class = `" + idRange.getLoggerClassName() + "`\n" );
fileWriter.write( " * Explicit? = " + idRange.isExplicit() + "\n" );
final SubSystem subSystem = idRange.getSubSystem();
if ( subSystem == null ) {
fileWriter.write( " * sub-system? = no\n" );
}
else {
fileWriter.write( " * sub-system? = <<" + subSystem.getAnchorName() + ",yes>>\n" );
}
}
catch (IOException e) {
throw new RuntimeException( "Error writing msg-id entry (" + idRange.getAnchorName() + ") to report file", e );
}
} );
}
catch (IOException e) {
throw new RuntimeException( "Error writing to report file", e );
}
}
private static class SubSystem {
private final String name;
private final String description;
private final String loggingClassName;
private final String anchorName;
private IdRange idRange;
public SubSystem(String name, String description, String loggingClassName) {
this.name = name;
this.description = description;
this.loggingClassName = loggingClassName;
this.anchorName = determineAnchorName( name );
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public String getLoggingClassName() {
return loggingClassName;
}
public String getAnchorName() {
return anchorName;
}
public IdRange getIdRange() {
return idRange;
}
private static String determineAnchorName(final String name) {
final String baseName;
if ( name.startsWith( "org.hibernate.orm." ) ) {
baseName = name.substring( "org.hibernate.orm.".length() );
}
else if ( name.startsWith( "org.hibernate." ) ) {
baseName = name.substring( "org.hibernate.".length() );
}
else {
baseName = name;
}
return baseName.replace( '.', '_' );
}
}
private static class IdRange {
private final int minValue;
private final int maxValue;
private final String loggerClassName;
private final boolean explicit;
private final SubSystem subSystem;
private final String anchorName;
public IdRange(
int minValue,
int maxValue,
String loggerClassName,
boolean explicit,
SubSystem subSystem) {
this.minValue = minValue;
this.maxValue = maxValue;
this.loggerClassName = loggerClassName;
this.explicit = explicit;
this.subSystem = subSystem;
this.anchorName = "HHH" + minValue;
}
public int getMinValue() {
return minValue;
}
public int getMaxValue() {
return maxValue;
}
public String getLoggerClassName() {
return loggerClassName;
}
public boolean isExplicit() {
return explicit;
}
public SubSystem getSubSystem() {
return subSystem;
}
public String getAnchorName() {
return anchorName;
}
public String getLabel() {
return String.format( "HHH%06d - HHH%06d", minValue, maxValue );
}
}
}

View File

@ -8,6 +8,7 @@ package org.hibernate.orm.post;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.Configuration;
/**
@ -23,32 +24,39 @@ public class ReportGenerationPlugin implements Plugin<Project> {
.maybeCreate( CONFIG_NAME )
.setDescription( "Used to collect the jars with classes files to be used in the aggregation reports for `@Internal`, `@Incubating`, etc" );
final Task groupingTask = project.getTasks().maybeCreate( "generateHibernateReports" );
groupingTask.setGroup( TASK_GROUP_NAME );
final IndexManager indexManager = new IndexManager( artifactsToProcess, project );
final IndexerTask indexerTask = project.getTasks().create(
"buildAggregatedIndex",
IndexerTask.class,
indexManager
);
groupingTask.dependsOn( indexerTask );
final IncubationReportTask incubatingTask = project.getTasks().create(
"createIncubationReport",
"generateIncubationReport",
IncubationReportTask.class,
indexManager
);
incubatingTask.dependsOn( indexerTask );
groupingTask.dependsOn( incubatingTask );
final InternalsReportTask internalsTask = project.getTasks().create(
"createInternalsReport",
"generateInternalsReport",
InternalsReportTask.class,
indexManager
);
internalsTask.dependsOn( indexerTask );
groupingTask.dependsOn( internalsTask );
final LoggingReportTask loggingTask = project.getTasks().create(
"createLoggingReport",
"generateLoggingReport",
LoggingReportTask.class,
indexManager
);
loggingTask.dependsOn( indexerTask );
groupingTask.dependsOn( loggingTask );
}
}

View File

@ -28,13 +28,14 @@ import org.hibernate.service.spi.ServiceRegistryAwareService;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.Stoppable;
import org.jboss.logging.Logger;
import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.ProxoolFacade;
import org.logicalcobwebs.proxool.configuration.JAXPConfigurator;
import org.logicalcobwebs.proxool.configuration.PropertyConfigurator;
import static org.hibernate.proxool.internal.ProxoolMessageLogger.PROXOOL_LOGGER;
import static org.hibernate.proxool.internal.ProxoolMessageLogger.PROXOOL_MESSAGE_LOGGER;
/**
* A connection provider that uses a Proxool connection pool. Hibernate will use this by
* default if the {@code hibernate.proxool.*} properties are set.
@ -43,10 +44,6 @@ import org.logicalcobwebs.proxool.configuration.PropertyConfigurator;
*/
public class ProxoolConnectionProvider
implements ConnectionProvider, Configurable, Stoppable, ServiceRegistryAwareService {
private static final ProxoolMessageLogger LOG = Logger.getMessageLogger(
ProxoolMessageLogger.class,
ProxoolConnectionProvider.class.getName()
);
private static final String PROXOOL_JDBC_STEM = "proxool.";
@ -125,8 +122,8 @@ public class ProxoolConnectionProvider
if ( "true".equals( externalConfig ) ) {
// Validate that an alias name was provided to determine which pool to use
if ( !StringHelper.isNotEmpty( proxoolAlias ) ) {
final String msg = LOG.unableToConfigureProxoolProviderToUseExistingInMemoryPool( Environment.PROXOOL_POOL_ALIAS );
LOG.error( msg );
final String msg = PROXOOL_MESSAGE_LOGGER.unableToConfigureProxoolProviderToUseExistingInMemoryPool( Environment.PROXOOL_POOL_ALIAS );
PROXOOL_LOGGER.error( msg );
throw new HibernateException( msg );
}
// Append the stem to the proxool pool alias
@ -135,17 +132,17 @@ public class ProxoolConnectionProvider
// Set the existing pool flag to true
existingPool = true;
LOG.configuringProxoolProviderUsingExistingPool( proxoolAlias );
PROXOOL_MESSAGE_LOGGER.configuringProxoolProviderUsingExistingPool( proxoolAlias );
// Configured using the JAXP Configurator
}
else if ( StringHelper.isNotEmpty( jaxpFile ) ) {
LOG.configuringProxoolProviderUsingJaxpConfigurator( jaxpFile );
PROXOOL_MESSAGE_LOGGER.configuringProxoolProviderUsingJaxpConfigurator( jaxpFile );
// Validate that an alias name was provided to determine which pool to use
if ( !StringHelper.isNotEmpty( proxoolAlias ) ) {
final String msg = LOG.unableToConfigureProxoolProviderToUseJaxp( Environment.PROXOOL_POOL_ALIAS );
LOG.error( msg );
final String msg = PROXOOL_MESSAGE_LOGGER.unableToConfigureProxoolProviderToUseJaxp( Environment.PROXOOL_POOL_ALIAS );
PROXOOL_LOGGER.error( msg );
throw new HibernateException( msg );
}
@ -153,24 +150,24 @@ public class ProxoolConnectionProvider
JAXPConfigurator.configure( getConfigStreamReader( jaxpFile ), false );
}
catch (ProxoolException e) {
final String msg = LOG.unableToLoadJaxpConfiguratorFile( jaxpFile );
LOG.error( msg, e );
final String msg = PROXOOL_MESSAGE_LOGGER.unableToLoadJaxpConfiguratorFile( jaxpFile );
PROXOOL_LOGGER.error( msg, e );
throw new HibernateException( msg, e );
}
// Append the stem to the proxool pool alias
proxoolAlias = PROXOOL_JDBC_STEM + proxoolAlias;
LOG.configuringProxoolProviderToUsePoolAlias( proxoolAlias );
PROXOOL_MESSAGE_LOGGER.configuringProxoolProviderToUsePoolAlias( proxoolAlias );
// Configured using the Properties File Configurator
}
else if ( StringHelper.isNotEmpty( propFile ) ) {
LOG.configuringProxoolProviderUsingPropertiesFile( propFile );
PROXOOL_MESSAGE_LOGGER.configuringProxoolProviderUsingPropertiesFile( propFile );
// Validate that an alias name was provided to determine which pool to use
if ( !StringHelper.isNotEmpty( proxoolAlias ) ) {
final String msg = LOG.unableToConfigureProxoolProviderToUsePropertiesFile( Environment.PROXOOL_POOL_ALIAS );
LOG.error( msg );
final String msg = PROXOOL_MESSAGE_LOGGER.unableToConfigureProxoolProviderToUsePropertiesFile( Environment.PROXOOL_POOL_ALIAS );
PROXOOL_LOGGER.error( msg );
throw new HibernateException( msg );
}
@ -178,22 +175,22 @@ public class ProxoolConnectionProvider
PropertyConfigurator.configure( getConfigProperties( propFile ) );
}
catch (ProxoolException e) {
final String msg = LOG.unableToLoadPropertyConfiguratorFile( propFile );
LOG.error( msg, e );
final String msg = PROXOOL_MESSAGE_LOGGER.unableToLoadPropertyConfiguratorFile( propFile );
PROXOOL_LOGGER.error( msg, e );
throw new HibernateException( msg, e );
}
// Append the stem to the proxool pool alias
proxoolAlias = PROXOOL_JDBC_STEM + proxoolAlias;
LOG.configuringProxoolProviderToUsePoolAlias( proxoolAlias );
PROXOOL_MESSAGE_LOGGER.configuringProxoolProviderToUsePoolAlias( proxoolAlias );
}
// Remember Isolation level
isolation = ConnectionProviderInitiator.extractIsolation( props );
LOG.jdbcIsolationLevel( ConnectionProviderInitiator.toIsolationNiceName( isolation ) );
PROXOOL_MESSAGE_LOGGER.jdbcIsolationLevel( ConnectionProviderInitiator.toIsolationNiceName( isolation ) );
autocommit = ConfigurationHelper.getBoolean( Environment.AUTOCOMMIT, props );
LOG.autoCommitMode( autocommit );
PROXOOL_MESSAGE_LOGGER.autoCommitMode( autocommit );
}
private Reader getConfigStreamReader(String resource) {
@ -236,8 +233,8 @@ public class ProxoolConnectionProvider
catch (Exception e) {
// If you're closing down the ConnectionProvider chances are an
// is not a real big deal, just warn
final String msg = LOG.exceptionClosingProxoolPool();
LOG.warn( msg, e );
final String msg = PROXOOL_MESSAGE_LOGGER.exceptionClosingProxoolPool();
PROXOOL_LOGGER.warn( msg, e );
throw new HibernateException( msg, e );
}
}

View File

@ -7,7 +7,9 @@
package org.hibernate.proxool.internal;
import org.hibernate.internal.log.ConnectionPoolingLogger;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.LogMessage;
import org.jboss.logging.annotations.Message;
import org.jboss.logging.annotations.MessageLogger;
@ -23,7 +25,14 @@ import static org.jboss.logging.Logger.Level.INFO;
*/
@MessageLogger(projectCode = "HHH")
@ValidIdRange( min = 30001, max = 35000 )
@SubSystemLogging(
name = ProxoolMessageLogger.LOGGER_NAME,
description = "Logs details related to Proxool connection pooling"
)
public interface ProxoolMessageLogger extends ConnectionPoolingLogger {
String LOGGER_NAME = ConnectionPoolingLogger.LOGGER_NAME + ".proxool";
Logger PROXOOL_LOGGER = Logger.getLogger( LOGGER_NAME );
ProxoolMessageLogger PROXOOL_MESSAGE_LOGGER = Logger.getMessageLogger( ProxoolMessageLogger.class, LOGGER_NAME );
/**
* Logs the name of a named pool to be used for configuration information

View File

@ -7,6 +7,8 @@
package org.hibernate.spatial;
import org.hibernate.internal.log.SubSystemLogging;
import org.jboss.logging.BasicLogger;
import org.jboss.logging.Logger;
import org.jboss.logging.annotations.LogMessage;
@ -23,11 +25,16 @@ import static org.jboss.logging.Logger.Level.INFO;
*/
@MessageLogger(projectCode = "HHH")
@ValidIdRange(min = 80000001, max = 80001000)
@SubSystemLogging(
name = HSMessageLogger.LOGGER_NAME,
description = "Base logging for Hibernate Spatial",
mixed = true
)
public interface HSMessageLogger extends BasicLogger {
String LOGGER_NAME = "org.hibernate.spatial";
HSMessageLogger LOGGER = Logger.getMessageLogger( HSMessageLogger.class, LOGGER_NAME );
HSMessageLogger SPATIAL_MSG_LOGGER = Logger.getMessageLogger( HSMessageLogger.class, LOGGER_NAME );
@LogMessage(level = INFO)
@Message(value = "hibernate-spatial integration enabled : %s", id = 80000001)

View File

@ -27,13 +27,13 @@ public class CockroachDbContributor implements ContributorImplementor {
@Override
public void contributeJdbcTypes(TypeContributions typeContributions) {
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.typeContributions( this.getClass().getCanonicalName() );
typeContributions.contributeJdbcType( PGGeometryJdbcType.INSTANCE_WKB_2 );
}
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.functionContributions( this.getClass().getCanonicalName() );
final PostgisSqmFunctionDescriptors postgisFunctions = new PostgisSqmFunctionDescriptors( functionContributions );
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();

View File

@ -24,13 +24,13 @@ public class H2GisDialectContributor implements ContributorImplementor {
}
public void contributeJdbcTypes(TypeContributions typeContributions) {
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.typeContributions( this.getClass().getCanonicalName() );
typeContributions.contributeJdbcType( H2GISGeometryType.INSTANCE );
}
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.functionContributions( this.getClass().getCanonicalName() );
final KeyedSqmFunctionDescriptors functions = new H2SqmFunctionDescriptors( functionContributions );
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
functions.asMap().forEach( (key, desc) -> {

View File

@ -25,13 +25,13 @@ public class MariaDBDialectContributor implements ContributorImplementor {
}
public void contributeJdbcTypes(TypeContributions typeContributions) {
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.typeContributions( this.getClass().getCanonicalName() );
typeContributions.contributeJdbcType( MySQLGeometryJdbcType.INSTANCE );
}
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.functionContributions( this.getClass().getCanonicalName() );
final KeyedSqmFunctionDescriptors mariaDbFunctions = new MariaDBSqmFunctionDescriptors( functionContributions );
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
mariaDbFunctions.asMap().forEach( (key, desc) -> {

View File

@ -25,13 +25,13 @@ public class MySQLDialectContributor implements ContributorImplementor {
@Override
public void contributeJdbcTypes(TypeContributions typeContributions) {
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.typeContributions( this.getClass().getCanonicalName() );
typeContributions.contributeJdbcType( MySQLGeometryJdbcType.INSTANCE);
}
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.functionContributions( this.getClass().getCanonicalName() );
final KeyedSqmFunctionDescriptors mysqlFunctions = new MySqlSqmFunctionDescriptors( functionContributions );
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
mysqlFunctions.asMap().forEach( (key, desc) -> {

View File

@ -39,7 +39,7 @@ public class OracleDialectContributor implements ContributorImplementor {
@Override
public void contributeJdbcTypes(TypeContributions typeContributions) {
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.typeContributions( this.getClass().getCanonicalName() );
final ConfigurationService cfgService = getServiceRegistry().getService( ConfigurationService.class );
final StrategySelector strategySelector = getServiceRegistry().getService( StrategySelector.class );
@ -53,7 +53,7 @@ public class OracleDialectContributor implements ContributorImplementor {
)
);
HSMessageLogger.LOGGER.connectionFinder( connectionFinder.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.connectionFinder( connectionFinder.getClass().getCanonicalName() );
SDOGeometryType sdoGeometryType = new SDOGeometryType(
new OracleJDBCTypeFactory( connectionFinder ), useSTGeometry
@ -64,7 +64,7 @@ public class OracleDialectContributor implements ContributorImplementor {
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.functionContributions( this.getClass().getCanonicalName() );
KeyedSqmFunctionDescriptors functionDescriptors;
if ( useSTGeometry ) {

View File

@ -24,13 +24,13 @@ public class PostgisDialectContributor implements ContributorImplementor {
@Override
public void contributeJdbcTypes(TypeContributions typeContributions) {
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.typeContributions( this.getClass().getCanonicalName() );
typeContributions.contributeJdbcType( PGGeometryJdbcType.INSTANCE_WKB_2 );
}
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.functionContributions( this.getClass().getCanonicalName() );
final PostgisSqmFunctionDescriptors postgisFunctions = new PostgisSqmFunctionDescriptors( functionContributions );
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
postgisFunctions.asMap().forEach( (key, desc) -> {

View File

@ -23,13 +23,13 @@ public class SqlServerDialectContributor implements ContributorImplementor {
@Override
public void contributeJdbcTypes(TypeContributions typeContributions) {
HSMessageLogger.LOGGER.typeContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.typeContributions( this.getClass().getCanonicalName() );
typeContributions.contributeJdbcType( SqlServerGeometryType.INSTANCE );
}
@Override
public void contributeFunctions(FunctionContributions functionContributions) {
HSMessageLogger.LOGGER.functionContributions( this.getClass().getCanonicalName() );
HSMessageLogger.SPATIAL_MSG_LOGGER.functionContributions( this.getClass().getCanonicalName() );
final SqlServerSqmFunctionDescriptors functions = new SqlServerSqmFunctionDescriptors( functionContributions );
final SqmFunctionRegistry functionRegistry = functionContributions.getFunctionRegistry();
functions.asMap().forEach( (key, desc) -> {