github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/nlog/debug_on.go (about)

     1  //go:build debug
     2  
     3  // Package nlog
     4  /*
     5   * Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
     6   */
     7  package nlog
     8  
     9  import (
    10  	"fmt"
    11  	"os"
    12  	rdebug "runtime/debug"
    13  )
    14  
    15  func assert(cond bool, a ...any) {
    16  	if !cond {
    17  		msg := "nlog assertion failed"
    18  		if len(a) > 0 {
    19  			msg += ": " + fmt.Sprint(a...)
    20  		}
    21  		if Stopping() {
    22  			os.Stderr.WriteString(wstag + msg + "\n")
    23  			return
    24  		}
    25  		os.Stderr.WriteString(msg + "\n")
    26  		rdebug.PrintStack()
    27  		os.Exit(1)
    28  	}
    29  }