VOL-1247 : Modified change tuple to include previous and latest data

VOL-1214 : Fixed logs to use the proper mechanism

- Added missing license
- Moved one change tuple statement which would not include proper info

Change-Id: I5a02f6fe92c8b193642294d62f4413ac6edc0c62
diff --git a/db/model/child_type.go b/db/model/child_type.go
index de2fad7..d503b8d 100644
--- a/db/model/child_type.go
+++ b/db/model/child_type.go
@@ -16,10 +16,10 @@
 package model
 
 import (
-	"fmt"
 	desc "github.com/golang/protobuf/descriptor"
 	"github.com/golang/protobuf/proto"
 	"github.com/golang/protobuf/protoc-gen-go/descriptor"
+	"github.com/opencord/voltha-go/common/log"
 	"github.com/opencord/voltha-go/protos/common"
 	"reflect"
 	"strconv"
@@ -77,7 +77,7 @@
 					var keyFromStr func(string) interface{}
 
 					if meta.(*common.ChildNode).GetKey() == "" {
-						//fmt.Println("Child key is empty ... moving on")
+						//log.Debugf("Child key is empty ... moving on")
 					} else {
 						parentType := FindOwnerType(reflect.ValueOf(cls), field.GetName(), 0, false)
 						keyType := FindKeyOwner(reflect.New(parentType).Elem().Interface(), meta.(*common.ChildNode).GetKey(), 0)
@@ -108,7 +108,7 @@
 								return uint64(i)
 							}
 						default:
-							fmt.Errorf("Key type not implemented - type: %s\n", keyType.(reflect.Type))
+							log.Errorf("Key type not implemented - type: %s\n", keyType.(reflect.Type))
 						}
 
 						ct := ChildType{
diff --git a/db/model/child_type_test.go b/db/model/child_type_test.go
index 2f75eba..fcfe949 100644
--- a/db/model/child_type_test.go
+++ b/db/model/child_type_test.go
@@ -16,7 +16,6 @@
 package model
 
 import (
-	"fmt"
 	"github.com/opencord/voltha-go/protos/voltha"
 	"reflect"
 	"testing"
@@ -44,7 +43,7 @@
 
 	tst := reflect.ValueOf(cls).Elem().FieldByName("ImageDownloads")
 
-	fmt.Printf("############ Field by name : %+v\n", reflect.TypeOf(tst.Interface()))
+	t.Logf("############ Field by name : %+v\n", reflect.TypeOf(tst.Interface()))
 
 	if names == nil || len(names) == 0 {
 		t.Errorf("ChildrenFields failed to return names: %+v\n", names)
diff --git a/db/model/data_revision.go b/db/model/data_revision.go
index 7918c14..9bf840d 100644
--- a/db/model/data_revision.go
+++ b/db/model/data_revision.go
@@ -21,6 +21,7 @@
 	"encoding/json"
 	"fmt"
 	"github.com/golang/protobuf/proto"
+	"github.com/opencord/voltha-go/common/log"
 	"reflect"
 )
 
@@ -42,7 +43,7 @@
 
 	if IsProtoMessage(data) {
 		if pbdata, err := proto.Marshal(data.(proto.Message)); err != nil {
-			fmt.Errorf("problem to marshal protobuf data --> err: %s", err.Error())
+			log.Errorf("problem to marshal protobuf data --> err: %s", err.Error())
 		} else {
 			buffer.Write(pbdata)
 		}
@@ -50,7 +51,7 @@
 	} else if reflect.ValueOf(data).IsValid() {
 		dataObj := reflect.New(reflect.TypeOf(data).Elem())
 		if json, err := json.Marshal(dataObj.Interface()); err != nil {
-			fmt.Errorf("problem to marshal data --> err: %s", err.Error())
+			log.Errorf("problem to marshal data --> err: %s", err.Error())
 		} else {
 			buffer.Write(json)
 		}
diff --git a/db/model/event_bus.go b/db/model/event_bus.go
index 6afc63b..c4dfbdc 100644
--- a/db/model/event_bus.go
+++ b/db/model/event_bus.go
@@ -17,7 +17,7 @@
 
 import (
 	"encoding/json"
-	"fmt"
+	"github.com/opencord/voltha-go/common/log"
 	"github.com/opencord/voltha-go/protos/voltha"
 )
 
@@ -51,7 +51,7 @@
 	hash := args[2].(string)
 
 	if _, ok := IGNORED_CALLBACKS[eventType]; ok {
-		fmt.Printf("ignoring event - type:%s, data:%+v\n", eventType, data)
+		log.Debugf("ignoring event - type:%s, data:%+v\n", eventType, data)
 	}
 	var kind voltha.ConfigEventType_ConfigEventType
 	switch eventType {
@@ -67,7 +67,7 @@
 	var err error
 	if IsProtoMessage(data) {
 		if msg, err = json.Marshal(data); err != nil {
-			fmt.Errorf("problem marshalling data: %+v, err:%s\n", data, err.Error())
+			log.Errorf("problem marshalling data: %+v, err:%s\n", data, err.Error())
 		}
 	} else {
 		msg = data.([]byte)
diff --git a/db/model/event_bus_client.go b/db/model/event_bus_client.go
index 1ca1d78..227cb3c 100644
--- a/db/model/event_bus_client.go
+++ b/db/model/event_bus_client.go
@@ -16,7 +16,7 @@
 package model
 
 import (
-	"fmt"
+	"github.com/opencord/voltha-go/common/log"
 	"github.com/opencord/voltha-go/protos/voltha"
 )
 
@@ -28,5 +28,5 @@
 }
 
 func (ebc *EventBusClient) Publish(topic string, event voltha.ConfigEvent) {
-	fmt.Printf("publishing event:%+v, topic:%s\n", event, topic)
+	log.Debugf("publishing event:%+v, topic:%s\n", event, topic)
 }
diff --git a/db/model/merge.go b/db/model/merge.go
index e041e12..0546bd3 100644
--- a/db/model/merge.go
+++ b/db/model/merge.go
@@ -127,7 +127,7 @@
 					if field.IsContainer {
 						changes = append(
 							changes, ChangeTuple{POST_LISTCHANGE,
-								NewOperationContext("", nil, fieldName, "")},
+								NewOperationContext("", nil, fieldName, ""), nil},
 						)
 					}
 				}
@@ -149,13 +149,13 @@
 					// FIXME: newRev may come back as nil... exclude those entries for now
 					if newRev != nil {
 						newList[idx] = newRev
-						changes = append(changes, ChangeTuple{POST_ADD, newRev.GetData()})
+						changes = append(changes, ChangeTuple{POST_ADD, newList[idx].GetData(), newRev.GetData()})
 					}
 				}
 				for key, _ := range src.RemovedKeys {
 					oldRev := forkList[src.KeyMap1[key]]
 					revsToDiscard = append(revsToDiscard, oldRev)
-					changes = append(changes, ChangeTuple{POST_REMOVE, oldRev.GetData()})
+					changes = append(changes, ChangeTuple{POST_REMOVE, oldRev.GetData(), nil})
 				}
 				for key, _ := range src.ChangedKeys {
 					idx := src.KeyMap2[key]
@@ -188,7 +188,7 @@
 					} else {
 						newRev := mergeChildFunc(srcList[src.KeyMap2[key]])
 						newList = append(newList, newRev)
-						changes = append(changes, ChangeTuple{POST_ADD, newRev.GetData()})
+						changes = append(changes, ChangeTuple{POST_ADD, srcList[src.KeyMap2[key]], newRev.GetData()})
 					}
 				}
 				for key, _ := range src.ChangedKeys {
@@ -225,7 +225,7 @@
 						newList[len(newList)-1] = nil
 						newList = newList[:len(newList)-1]
 
-						changes = append(changes, ChangeTuple{POST_REMOVE, oldRev.GetData()})
+						changes = append(changes, ChangeTuple{POST_REMOVE, oldRev.GetData(), nil})
 					}
 				}
 
