summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-03-15 22:47:37 +0800
committerYun Huang <yun.huang@windriver.com>2018-03-15 22:47:37 +0800
commit6c7295e3de3fe80e8a5adf31b64be186e27ce5ad (patch)
tree1b4e22bee81c70ed09b5061049b8ad8576e68c78
parent70b3774c3855f256ad9976743f433d88eacab655 (diff)
Enable AOP for newton logging
Change-Id: I232b60b48fb678821502f1ee3b14022bab078aba Issue-ID: MULTICLOUD-177 Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r--newton/assembly.xml1
-rw-r--r--newton/newton/pub/__init__.py14
-rw-r--r--newton/newton/pub/config/__init__.py14
-rw-r--r--newton/newton/pub/config/config.py13
-rw-r--r--newton/newton/pub/config/log.yml34
-rw-r--r--newton/newton/settings.py40
-rw-r--r--newton/requirements.txt4
-rw-r--r--newton/tox.ini2
8 files changed, 90 insertions, 32 deletions
diff --git a/newton/assembly.xml b/newton/assembly.xml
index 55d172a1..d0dbea27 100644
--- a/newton/assembly.xml
+++ b/newton/assembly.xml
@@ -31,6 +31,7 @@
<include>**/*.wsdl</include>
<include>**/*.xsd</include>
<include>**/*.bpel</include>
+ <include>**/*.yml</include>
</includes>
</fileSet>
<fileSet>
diff --git a/newton/newton/pub/__init__.py b/newton/newton/pub/__init__.py
new file mode 100644
index 00000000..afa702d3
--- /dev/null
+++ b/newton/newton/pub/__init__.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2017-2018 Wind River Systems, Inc.
+#
+# 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.
+
diff --git a/newton/newton/pub/config/__init__.py b/newton/newton/pub/config/__init__.py
new file mode 100644
index 00000000..afa702d3
--- /dev/null
+++ b/newton/newton/pub/config/__init__.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2017-2018 Wind River Systems, Inc.
+#
+# 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.
+
diff --git a/newton/newton/pub/config/config.py b/newton/newton/pub/config/config.py
new file mode 100644
index 00000000..ae1ce9db
--- /dev/null
+++ b/newton/newton/pub/config/config.py
@@ -0,0 +1,13 @@
+# Copyright (c) 2017-2018 Wind River Systems, Inc.
+#
+# 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.
diff --git a/newton/newton/pub/config/log.yml b/newton/newton/pub/config/log.yml
new file mode 100644
index 00000000..452d3b61
--- /dev/null
+++ b/newton/newton/pub/config/log.yml
@@ -0,0 +1,34 @@
+version: 1
+disable_existing_loggers: False
+
+loggers:
+ newton:
+ handlers: [newton_handler]
+ level: "DEBUG"
+ propagate: False
+ newton_base:
+ handlers': [newton_handler]
+ level: "DEBUG"
+ propagate: False
+ common:
+ handlers: [newton_handler]
+ level: "DEBUG"
+ propagate: False
+handlers:
+ newton_handler:
+ level: "DEBUG"
+ class: "logging.handlers.RotatingFileHandler"
+ filename: "/var/log/onap/multicloud/openstack/newton/newton.log"
+ formatter: "mdcFormat"
+ maxBytes: 1024*1024*50
+ backupCount: 10
+formatters:
+ standard:
+ format: "%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s"
+ mdcFormat:
+ format: "%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:[%(mdc)s]: %(message)s"
+ mdcfmt: "{requestID}"
+ datefmt: "%Y-%m-%d %H:%M:%S"
+ (): onaplogging.mdcformatter.MDCFormatter
+
+
diff --git a/newton/newton/settings.py b/newton/newton/settings.py
index aafcfbbc..a5585a68 100644
--- a/newton/newton/settings.py
+++ b/newton/newton/settings.py
@@ -15,6 +15,10 @@
import os
import sys
+from logging import config
+from onaplogging import monkey
+monkey.patch_all()
+
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
@@ -84,36 +88,6 @@ TIME_ZONE = 'UTC'
STATIC_URL = '/static/'
-LOGGING = {
- 'version': 1,
- 'disable_existing_loggers': True,
- 'formatters': {
- 'standard': {
- 'format': '%(asctime)s:[%(name)s]:[%(filename)s]-[%(lineno)d] [%(levelname)s]:%(message)s',
- },
- },
- 'filters': {
- },
- 'handlers': {
- 'newton_handler': {
- 'level': 'DEBUG',
- 'class': 'logging.handlers.RotatingFileHandler',
- 'filename': '/var/log/onap/multicloud/openstack/newton/newton.log',
- 'formatter': 'standard',
- 'maxBytes': 1024 * 1024 * 50,
- 'backupCount': 5,
- },
- },
-
- 'loggers': {
- 'newton': {
- 'handlers': ['newton_handler'],
- 'level': 'DEBUG',
- 'propagate': False
- },
- }
-}
-
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
@@ -147,9 +121,13 @@ ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fi
OPENSTACK_VERSION = "newton"
MULTIVIM_VERSION = "multicloud-" + OPENSTACK_VERSION
+LOGGING_CONFIG = None
+# yaml configuration of logging
+LOGGING_FILE = os.path.join(BASE_DIR, 'newton/pub/config/log.yml')
+config.yamlConfig(filepath=LOGGING_FILE, watchDog=True)
if 'test' in sys.argv:
- LOGGING['handlers']['newton_handler']['filename'] = 'logs/newton.log'
+ #LOGGING['handlers']['newton_handler']['filename'] = 'logs/newton.log'
REST_FRAMEWORK = {}
import platform
diff --git a/newton/requirements.txt b/newton/requirements.txt
index cb42f78c..df84bef5 100644
--- a/newton/requirements.txt
+++ b/newton/requirements.txt
@@ -17,3 +17,7 @@ python-memcached
coverage==4.2
mock==2.0.0
unittest_xml_reporting==1.12.0
+
+# for onap logging
+onappylog>=1.0.5
+
diff --git a/newton/tox.ini b/newton/tox.ini
index 4be77268..e3334cf1 100644
--- a/newton/tox.ini
+++ b/newton/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,py35,cov
+envlist = py27,cov
skipsdist = true
[tox:jenkins]