mirror of
https://github.com/postmannen/ctrl.git
synced 2025-03-31 01:24:31 +00:00
cleaned up err console logging
This commit is contained in:
parent
0bf45ef435
commit
f792675ebe
4 changed files with 2 additions and 22 deletions
|
@ -36,7 +36,6 @@ func (s *server) getMessagesFromFile(directoryToCheck string, fileName string, i
|
|||
js, err := jsonFromFileData(b)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: malformed json: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(s.nodeName), er)
|
||||
continue
|
||||
}
|
||||
|
@ -52,7 +51,6 @@ func (s *server) getMessagesFromFile(directoryToCheck string, fileName string, i
|
|||
inputFromFileCh <- js
|
||||
}
|
||||
er := fmt.Errorf("error: getMessagesFromFile stopped")
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(s.nodeName), er)
|
||||
}
|
||||
|
||||
|
|
13
process.go
13
process.go
|
@ -135,7 +135,6 @@ func (p process) spawnWorker(s *server) {
|
|||
err := p.procFunc()
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: spawnWorker: procFunc failed: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(p.newMessagesCh, node(p.node), er)
|
||||
}
|
||||
}()
|
||||
|
@ -156,7 +155,6 @@ func (p process) spawnWorker(s *server) {
|
|||
err := p.procFunc()
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: spawnWorker: procFunc failed: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(p.newMessagesCh, node(p.node), er)
|
||||
}
|
||||
}()
|
||||
|
@ -176,7 +174,6 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
|
|||
dataPayload, err := gobEncodeMessage(message)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: createDataPayload: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(p.newMessagesCh, node(p.node), er)
|
||||
continue
|
||||
}
|
||||
|
@ -198,7 +195,6 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
|
|||
subReply, err := natsConn.SubscribeSync(msg.Reply)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: nc.SubscribeSync failed: failed to create reply message: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(p.newMessagesCh, node(p.node), er)
|
||||
continue
|
||||
}
|
||||
|
@ -207,7 +203,6 @@ func (p process) messageDeliverNats(natsConn *nats.Conn, message Message) {
|
|||
err = natsConn.PublishMsg(msg)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: publish failed: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(p.newMessagesCh, node(p.node), er)
|
||||
continue
|
||||
}
|
||||
|
@ -266,7 +261,6 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na
|
|||
err := gobDec.Decode(&message)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: gob decoding failed: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
}
|
||||
|
||||
|
@ -275,7 +269,6 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na
|
|||
mh, ok := p.methodsAvailable.CheckIfExists(message.Method)
|
||||
if !ok {
|
||||
er := fmt.Errorf("error: subscriberHandler: method type not available: %v", p.subject.CommandOrEvent)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
}
|
||||
|
||||
|
@ -295,12 +288,10 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na
|
|||
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: subscriberHandler: failed to execute event: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
}
|
||||
} else {
|
||||
er := fmt.Errorf("info: we don't allow receiving from: %v, %v", message.FromNode, p.subject)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
}
|
||||
|
||||
|
@ -311,7 +302,6 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na
|
|||
mf, ok := p.methodsAvailable.CheckIfExists(message.Method)
|
||||
if !ok {
|
||||
er := fmt.Errorf("error: subscriberHandler: method type not available: %v", p.subject.CommandOrEvent)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
}
|
||||
|
||||
|
@ -332,18 +322,15 @@ func (p process) subscriberHandler(natsConn *nats.Conn, thisNode string, msg *na
|
|||
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: subscriberHandler: failed to execute event: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
}
|
||||
} else {
|
||||
er := fmt.Errorf("info: we don't allow receiving from: %v, %v", message.FromNode, p.subject)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
}
|
||||
// ---
|
||||
default:
|
||||
er := fmt.Errorf("info: did not find that specific type of command: %#v", p.subject.CommandOrEvent)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(thisNode), er)
|
||||
|
||||
}
|
||||
|
|
|
@ -91,7 +91,6 @@ func (r *ringBuffer) fillBuffer(inCh chan subjectAndMessage, samValueBucket stri
|
|||
s, err := r.dumpBucket(samValueBucket)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: fillBuffer: retreival of values from k/v store failed: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(r.newMessagesCh, node(r.nodeName), er)
|
||||
}
|
||||
|
||||
|
@ -116,7 +115,6 @@ func (r *ringBuffer) fillBuffer(inCh chan subjectAndMessage, samValueBucket stri
|
|||
// Check if the command or event exists in commandOrEvent.go
|
||||
if !coeAvailable.CheckIfExists(v.CommandOrEvent, v.Subject) {
|
||||
er := fmt.Errorf("error: fillBuffer: the event or command type do not exist, so this message will not be put on the buffer to be processed. Check the syntax used in the json file for the message. Allowed values are : %v", coeAvailableValues)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(r.newMessagesCh, node(r.nodeName), er)
|
||||
|
||||
fmt.Println()
|
||||
|
@ -150,7 +148,6 @@ func (r *ringBuffer) fillBuffer(inCh chan subjectAndMessage, samValueBucket stri
|
|||
js, err := json.Marshal(samV)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error:fillBuffer gob encoding samValue: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(r.newMessagesCh, node(r.nodeName), er)
|
||||
}
|
||||
|
||||
|
@ -158,7 +155,6 @@ func (r *ringBuffer) fillBuffer(inCh chan subjectAndMessage, samValueBucket stri
|
|||
err = r.dbUpdate(r.db, samValueBucket, strconv.Itoa(dbID), js)
|
||||
if err != nil {
|
||||
er := fmt.Errorf("error: dbUpdate samValue failed: %v", err)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(r.newMessagesCh, node(r.nodeName), er)
|
||||
|
||||
}
|
||||
|
|
|
@ -151,7 +151,8 @@ func (s *server) printProcessesMap() {
|
|||
// sendErrorMessage will put the error message directly on the channel that is
|
||||
// read by the nats publishing functions.
|
||||
func sendErrorLogMessage(newMessagesCh chan<- []subjectAndMessage, FromNode node, theError error) {
|
||||
// --- Testing
|
||||
// NB: Adding log statement here for more visuality during development.
|
||||
log.Printf("%v\n", theError)
|
||||
sam := createErrorMsgContent(FromNode, theError)
|
||||
newMessagesCh <- []subjectAndMessage{sam}
|
||||
}
|
||||
|
@ -224,13 +225,11 @@ func (s *server) routeMessagesToProcess(dbFileName string, newSAM chan []subject
|
|||
// Check if the format of the message is correct.
|
||||
if _, ok := methodsAvailable.CheckIfExists(sam.Message.Method); !ok {
|
||||
er := fmt.Errorf("error: routeMessagesToProcess: the method do not exist, message dropped: %v", sam.Message.Method)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(s.nodeName), er)
|
||||
continue
|
||||
}
|
||||
if !coeAvailable.CheckIfExists(sam.Subject.CommandOrEvent, sam.Subject) {
|
||||
er := fmt.Errorf("error: routeMessagesToProcess: the command or event do not exist, message dropped: %v", sam.Message.Method)
|
||||
log.Printf("%v\n", er)
|
||||
sendErrorLogMessage(s.newMessagesCh, node(s.nodeName), er)
|
||||
|
||||
continue
|
||||
|
|
Loading…
Add table
Reference in a new issue