@@ -251,7 +251,7 @@
 		rev = rev.UpdateAllChildren(newChildren, dstRev.GetBranch())
 
 		if configChanged {
-			changes = append(changes, ChangeTuple{POST_UPDATE, rev.GetData()})
+			changes = append(changes, ChangeTuple{POST_UPDATE, dstRev.GetBranch().Latest.GetData(), rev.GetData()})
 		}
 		return rev, changes
 	} else {
diff --git a/db/model/model.go b/db/model/model.go
new file mode 100644
index 0000000..2b95280
--- /dev/null
+++ b/db/model/model.go
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package model
+
+import (
+	"github.com/opencord/voltha-go/common/log"
+)
+
+func init() {
+	log.AddPackage(log.JSON, log.WarnLevel, log.Fields{"instanceId": "DB_MODEL"})
+	defer log.CleanUp()
+}
diff --git a/db/model/node.go b/db/model/node.go
index 2ff199f..75f6915 100644
--- a/db/model/node.go
+++ b/db/model/node.go
@@ -61,8 +61,9 @@
 }
 
 type ChangeTuple struct {
-	Type CallbackType
-	Data interface{}
+	Type         CallbackType
+	PreviousData interface{}
+	LatestData   interface{}
 }
 
 func NewNode(root *root, initialData interface{}, autoPrune bool, txid string) *node {
@@ -83,7 +84,7 @@
 		n.Type = reflect.ValueOf(initialData).Interface()
 	} else {
 		// not implemented error
-		fmt.Errorf("cannot process initial data - %+v", initialData)
+		log.Errorf("cannot process initial data - %+v", initialData)
 	}
 
 	return n
