aboutsummaryrefslogtreecommitdiffstats
path: root/miss_htbt_service/htbtworker.py
diff options
context:
space:
mode:
authorSatoshi Fujii <fujii-satoshi@jp.fujitsu.com>2021-10-22 12:30:45 +0000
committerSatoshi Fujii <fujii-satoshi@jp.fujitsu.com>2021-10-22 12:58:05 +0000
commit8d7c0201456b7f9af6e91fea90354f4c3de323fe (patch)
tree522632565397508044ba2de89313616f3aa495a6 /miss_htbt_service/htbtworker.py
parentc48b9767a6bcad91f89fc3fded0b6024e89525c0 (diff)
Fix log rotation issue
Writing log to a single file from multiple processes is not supported by python logging. It causes making fragmented log files at log rotation and logs are mixed up. This change is to use different log files for each sub-process to help developers check log for a specific process easily. This change does not affect to pod log (stdout log). Signed-off-by: Satoshi Fujii <fujii-satoshi@jp.fujitsu.com> Issue-ID: DCAEGEN2-2941 Change-Id: If8bcb2308863d1395a2c547d2e7b746301665fb0
Diffstat (limited to 'miss_htbt_service/htbtworker.py')
-rw-r--r--miss_htbt_service/htbtworker.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/miss_htbt_service/htbtworker.py b/miss_htbt_service/htbtworker.py
index 6fbda2d..be1b6aa 100644
--- a/miss_htbt_service/htbtworker.py
+++ b/miss_htbt_service/htbtworker.py
@@ -22,6 +22,7 @@
# Simple Microservice
# Tracks Heartbeat messages on input topic in DMaaP
# and poppulate the information in postgres DB
+import logging
import psycopg2
import requests
@@ -33,7 +34,7 @@ import time
import misshtbtd as db
import get_logger
-_logger = get_logger.get_logger(__name__)
+_logger = logging.getLogger(__name__)
def read_json_file(i, prefix="../../tests"):
@@ -160,8 +161,7 @@ def process_msg(jsfile, user_name, password, ip_address, port_num, db_name):
source_name_key = source_name_count + 1
cl_flag = 0
if source_name_count == 0: # pragma: no cover
- msg = "HBT: Insert entry in table_2,source_name_count=0 : ", row
- _logger.info(msg)
+ _logger.info("HBT: Insert entry into vnf_table_2, source_name='%s'", srcname)
cur.execute("INSERT INTO vnf_table_2 VALUES(%s,%s,%s,%s,%s)",
(eventName, source_name_key, lastepo, srcname, cl_flag))
cur.execute("UPDATE vnf_table_1 SET SOURCE_NAME_COUNT = %s where EVENT_NAME = %s",
@@ -190,8 +190,7 @@ def process_msg(jsfile, user_name, password, ip_address, port_num, db_name):
_logger.info(msg)
if source_name_count == (source_name_key + 1):
source_name_key = source_name_count + 1
- msg = "HBT: Insert entry in table_2 : ", row
- _logger.info(msg)
+ _logger.info("HBT: Insert entry into vnf_table_2, source_name='%s'", srcname)
cur.execute("INSERT INTO vnf_table_2 VALUES(%s,%s,%s,%s,%s)",
(eventName, source_name_key, lastepo, srcname, cl_flag))
cur.execute("UPDATE vnf_table_1 SET SOURCE_NAME_COUNT = %s WHERE EVENT_NAME = %s",
@@ -256,6 +255,7 @@ def commit_and_close_db(connection_db):
if __name__ == '__main__':
+ get_logger.configure_logger('htbtworker')
jsfile = sys.argv[1]
msg = "HBT:HeartBeat thread Created"
_logger.info("HBT:HeartBeat thread Created")