You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Alex Orlov <oo...@mail.ru.INVALID> on 2021/06/22 07:44:02 UTC

Getting logging messages in child process immediately

Hi all,
 
I use JPMS test modules and for debugging I use the following command:
mvn -Dmaven.failsafe.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspe=y,address=8000 -Xnoagent -Djava.compiler=NONE" clean verify -P it
 
So, all tests are executed in child process. However, there is one problem. When tests are executed in child process
then messages are printed on console only after test is executed. But, I need to see messages during debugging immediately.
As I found out messages are printed on console after the following code in
 org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelEncoder
 
    private void encodeAndPrintEvent( StringBuilder event, boolean sendImmediately )
    {
        try
        {
            //noinspection ResultOfMethodCallIgnored
            Thread.interrupted();
            byte[] array = event.append( '\n' )
                .toString()
                .getBytes( STREAM_ENCODING );
            ByteBuffer bb = ByteBuffer.wrap( array );
            if ( sendImmediately )
            {
                out.write( bb );   <========================== AFTER THIS LINE
            }
            else
            {
                out.writeBuffered( bb );
            }
        }
        catch ( ClosedChannelException e )
        {
            if ( !onExit )
            {
                DumpErrorSingleton.getSingleton()
                    .dumpException( e, "Channel closed while writing the event '" + event + "'." );
            }
        }
    …..
    }
 
Could anyone sat if there is any solution/flag to print log messages from child process on console immediately?
 
 
 
--
Best regards, Alex Orlov
 

Re[2]: Getting logging messages in child process immediately

Posted by Alex Orlov <oo...@mail.ru.INVALID>.
I still have no solution. Can anyone help me?
 
 
--
Best regards, Alex Orlov
 
  
>Вторник, 22 июня 2021, 11:47 +03:00 от Mantas Gridinas <mg...@gmail.com>:
> 
>Try flushing or something equivalent  
>On Tue, Jun 22, 2021, 10:44 Alex Orlov < ooo_saturn7@mail.ru.invalid > wrote:
>  
>>Hi all,
>> 
>>I use JPMS test modules and for debugging I use the following command:
>>mvn -Dmaven.failsafe.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspe=y,address=8000 -Xnoagent -Djava.compiler=NONE" clean verify -P it
>> 
>>So, all tests are executed in child process. However, there is one problem. When tests are executed in child process
>>then messages are printed on console only after test is executed. But, I need to see messages during debugging immediately.
>>As I found out messages are printed on console after the following code in
>> org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelEncoder
>> 
>>    private void encodeAndPrintEvent( StringBuilder event, boolean sendImmediately )
>>    {
>>        try
>>        {
>>            //noinspection ResultOfMethodCallIgnored
>>            Thread.interrupted();
>>            byte[] array = event.append( '\n' )
>>                .toString()
>>                .getBytes( STREAM_ENCODING );
>>            ByteBuffer bb = ByteBuffer.wrap( array );
>>            if ( sendImmediately )
>>            {
>>                out.write( bb );   <========================== AFTER THIS LINE
>>            }
>>            else
>>            {
>>                out.writeBuffered( bb );
>>            }
>>        }
>>        catch ( ClosedChannelException e )
>>        {
>>            if ( !onExit )
>>            {
>>                DumpErrorSingleton.getSingleton()
>>                    .dumpException( e, "Channel closed while writing the event '" + event + "'." );
>>            }
>>        }
>>    …..
>>    }
>> 
>>Could anyone sat if there is any solution/flag to print log messages from child process on console immediately?
>> 
>> 
>> 
>>--
>>Best regards, Alex Orlov
>> 
 

Re: Getting logging messages in child process immediately

Posted by Mantas Gridinas <mg...@gmail.com>.
Try flushing or something equivalent

On Tue, Jun 22, 2021, 10:44 Alex Orlov <oo...@mail.ru.invalid> wrote:

>
> Hi all,
>
> I use JPMS test modules and for debugging I use the following command:
> mvn -Dmaven.failsafe.debug="-Xdebug
> -Xrunjdwp:transport=dt_socket,server=y,suspe=y,address=8000 -Xnoagent
> -Djava.compiler=NONE" clean verify -P it
>
> So, all tests are executed in child process. However, there is one
> problem. When tests are executed in child process
> then messages are printed on console only after test is executed. But, I
> need to see messages during debugging immediately.
> As I found out messages are printed on console after the following code in
>  org.apache.maven.surefire.booter.spi.LegacyMasterProcessChannelEncoder
>
>     private void encodeAndPrintEvent( StringBuilder event, boolean
> sendImmediately )
>     {
>         try
>         {
>             //noinspection ResultOfMethodCallIgnored
>             Thread.interrupted();
>             byte[] array = event.append( '\n' )
>                 .toString()
>                 .getBytes( STREAM_ENCODING );
>             ByteBuffer bb = ByteBuffer.wrap( array );
>             if ( sendImmediately )
>             {
>                 out.write( bb );   <========================== AFTER THIS
> LINE
>             }
>             else
>             {
>                 out.writeBuffered( bb );
>             }
>         }
>         catch ( ClosedChannelException e )
>         {
>             if ( !onExit )
>             {
>                 DumpErrorSingleton.getSingleton()
>                     .dumpException( e, "Channel closed while writing the
> event '" + event + "'." );
>             }
>         }
>     …..
>     }
>
> Could anyone sat if there is any solution/flag to print log messages from
> child process on console immediately?
>
>
>
> --
> Best regards, Alex Orlov
>