@@ -112,14 +113,17 @@
 	if changeAnnouncement != nil && branch.Txid == "" {
 		if n.Proxy != nil {
 			for _, change := range changeAnnouncement {
-				fmt.Printf("invoking callback - changeType: %+v, data:%+v\n", change.Type, change.Data)
-				n.root.AddCallback(n.Proxy.InvokeCallbacks, change.Type, change.Data, true)
+				log.Debugf("invoking callback - changeType: %+v, previous:%+v, latest: %+v\n", change.Type,
+					change.PreviousData, change.LatestData)
+				n.root.AddCallback(n.Proxy.InvokeCallbacks, change.Type, change.PreviousData, change.LatestData, true)
 			}
 		}
 
 		for _, change := range changeAnnouncement {
-			fmt.Printf("sending notification - changeType: %+v, data:%+v\n", change.Type, change.Data)
-			n.root.AddNotificationCallback(n.makeEventBus().Advertise, change.Type, change.Data, revision.GetHash())
+			log.Debugf("sending notification - changeType: %+v, previous:%+v, latest: %+v\n", change.Type,
+				change.PreviousData,
+				change.LatestData)
+			n.root.AddNotificationCallback(n.makeEventBus().Advertise, change.Type, change.PreviousData, change.LatestData, revision.GetHash())
 		}
 	}
 }
@@ -161,7 +165,7 @@
 						_, key := GetAttributeValue(v.Interface(), field.Key, 0)
 						for _, k := range keysSeen {
 							if k == key.String() {
-								fmt.Errorf("duplicate key - %s", k)
+								log.Errorf("duplicate key - %s", k)
 							}
 						}
 						children[fieldName] = append(children[fieldName], rev)
@@ -178,7 +182,7 @@
 				children[fieldName] = append(children[fieldName], n.MakeNode(fieldValue.Interface(), txid).Latest())
 			}
 		} else {
-			fmt.Errorf("field is invalid - %+v", fieldValue)
+			log.Errorf("field is invalid - %+v", fieldValue)
 		}
 	}
 	// FIXME: ClearField???  No such method in go protos.  Reset?
