2024-10-16 01:29:44 +09:00
|
|
|
// Package fmsg provides various functions for output messages.
|
|
|
|
package fmsg
|
2024-10-21 20:47:02 +09:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2024-10-26 23:09:32 +09:00
|
|
|
var std = log.New(os.Stderr, "fortify: ", 0)
|
2024-10-21 20:47:02 +09:00
|
|
|
|
|
|
|
func SetPrefix(prefix string) {
|
|
|
|
prefix += ": "
|
|
|
|
std.SetPrefix(prefix)
|
2024-10-26 23:09:32 +09:00
|
|
|
std.SetPrefix(prefix)
|
2024-10-21 20:47:02 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func Print(v ...any) {
|
2024-10-26 23:09:32 +09:00
|
|
|
dequeueOnce.Do(dequeue)
|
|
|
|
queueSync.Add(1)
|
|
|
|
msgbuf <- dPrint(v)
|
2024-10-21 20:47:02 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func Printf(format string, v ...any) {
|
2024-10-26 23:09:32 +09:00
|
|
|
dequeueOnce.Do(dequeue)
|
|
|
|
queueSync.Add(1)
|
|
|
|
msgbuf <- &dPrintf{format, v}
|
2024-10-21 20:47:02 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func Println(v ...any) {
|
2024-10-26 23:09:32 +09:00
|
|
|
dequeueOnce.Do(dequeue)
|
|
|
|
queueSync.Add(1)
|
|
|
|
msgbuf <- dPrintln(v)
|
2024-10-21 20:47:02 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func Fatal(v ...any) {
|
2024-10-26 23:09:32 +09:00
|
|
|
Print(v...)
|
|
|
|
Exit(1)
|
2024-10-21 20:47:02 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
func Fatalf(format string, v ...any) {
|
2024-10-26 23:09:32 +09:00
|
|
|
Printf(format, v...)
|
|
|
|
Exit(1)
|
2024-10-21 20:47:02 +09:00
|
|
|
}
|