openolt_grpc logging
Change-Id: Iae26be472663d0ea26a91d336ae479740083aa58
diff --git a/voltha/adapters/openolt/grpc/logconfig.yml b/voltha/adapters/openolt/grpc/logconfig.yml
new file mode 100644
index 0000000..8ff722b
--- /dev/null
+++ b/voltha/adapters/openolt/grpc/logconfig.yml
@@ -0,0 +1,51 @@
+---
+# Copyright 2017-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.
+
+version: 1
+
+formatters:
+ brief:
+ format: '%(message)s'
+ default:
+ format: '%(asctime)s.%(msecs)03d %(levelname)-8s %(threadName)s %(module)s.%(funcName)s %(message)s'
+ datefmt: '%Y%m%dT%H%M%S'
+
+handlers:
+ console:
+ class : logging.StreamHandler
+ level: DEBUG
+ formatter: default
+ stream: ext://sys.stdout
+ localRotatingFile:
+ class: logging.handlers.RotatingFileHandler
+ filename: openolt_grpc.log
+ formatter: default
+ maxBytes: 2097152
+ backupCount: 10
+ level: DEBUG
+ null:
+ class: logging.NullHandler
+
+loggers:
+ amqp:
+ handlers: [null]
+ propagate: False
+ conf:
+ propagate: False
+ '': # root logger
+ handlers: [console, localRotatingFile]
+ level: INFO # this can be bumped up/down by -q and -v command line
+ # options
+ propagate: False
diff --git a/voltha/adapters/openolt/grpc/openolt_grpc.py b/voltha/adapters/openolt/grpc/openolt_grpc.py
index 7a4acf4..923ab90 100644
--- a/voltha/adapters/openolt/grpc/openolt_grpc.py
+++ b/voltha/adapters/openolt/grpc/openolt_grpc.py
@@ -15,17 +15,17 @@
#
import sys
-import structlog
+import time
+import yaml
import grpc
import threading
+from common.structlog_setup import setup_logging
from voltha.registry import registry
from voltha.adapters.openolt.protos import openolt_pb2_grpc, openolt_pb2
from voltha.adapters.openolt.openolt_kafka_proxy import OpenoltKafkaProxy, \
kafka_send_pb
-log = structlog.get_logger()
-
class OpenoltGrpc(object):
def __init__(self, host_and_port, device):
@@ -69,7 +69,7 @@
kafka_send_pb(topic, ind)
break
else:
- # log.debug("openolt grpc rx indication", indication=ind)
+ log.info("openolt grpc rx indication", indication=ind)
kafka_send_pb(topic, ind)
@@ -81,9 +81,16 @@
broker = sys.argv[1]
host = sys.argv[2]
+ log = setup_logging(yaml.load(open('./logconfig.yml', 'r')),
+ host,
+ verbosity_adjust=0,
+ cache_on_use=True)
+
kafka_proxy = registry.register(
'openolt_kafka_proxy',
OpenoltKafkaProxy(broker)
).start()
- process_indications(host)
+ while True:
+ process_indications(host)
+ time.sleep(5)