@@ -209,7 +213,7 @@
 		}
 	}
 
-	fmt.Errorf("key %s=%s not found", keyName, value)
+	log.Errorf("key %s=%s not found", keyName, value)
 
 	return -1, nil
 }
@@ -355,7 +359,7 @@
 
 	if field.IsContainer {
 		if path == "" {
-			fmt.Errorf("cannot update a list\n")
+			log.Errorf("cannot update a list\n")
 		} else if field.Key != "" {
 			partition := strings.SplitN(path, "/", 2)
 			key := partition[0]
@@ -386,7 +390,7 @@
 			_newKeyType := fmt.Sprintf("%s", newKey)
 			_keyValueType := fmt.Sprintf("%s", keyValue)
 			if _newKeyType != _keyValueType {
-				fmt.Errorf("cannot change key field\n")
+				log.Errorf("cannot change key field\n")
 			}
 			children[idx] = newChildRev
 			rev = rev.UpdateChildren(name, children, branch)
@@ -394,7 +398,7 @@
 			n.root.MakeLatest(branch, rev, nil)
 			return rev
 		} else {
-			fmt.Errorf("cannot index into container with no keys\n")
+			log.Errorf("cannot index into container with no keys\n")
 		}
 	} else {
 		childRev := rev.GetChildren()[name][0]
@@ -413,7 +417,7 @@
 
 	if reflect.TypeOf(data) != reflect.ValueOf(n.Type).Type() {
 		// TODO raise error
-		fmt.Errorf("data does not match type: %+v", n.Type)
+		log.Errorf("data does not match type: %+v", n.Type)
 		return nil
 	}
 
@@ -429,11 +433,12 @@
 	if !reflect.DeepEqual(branch.Latest.GetData(), data) {
 		if strict {
 			// TODO: checkAccessViolations(data, Branch.GetLatest.data)
-			fmt.Println("checking access violations")
+			log.Debugf("checking access violations")
 		}
 		rev := branch.Latest.UpdateData(data, branch)
+		changes := []ChangeTuple{{POST_UPDATE, branch.Latest.GetData(), rev.GetData()}}
 		branch.Latest.Drop(branch.Txid, true)
-		n.root.MakeLatest(branch, rev, []ChangeTuple{{POST_UPDATE, rev.GetData()}})
+		n.root.MakeLatest(branch, rev, changes)
 		return rev
 	} else {
 		return branch.Latest
@@ -449,7 +454,7 @@
 	}
 	if path == "" {
 		// TODO raise error
-		fmt.Errorf("cannot add for non-container mode\n")
+		log.Errorf("cannot add for non-container mode\n")
 	}
 
 	var branch *Branch
@@ -489,17 +494,18 @@
 				_, key := GetAttributeValue(data, field.Key, 0)
 				if _, rev := n.findRevByKey(children, field.Key, key.String()); rev != nil {
 					// TODO raise error
-					fmt.Errorf("duplicate key found: %s", key.String())
+					log.Errorf("duplicate key found: %s", key.String())
 				}
 
 				childRev := n.MakeNode(data, txid).Latest(txid)
 				children = append(children, childRev)
 				rev := rev.UpdateChildren(name, children, branch)
+				changes := []ChangeTuple{{POST_ADD, branch.Latest.GetData(), rev.GetData()}}
 				branch.Latest.Drop(txid, false)
-				n.root.MakeLatest(branch, rev, []ChangeTuple{{POST_ADD, rev.GetData()}})
+				n.root.MakeLatest(branch, rev, changes)
 				return rev
 			} else {
-				fmt.Errorf("cannot add to non-keyed container\n")
+				log.Errorf("cannot add to non-keyed container\n")
 			}
 		} else if field.Key != "" {
 			partition := strings.SplitN(path, "/", 2)
@@ -520,10 +526,10 @@
 			n.root.MakeLatest(branch, rev, nil)
 			return rev
 		} else {
-			fmt.Errorf("cannot add to non-keyed container\n")
+			log.Errorf("cannot add to non-keyed container\n")
 		}
 	} else {
-		fmt.Errorf("cannot add to non-container field\n")
+		log.Errorf("cannot add to non-container field\n")
 	}
 	return nil
 }
