Skip to content

Commit

Permalink
Fix secondary exceptions from console (#5518)
Browse files Browse the repository at this point in the history

Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso authored Nov 20, 2024
1 parent fa0e8e0 commit 99a7f37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import nextflow.util.Barrier
import nextflow.util.ConfigHelper
import nextflow.util.Duration
import nextflow.util.HistoryFile
import nextflow.util.LoggerHelper
import nextflow.util.NameGenerator
import nextflow.util.SysHelper
import nextflow.util.ThreadPoolManager
Expand Down Expand Up @@ -787,10 +788,11 @@ class Session implements ISession {
*/
void abort(Throwable cause = null) {
if( aborted ) return
if( !(cause instanceof ScriptCompilationException) )
if( cause !instanceof ScriptCompilationException )
log.debug "Session aborted -- Cause: ${cause?.message ?: cause ?: '-'}"
aborted = true
error = cause
LoggerHelper.aborted = true
try {
// log the dataflow network status
def status = dumpNetworkStatus()
Expand Down
16 changes: 12 additions & 4 deletions modules/nextflow/src/main/groovy/nextflow/util/LoggerHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

package nextflow.util

import ch.qos.logback.core.encoder.Encoder
import ch.qos.logback.core.spi.FilterAttachable
import ch.qos.logback.core.spi.LifeCycle

import static nextflow.Const.*

import java.lang.reflect.Field
Expand All @@ -28,6 +24,7 @@ import java.nio.file.FileAlreadyExistsException
import java.nio.file.NoSuchFileException
import java.nio.file.Path
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
import java.util.regex.Pattern

import ch.qos.logback.classic.Level
Expand All @@ -42,13 +39,16 @@ import ch.qos.logback.core.ConsoleAppender
import ch.qos.logback.core.CoreConstants
import ch.qos.logback.core.FileAppender
import ch.qos.logback.core.LayoutBase
import ch.qos.logback.core.encoder.Encoder
import ch.qos.logback.core.encoder.LayoutWrappingEncoder
import ch.qos.logback.core.filter.Filter
import ch.qos.logback.core.joran.spi.NoAutoStart
import ch.qos.logback.core.rolling.FixedWindowRollingPolicy
import ch.qos.logback.core.rolling.RollingFileAppender
import ch.qos.logback.core.rolling.TriggeringPolicyBase
import ch.qos.logback.core.spi.FilterAttachable
import ch.qos.logback.core.spi.FilterReply
import ch.qos.logback.core.spi.LifeCycle
import ch.qos.logback.core.util.FileSize
import groovy.transform.CompileStatic
import groovy.transform.PackageScope
Expand Down Expand Up @@ -85,6 +85,10 @@ import org.slf4j.MarkerFactory
@CompileStatic
class LoggerHelper {

static volatile boolean aborted

static final AtomicInteger errCount = new AtomicInteger()

static private Logger log = LoggerFactory.getLogger(LoggerHelper)

static public Marker STICKY = MarkerFactory.getMarker('sticky')
Expand Down Expand Up @@ -419,6 +423,10 @@ class LoggerHelper {
return FilterReply.NEUTRAL;
}

// print to console only the very first error log and ignore the others
if( aborted && event.level==Level.ERROR && errCount.getAndIncrement()>0 )
return FilterReply.DENY;

def logger = event.getLoggerName()
def level = event.getLevel()
for( int i=0; i<len; i++ ) {
Expand Down

0 comments on commit 99a7f37

Please sign in to comment.