logging to stderr in addition to LOGFILE 25/6425/4
authortierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 20 Aug 2018 11:57:04 +0000 (11:57 +0000)
committertierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 27 Aug 2018 09:08:18 +0000 (09:08 +0000)
Change-Id: Ia1d0a0fd7e1e1c4b6d3e34a0fae13605ab8173ae

osm_lcm/__init__.py
osm_lcm/lcm.cfg
osm_lcm/lcm.py
setup.py

index e3ef989..3a63f8e 100644 (file)
@@ -1,2 +1,3 @@
-version = '0.1.11'
-version_date = '2018-07-23'
+# version moved to lcm.py. uncomment if LCM is installed as library and installed
+# version = '0.1.12'
+# version_date = '2018-08-23'
index c62ee25..c479773 100644 (file)
@@ -4,7 +4,8 @@
 #[global]
 global:
     loglevel: DEBUG
-    #logfile:  /var/log/osm/lcm.log
+    logfile:  /var/log/osm/lcm.log
+    # nologging: True     # do no log to stdout/stderr
 
 #[RO]
 RO:
@@ -12,7 +13,7 @@ RO:
     port:   9090
     tenant: osm
     loglevel: DEBUG
-    #logfile:  /var/log/osm/lcm-ro.log
+    # logfile:  /var/log/osm/lcm-ro.log
 
 #[VCA]
 VCA:
@@ -21,7 +22,7 @@ VCA:
     user:   admin
     secret:   secret
     loglevel: DEBUG
-    #logfile:  /var/log/osm/lcm-vca.log
+    # logfile:  /var/log/osm/lcm-vca.log
 
 #[database]
 database:
@@ -32,7 +33,7 @@ database:
     user:   user
     password:   password
     loglevel: DEBUG
-    #logfile:  /var/log/osm/lcm-database.log
+    # logfile:  /var/log/osm/lcm-database.log
 
 #[storage]
 storage:
@@ -40,7 +41,7 @@ storage:
     # for local provide file path
     path:   /app/storage
     loglevel: DEBUG
-    #logfile:  /var/log/osm/lcm-storage.log
+    # logfile:  /var/log/osm/lcm-storage.log
 
 #[message]
 message:
@@ -51,4 +52,4 @@ message:
     host:   kafka
     port:   9092
     loglevel: DEBUG
-    #logfile:  /var/log/osm/lcm-message.log
+    # logfile:  /var/log/osm/lcm-message.log
index 3266914..310c434 100644 (file)
@@ -31,6 +31,9 @@ from time import time
 
 __author__ = "Alfonso Tierno"
 min_RO_version = [0, 5, 72]
+# uncomment if LCM is installed as library and installed, and get them from __init__.py
+lcm_version = '0.1.12'
+lcm_version_date = '2018-08-23'
 
 
 class LcmException(Exception):
@@ -166,12 +169,12 @@ class Lcm:
         config["database"]["logger_name"] = "lcm.db"
         config["storage"]["logger_name"] = "lcm.fs"
         config["message"]["logger_name"] = "lcm.msg"
-        if "logfile" in config["global"]:
+        if config["global"].get("logfile"):
             file_handler = logging.handlers.RotatingFileHandler(config["global"]["logfile"],
                                                                 maxBytes=100e6, backupCount=9, delay=0)
             file_handler.setFormatter(log_formatter_simple)
             self.logger.addHandler(file_handler)
-        else:
+        if not config["global"].get("nologging"):
             str_handler = logging.StreamHandler()
             str_handler.setFormatter(log_formatter_simple)
             self.logger.addHandler(str_handler)
@@ -183,14 +186,14 @@ class Lcm:
         for k1, logname in {"message": "lcm.msg", "database": "lcm.db", "storage": "lcm.fs"}.items():
             config[k1]["logger_name"] = logname
             logger_module = logging.getLogger(logname)
-            if "logfile" in config[k1]:
+            if config[k1].get("logfile"):
                 file_handler = logging.handlers.RotatingFileHandler(config[k1]["logfile"],
                                                                     maxBytes=100e6, backupCount=9, delay=0)
                 file_handler.setFormatter(log_formatter_simple)
                 logger_module.addHandler(file_handler)
-            if "loglevel" in config[k1]:
+            if config[k1].get("loglevel"):
                 logger_module.setLevel(config[k1]["loglevel"])
-        self.logger.critical("starting osm/lcm version {} {}".format(lcm_version, lcm_version_date))
+        self.logger.critical("starting osm/lcm version {} {}".format(lcm_version, lcm_version_date))
         self.n2vc = N2VC(
             log=self.logger,
             server=config['VCA']['host'],
index 45de1f8..47ca680 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -33,7 +33,7 @@ setup(
         "git+https://osm.etsi.org/gerrit/osm/common.git@master#egg=osm-common-0.1.4"
     ],
     install_requires=[
-        'pymongo', 'PyYAML',
+        'pymongo', 'PyYAML', 'aiohttp'
         # 'osm-common',
     ],
     setup_requires=['setuptools-version-command'],