Ocean/Log/DeviceDatabase/Write2Database.go

16 lines
480 B
Go
Raw Permalink Normal View History

package DeviceDatabase
2015-06-17 15:44:52 +00:00
import (
"fmt"
)
// Function to write a logging event to the database.
func write2Database(entry LogDBEntry) {
2015-06-17 15:44:52 +00:00
// Try to write the event to the database:
if err := logDBCollection.Insert(entry); err != nil {
2015-06-17 15:44:52 +00:00
// Case: Error!
// Cannot log here to prevent endless loop (consumer is also producer)
fmt.Printf("Was not able to write a logging event to the database: '%s'. The log entry was: '%s'.\n", err.Error(), entry.Format())
}
}