Fixing logging
Change-Id: I3bd5168110985fd06faa6a4bc2fe3d713a208337
diff --git a/src/grpc_client/main.py b/src/grpc_client/main.py
index fc64ef3..bf866bf 100644
--- a/src/grpc_client/main.py
+++ b/src/grpc_client/main.py
@@ -21,6 +21,10 @@
from xosconfig import Config
from twisted.internet import reactor
+from xosconfig import Config
+from multistructlog import create_logger
+log = create_logger(Config().get('logging'))
+
class GRPC_Client:
def __init__(self):
self.client = None
@@ -32,7 +36,7 @@
self.grpc_insecure_endpoint = insecure + ":50055"
def setup_resources(self, client, key, deferred, recipe):
- print "[XOS-TOSCA] Loading resources"
+ log.info("[XOS-TOSCA] Loading resources for authenticated user")
if key not in RESOURCES:
RESOURCES[key] = {}
for k in client.xos_orm.all_model_names:
@@ -40,7 +44,7 @@
reactor.callLater(0, deferred.callback, recipe)
def start(self):
- print "[XOS-TOSCA] Connecting to xos-core"
+ log.info("[XOS-TOSCA] Connecting to xos-core")
deferred = defer.Deferred()
diff --git a/src/grpc_client/models_accessor.py b/src/grpc_client/models_accessor.py
index 5d54644..2c96c48 100644
--- a/src/grpc_client/models_accessor.py
+++ b/src/grpc_client/models_accessor.py
@@ -13,6 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from xosconfig import Config
+from multistructlog import create_logger
+log = create_logger(Config().get('logging'))
from resources import RESOURCES
@@ -69,15 +72,15 @@
models = cls.objects.filter(**filter)
if len(models) == 1:
- print "[XOS-Tosca] Model of class %s and properties %s already exist, retrieving instance..." % (class_name, str(filter))
model = models[0]
+ log.info("[XOS-Tosca] Model of class %s and properties %s already exist, retrieving instance..." % (class_name, str(filter)), model=model)
elif len(models) == 0:
if 'must-exist' in data and data['must-exist']:
raise Exception("[XOS-TOSCA] Model of class %s and properties %s has property 'must-exist' but cannot be found" % (class_name, str(filter)))
model = cls.objects.new()
- print "[XOS-Tosca] Model (%s) is new, creating new instance..." % str(filter)
+ log.info("[XOS-Tosca] Model (%s) is new, creating new instance..." % str(filter))
else:
raise Exception("[XOS-Tosca] Model of class %s and properties %s has multiple instances, I can't handle it" % (class_name, str(filter)))