/* TODO: encrypted debug and error messages?! yes please! - you may want an application that can detect that messages have happend while only being able to read them within the admin context */ func (node *Node) debugMsg(content string) { if node.debugMode { msg := new(api.Msg) msg.Name = "[DEBUG]" msg.Content = bytes.NewBufferString(content) node.Err() <- *msg } }
func (node *Node) errMsg(err error, fatal bool) { msg := new(api.Msg) if node.debugMode { msg.Content = bytes.NewBufferString(err.Error() + "\n---\n" + string(debug.Stack())) } else { msg.Content = bytes.NewBufferString(err.Error()) } msg.Name = "[ERROR]" msg.IsChan = fatal // use the "is channel" message flag as the "is fatal" flag node.Err() <- *msg if msg.IsChan { node.Stop() } }