github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/log/util.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package log
     4  
     5  import (
     6  	"runtime"
     7  
     8  	"../protocol"
     9  )
    10  
    11  func CallerInfo(calldepth int) (file string, line int) {
    12  	var ok bool
    13  	_, file, line, ok = runtime.Caller(calldepth)
    14  	if !ok {
    15  		file = "?"
    16  		line = 0
    17  	}
    18  	return
    19  }
    20  
    21  // Fatal use as log.Fatal(function()) and not check return error from function.
    22  // It will just panic error not exit app and return to OS, Because all goroutine without any notify will terminate and can't recover in any way.
    23  // So we just panic it and wait to some logic recover it or let app close in main function.
    24  func Fatal(err protocol.Error) {
    25  	if err != nil {
    26  		// os.Exit(125)
    27  		panic(err)
    28  	}
    29  }