Mike Schwörer
d38fa60fbc
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m37s
36 lines
567 B
Go
36 lines
567 B
Go
package exerr
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
type Method string
|
|
|
|
const (
|
|
MethodOutput Method = "OUTPUT"
|
|
MethodPrint Method = "PRINT"
|
|
MethodBuild Method = "BUILD"
|
|
MethodFatal Method = "FATAL"
|
|
)
|
|
|
|
type Listener = func(method Method, v *ExErr)
|
|
|
|
var listenerLock = sync.Mutex{}
|
|
var listener = make([]Listener, 0)
|
|
|
|
func RegisterListener(l Listener) {
|
|
listenerLock.Lock()
|
|
defer listenerLock.Unlock()
|
|
|
|
listener = append(listener, l)
|
|
}
|
|
|
|
func (ee *ExErr) CallListener(m Method) {
|
|
listenerLock.Lock()
|
|
defer listenerLock.Unlock()
|
|
|
|
for _, v := range listener {
|
|
v(m, ee)
|
|
}
|
|
}
|