Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JACOBIN-498 Make trace.ErrorMsg formatting like log.Log-severe #246

Merged
merged 2 commits into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Init() {

// Trace is the principal tracing function. Note that it currently
// writes to stderr. At some future point, this might become an option.
func Trace(msg string) {
func Trace(argMsg string) {

var err error

Expand All @@ -45,18 +45,26 @@ func Trace(msg string) {

// Lock access to the logging stream to prevent inter-thread overwrite issues
mutex.Lock()
_, err = fmt.Fprintf(os.Stderr, "[%3d.%03ds] %s\n", millis/1000, millis%1000, msg)
_, err = fmt.Fprintf(os.Stderr, "[%3d.%03ds] %s\n", millis/1000, millis%1000, argMsg)
mutex.Unlock()
if err != nil {
errMsg := fmt.Sprintf("*** stderr failed, err: %v", err)
errMsg := fmt.Sprintf("Trace: *** stderr failed, err: %v", err)
abruptEnd(excNames.IOError, errMsg)
}

}

// An error message is just a prefix-decorated message.
func ErrorMsg(msg string) {
Trace("*** ERROR *** " + msg)
// An error message is a prefix-decorated message that has no time-stamp.
func ErrorMsg(argMsg string) {
var err error
errMsg := "*** ERROR *** " + argMsg
mutex.Lock()
_, err = fmt.Fprintf(os.Stderr, "%s\n", errMsg)
mutex.Unlock()
if err != nil {
errMsg := fmt.Sprintf("ErrorMsg: *** stderr failed, err: %v", err)
abruptEnd(excNames.IOError, errMsg)
}
}

// Duplicated from minimalAbort in the exceptions package exceptions.go due to a Go-diagnosed cycle.
Expand Down