HHH-14152 sql-script.g fix for antlr non deterministic warning
- Added "system"-style SqlScriptLogging - Added rule trace logging through SqlScriptLogging
This commit is contained in:
parent
8beb1a2c65
commit
b4afea78b5
|
@ -76,7 +76,7 @@ quotedString
|
||||||
;
|
;
|
||||||
|
|
||||||
afterStatementPartNewline
|
afterStatementPartNewline
|
||||||
: NEWLINE {
|
: n:NEWLINE {
|
||||||
out( " " );
|
out( " " );
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
import org.jboss.logging.annotations.ValidIdRange;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@ValidIdRange( )
|
||||||
|
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();
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,6 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.hibernate.hql.internal.ast.util.ASTUtil;
|
import org.hibernate.hql.internal.ast.util.ASTUtil;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.tool.schema.SchemaToolingLogging;
|
|
||||||
|
|
||||||
import antlr.RecognitionException;
|
import antlr.RecognitionException;
|
||||||
import antlr.Token;
|
import antlr.Token;
|
||||||
|
@ -65,6 +64,7 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void out(String text) {
|
protected void out(String text) {
|
||||||
|
SqlScriptLogging.SCRIPT_LOGGER.tracef( "#out(`%s`) [text]", text );
|
||||||
currentStatementBuffer.append( text );
|
currentStatementBuffer.append( text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,13 +73,15 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void out(Token token) {
|
protected void out(Token token) {
|
||||||
|
SqlScriptLogging.SCRIPT_LOGGER.tracef( "#out(`%s`) [token]", token.getText() );
|
||||||
|
|
||||||
currentStatementBuffer.append( token.getText() );
|
currentStatementBuffer.append( token.getText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void statementStarted() {
|
protected void statementStarted() {
|
||||||
if ( currentStatementBuffer != null ) {
|
if ( currentStatementBuffer != null ) {
|
||||||
SchemaToolingLogging.LOGGER.debugf( "`#currentStatementBuffer` was not null at `#statementStart`" );
|
SqlScriptLogging.SCRIPT_LOGGER.debugf( "`#currentStatementBuffer` was not null at `#statementStart`" );
|
||||||
}
|
}
|
||||||
currentStatementBuffer = new StringBuilder();
|
currentStatementBuffer = new StringBuilder();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +92,7 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
|
||||||
@Override
|
@Override
|
||||||
protected void statementEnded() {
|
protected void statementEnded() {
|
||||||
final String statementText = currentStatementBuffer.toString().trim();
|
final String statementText = currentStatementBuffer.toString().trim();
|
||||||
SchemaToolingLogging.LOGGER.debugf( "Import statement : %s", statementText );
|
SqlScriptLogging.AST_LOGGER.debugf( "Import statement : %s", statementText );
|
||||||
commandConsumer.accept( statementText );
|
commandConsumer.accept( statementText );
|
||||||
|
|
||||||
currentStatementBuffer = null;
|
currentStatementBuffer = null;
|
||||||
|
@ -142,7 +144,7 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reportWarning(String message) {
|
public void reportWarning(String message) {
|
||||||
SchemaToolingLogging.LOGGER.debugf( "SqlScriptParser recognition warning : " + message );
|
SqlScriptLogging.SCRIPT_LOGGER.debugf( "SqlScriptParser recognition warning : " + message );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -153,7 +155,7 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void traceIn(String ruleName) {
|
public void traceIn(String ruleName) {
|
||||||
if ( ! SchemaToolingLogging.AST_TRACE_ENABLED ) {
|
if ( ! SqlScriptLogging.AST_TRACE_ENABLED ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,12 +164,12 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String prefix = StringHelper.repeat( '-', ( traceDepth++ * depthIndent ) );
|
final String prefix = StringHelper.repeat( '-', ( traceDepth++ * depthIndent ) );
|
||||||
SchemaToolingLogging.AST_LOGGER.tracef( "%s-> %s", prefix, ruleName );
|
SqlScriptLogging.AST_LOGGER.tracef( "%s-> %s", prefix, ruleName );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void traceOut(String ruleName) {
|
public void traceOut(String ruleName) {
|
||||||
if ( ! SchemaToolingLogging.AST_TRACE_ENABLED ) {
|
if ( ! SqlScriptLogging.AST_TRACE_ENABLED ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +178,6 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
final String prefix = StringHelper.repeat( '-', ( --traceDepth * depthIndent ) );
|
final String prefix = StringHelper.repeat( '-', ( --traceDepth * depthIndent ) );
|
||||||
SchemaToolingLogging.AST_LOGGER.tracef( "<-%s %s", prefix, ruleName );
|
SqlScriptLogging.AST_LOGGER.tracef( "<-%s %s", prefix, ruleName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,9 @@ log4j.rootLogger=info, stdout
|
||||||
|
|
||||||
log4j.logger.org.hibernate.orm.graph=debug
|
log4j.logger.org.hibernate.orm.graph=debug
|
||||||
|
|
||||||
#log4j.logger.org.hibernate.orm.tooling.schema=trace
|
#log4j.logger.org.hibernate.orm.tooling.schema.script=trace
|
||||||
## the AST logger gets very verbose at trace
|
#log4j.logger.org.hibernate.orm.tooling.schema.script.graph=trace
|
||||||
#log4j.logger.org.hibernate.orm.tooling.schema.AST=debug
|
|
||||||
|
|
||||||
log4j.logger.org.hibernate.tool.hbm2ddl=trace
|
log4j.logger.org.hibernate.tool.hbm2ddl=trace
|
||||||
log4j.logger.org.hibernate.testing.cache=debug
|
log4j.logger.org.hibernate.testing.cache=debug
|
||||||
|
|
Loading…
Reference in New Issue