logging_log_wasm.go 411 B

123456789101112131415161718192021
  1. //go:build js && wasm
  2. package fairwind
  3. import "syscall/js"
  4. func (this *Log) log(severity int, message string, parameters ...LoggingParameter) {
  5. this.mutex.Lock()
  6. defer this.mutex.Unlock()
  7. line, err := this.formatter.Format(
  8. *NewLogLine(severity, message, parameters),
  9. )
  10. if err != nil {
  11. // TODO: log error OS-specific
  12. return
  13. }
  14. console := js.Global().Get("console")
  15. console.Call("log", line)
  16. }