@@ -537,7 +543,7 @@
 	}
 	if path == "" {
 		// TODO raise error
-		fmt.Errorf("cannot remove for non-container mode\n")
+		log.Errorf("cannot remove for non-container mode\n")
 	}
 	var branch *Branch
 	var ok bool
@@ -563,7 +569,7 @@
 
 	if field.IsContainer {
 		if path == "" {
-			fmt.Errorf("cannot remove without a key\n")
+			log.Errorf("cannot remove without a key\n")
 		} else if field.Key != "" {
 			partition := strings.SplitN(path, "/", 2)
 			key := partition[0]
@@ -595,9 +601,9 @@
 				if n.Proxy != nil {
 					data := childRev.GetData()
 					n.Proxy.InvokeCallbacks(PRE_REMOVE, data, false)
-					postAnnouncement = append(postAnnouncement, ChangeTuple{POST_REMOVE, data})
+					postAnnouncement = append(postAnnouncement, ChangeTuple{POST_REMOVE, data, nil})
 				} else {
-					postAnnouncement = append(postAnnouncement, ChangeTuple{POST_REMOVE, childRev.GetData()})
+					postAnnouncement = append(postAnnouncement, ChangeTuple{POST_REMOVE, childRev.GetData(), nil})
 				}
 				childRev.Drop(txid, true)
 				children = append(children[:idx], children[idx+1:]...)
@@ -607,10 +613,10 @@
 				return rev
 			}
 		} else {
-			fmt.Errorf("cannot add to non-keyed container\n")
+			log.Errorf("cannot add to non-keyed container\n")
 		}
 	} else {
-		fmt.Errorf("cannot add to non-container field\n")
+		log.Errorf("cannot add to non-container field\n")
 	}
 
 	return nil
diff --git a/db/model/persisted_revision.go b/db/model/persisted_revision.go
index 05c4090..774b77e 100644
--- a/db/model/persisted_revision.go
+++ b/db/model/persisted_revision.go
@@ -19,7 +19,6 @@
 	"bytes"
 	"compress/gzip"
 	"encoding/json"
-	"fmt"
 	"github.com/golang/protobuf/proto"
 	"github.com/opencord/voltha-go/common/log"
 	"io/ioutil"
@@ -104,7 +103,7 @@
 		}
 	}
 	if err := json.Unmarshal(output, &data); err != nil {
-		fmt.Errorf("problem to unmarshal data - %s", err.Error())
+		log.Errorf("problem to unmarshal data - %s", err.Error())
 	}
 
 	stop := time.Now()
