2014-04-26 09:18:56 +00:00
|
|
|
package DeviceDatabase
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Function to write a logging event to the database.
|
2014-04-26 09:18:56 +00:00
|
|
|
func write2Database(entry LogDBEntry) {
|
2015-06-17 15:44:52 +00:00
|
|
|
// Try to write the event to the database:
|
2014-04-26 09:18:56 +00:00
|
|
|
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())
|
2014-04-26 09:18:56 +00:00
|
|
|
}
|
|
|
|
}
|