diff --git a/db/model/proxy.go b/db/model/proxy.go
index 1939596..0f5ddc7 100644
--- a/db/model/proxy.go
+++ b/db/model/proxy.go
@@ -73,7 +73,7 @@
 
 func (p *Proxy) Update(path string, data interface{}, strict bool, txid string) interface{} {
 	if !strings.HasPrefix(path, "/") {
-		fmt.Errorf("invalid path: %s", path)
+		log.Errorf("invalid path: %s", path)
 		return nil
 	}
 	var fullPath string
@@ -87,7 +87,7 @@
 
 func (p *Proxy) Add(path string, data interface{}, txid string) interface{} {
 	if !strings.HasPrefix(path, "/") {
-		fmt.Errorf("invalid path: %s", path)
+		log.Errorf("invalid path: %s", path)
 		return nil
 	}
 	var fullPath string
@@ -101,7 +101,7 @@
 
 func (p *Proxy) Remove(path string, txid string) interface{} {
 	if !strings.HasPrefix(path, "/") {
-		fmt.Errorf("invalid path: %s", path)
+		log.Errorf("invalid path: %s", path)
 		return nil
 	}
 	var fullPath string
diff --git a/db/model/proxy_test.go b/db/model/proxy_test.go
index a96aa28..45329fd 100644
--- a/db/model/proxy_test.go
+++ b/db/model/proxy_test.go
@@ -18,7 +18,6 @@
 import (
 	"encoding/hex"
 	"encoding/json"
-	"fmt"
 	"github.com/google/uuid"
 	"github.com/opencord/voltha-go/common/log"
 	"github.com/opencord/voltha-go/protos/common"
@@ -150,7 +149,6 @@
 	//updated := devProxy.Get("/ports", 0, false, "")
 	//t.Logf("got updated ports: %+v", updated)
 
-
 	//
 	// Get a device proxy, retrieve all the ports and update a specific one
 	//
@@ -231,17 +229,17 @@
 func firstCallback(args ...interface{}) interface{} {
 	name := args[0]
 	id := args[1]
-	fmt.Printf("Running first callback - name: %s, id: %s\n", name, id)
+	log.Infof("Running first callback - name: %s, id: %s\n", name, id)
 	return nil
 }
 func deviceCallback(args ...interface{}) interface{} {
-	fmt.Printf("Running device callback\n")
+	log.Infof("Running device callback\n")
 	return nil
 }
 func secondCallback(args ...interface{}) interface{} {
 	name := args[0].(map[string]string)
 	id := args[1]
-	fmt.Printf("Running second callback - name: %s, id: %f\n", name["name"], id)
+	log.Infof("Running second callback - name: %s, id: %f\n", name["name"], id)
 	// FIXME: the panic call seem to interfere with the logging mechanism
 	//panic("Generating a panic in second callback")
 	return nil
@@ -249,7 +247,7 @@
 func thirdCallback(args ...interface{}) interface{} {
 	name := args[0]
 	id := args[1].(*voltha.Device)
-	fmt.Printf("Running third callback - name: %+v, id: %s\n", name, id.Id)
+	log.Infof("Running third callback - name: %+v, id: %s\n", name, id.Id)
 	return nil
 }
 
diff --git a/db/model/root.go b/db/model/root.go
index a6c62c6..27e4ec4 100644
--- a/db/model/root.go
+++ b/db/model/root.go
@@ -18,7 +18,6 @@
 import (
 	"encoding/hex"
 	"encoding/json"
-	"fmt"
 	"github.com/google/uuid"
 	"github.com/opencord/voltha-go/common/log"
 	"reflect"
@@ -115,7 +114,6 @@
 	r.NotificationCallbacks = append(r.NotificationCallbacks, CallbackTuple{callback, args})
 }
 
-
 func (r *root) Update(path string, data interface{}, strict bool, txid string, makeBranch MakeBranchFunction) Revision {
 	var result Revision
 
@@ -246,7 +244,7 @@
 
 	start := time.Now()
 	if err := json.Unmarshal(blob.Value.([]byte), &data); err != nil {
-		fmt.Errorf("problem to unmarshal blob - error:%s\n", err.Error())
+		log.Errorf("problem to unmarshal blob - error:%s\n", err.Error())
 	}
 	stop := time.Now()
 	GetProfiling().AddToInMemoryModelTime(stop.Sub(start).Seconds())
diff --git a/db/model/root_test.go b/db/model/root_test.go
index 68d7f2a..670e7e8 100644
--- a/db/model/root_test.go
+++ b/db/model/root_test.go
@@ -17,7 +17,7 @@
 
 import (
 	"encoding/json"
-	"fmt"
+	"github.com/opencord/voltha-go/common/log"
 	"github.com/opencord/voltha-go/protos/voltha"
 	"testing"
 	"time"
@@ -44,16 +44,16 @@
 
 	r := root.Load(msgClass)
 	afterLoad := time.Now()
-	fmt.Printf(">>>>>>>>>>>>> Time to Load : %f\n", afterLoad.Sub(start).Seconds())
+	log.Infof(">>>>>>>>>>>>> Time to Load : %f\n", afterLoad.Sub(start).Seconds())
 
 	d := r.node.Get(deviceProxy, "", 0, false, "")
 	afterGet := time.Now()
-	fmt.Printf(">>>>>>>>>>>>> Time to Load and get: %f\n", afterGet.Sub(start).Seconds())
+	log.Infof(">>>>>>>>>>>>> Time to Load and get: %f\n", afterGet.Sub(start).Seconds())
 
 	jr, _ := json.Marshal(r)
-	fmt.Printf("Content of ROOT --> \n%s\n", jr)
+	log.Infof("Content of ROOT --> \n%s\n", jr)
 
 	jd, _ := json.Marshal(d)
-	fmt.Printf("Content of GET --> \n%s\n", jd)
+	log.Infof("Content of GET --> \n%s\n", jd)
 
 }
diff --git a/db/model/transaction.go b/db/model/transaction.go
index 0ee3643..fa8de1d 100644
--- a/db/model/transaction.go
+++ b/db/model/transaction.go
@@ -15,7 +15,9 @@
  */
 package model
 
-import "fmt"
+import (
+	"github.com/opencord/voltha-go/common/log"
+)
 
 type Transaction struct {
 	proxy *Proxy
@@ -31,7 +33,7 @@
 }
 func (t *Transaction) Get(path string, depth int, deep bool) interface{} {
 	if t.txid == "" {
-		fmt.Errorf("closed transaction")
+		log.Errorf("closed transaction")
 		return nil
 	}
 	// TODO: need to review the return values at the different layers!!!!!
@@ -39,21 +41,21 @@
 }
 func (t *Transaction) Update(path string, data interface{}, strict bool) interface{} {
 	if t.txid == "" {
-		fmt.Errorf("closed transaction")
+		log.Errorf("closed transaction")
 		return nil
 	}
 	return t.proxy.Update(path, data, strict, t.txid)
 }
 func (t *Transaction) Add(path string, data interface{}) interface{} {
 	if t.txid == "" {
-		fmt.Errorf("closed transaction")
+		log.Errorf("closed transaction")
 		return nil
 	}
 	return t.proxy.Add(path, data, t.txid)
 }
 func (t *Transaction) Remove(path string) interface{} {
 	if t.txid == "" {
-		fmt.Errorf("closed transaction")
+		log.Errorf("closed transaction")
 		return nil
 	}
 	return t.proxy.Remove(path, t.txid)
diff --git a/db/model/transaction_test.go b/db/model/transaction_test.go
index 45e6c2d..a490acd 100644
--- a/db/model/transaction_test.go
+++ b/db/model/transaction_test.go
@@ -181,7 +181,6 @@
 	getDevTx.Commit()
 }
 
-
 func Test_Transaction_6_RemoveDevice(t *testing.T) {
 	removeTx := tx.Proxy.OpenTransaction()
 	if removed := removeTx.Remove("/devices/" + txDevId); removed == nil {
diff --git a/db/model/utils.go b/db/model/utils.go
index 65c1c4a..1966c5c 100644
--- a/db/model/utils.go
+++ b/db/model/utils.go
@@ -78,7 +78,7 @@
 			}
 		}
 	default:
-		//fmt.Printf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
+		//log.Debugf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
 	}
 
 	return nil
@@ -120,7 +120,7 @@
 			}
 		}
 	default:
-		//fmt.Printf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
+		//log.Debugf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
 	}
 
 	return nil
@@ -175,7 +175,7 @@
 			}
 		}
 	default:
-		//fmt.Printf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
+		//log.Debugf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
 	}
 
 	return attribName, attribValue
@@ -229,7 +229,7 @@
 
 		}
 	default:
-		//fmt.Printf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
+		//log.Debugf("%s Unhandled <%+v> ... It's a %+v\n", prefix, obj, k)
 	}
 
 	return result