diff options
author | Yun Huang <yun.huang@windriver.com> | 2018-03-15 22:15:37 +0800 |
---|---|---|
committer | Yun Huang <yun.huang@windriver.com> | 2018-03-15 22:15:37 +0800 |
commit | 70b3774c3855f256ad9976743f433d88eacab655 (patch) | |
tree | 047988dad7cc56088accd2e6e96c2732d93eaacf | |
parent | cabc350593488b32980bd3310754018e99a48945 (diff) |
Enable AOP for ocata logging
Change-Id: I8a616e99d4fba368b7bedb9fc4c40ba4ceb10445
Issue-ID: MULTICLOUD-177
Signed-off-by: Yun Huang <yun.huang@windriver.com>
-rw-r--r-- | ocata/assembly.xml | 1 | ||||
-rw-r--r-- | ocata/ocata/pub/__init__.py | 14 | ||||
-rw-r--r-- | ocata/ocata/pub/config/__init__.py | 14 | ||||
-rw-r--r-- | ocata/ocata/pub/config/config.py | 13 | ||||
-rw-r--r-- | ocata/ocata/pub/config/log.yml | 34 | ||||
-rw-r--r-- | ocata/ocata/settings.py | 51 | ||||
-rw-r--r-- | ocata/pom.xml | 8 | ||||
-rw-r--r-- | ocata/requirements.txt | 3 | ||||
-rw-r--r-- | ocata/tox.ini | 2 |
9 files changed, 90 insertions, 50 deletions
diff --git a/ocata/assembly.xml b/ocata/assembly.xml index e934f9f6..1c69acd6 100644 --- a/ocata/assembly.xml +++ b/ocata/assembly.xml @@ -31,6 +31,7 @@ <include>**/*.wsdl</include> <include>**/*.xsd</include> <include>**/*.bpel</include> + <include>**/*.yml</include> </includes> </fileSet> <fileSet> diff --git a/ocata/ocata/pub/__init__.py b/ocata/ocata/pub/__init__.py new file mode 100644 index 00000000..afa702d3 --- /dev/null +++ b/ocata/ocata/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/ocata/ocata/pub/config/__init__.py b/ocata/ocata/pub/config/__init__.py new file mode 100644 index 00000000..afa702d3 --- /dev/null +++ b/ocata/ocata/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/ocata/ocata/pub/config/config.py b/ocata/ocata/pub/config/config.py new file mode 100644 index 00000000..ae1ce9db --- /dev/null +++ b/ocata/ocata/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/ocata/ocata/pub/config/log.yml b/ocata/ocata/pub/config/log.yml new file mode 100644 index 00000000..224864d1 --- /dev/null +++ b/ocata/ocata/pub/config/log.yml @@ -0,0 +1,34 @@ +version: 1 +disable_existing_loggers: False + +loggers: + ocata: + handlers: [ocata_handler] + level: "DEBUG" + propagate: False + newton_base: + handlers': [ocata_handler] + level: "DEBUG" + propagate: False + common: + handlers: [ocata_handler] + level: "DEBUG" + propagate: False +handlers: + ocata_handler: + level: "DEBUG" + class: "logging.handlers.RotatingFileHandler" + filename: "/var/log/onap/multicloud/openstack/ocata/ocata.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/ocata/ocata/settings.py b/ocata/ocata/settings.py index 9f5711d6..169d83ea 100644 --- a/ocata/ocata/settings.py +++ b/ocata/ocata/settings.py @@ -15,6 +15,10 @@ import os import sys +from logging import config +from onaplogging import monkey +monkey.patch_all() + CACHE_EXPIRATION_TIME = 3600 # Build paths inside the project like this: os.path.join(BASE_DIR, ...) @@ -77,46 +81,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': { - 'ocata_handler': { - 'level': 'DEBUG', - 'class': 'logging.handlers.RotatingFileHandler', - 'filename': '/var/log/onap/multicloud/openstack/ocata/ocata.log', - 'formatter': 'standard', - 'maxBytes': 1024 * 1024 * 50, - 'backupCount': 5, - }, - }, - - 'loggers': { - 'ocata': { - 'handlers': ['ocata_handler'], - 'level': 'DEBUG', - 'propagate': False - }, - 'newton_base': { - 'handlers': ['ocata_handler'], - 'level': 'DEBUG', - 'propagate': False - }, - 'common': { - 'handlers': ['ocata_handler'], - 'level': 'DEBUG', - 'propagate': False - }, - } -} - CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', @@ -150,9 +114,14 @@ ROOT_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fi OPENSTACK_VERSION = "ocata" MULTIVIM_VERSION = "multicloud-" + OPENSTACK_VERSION +LOGGING_CONFIG = None +# yaml configuration of logging +LOGGING_FILE = os.path.join(BASE_DIR, 'ocata/pub/config/log.yml') +config.yamlConfig(filepath=LOGGING_FILE, watchDog=True) + if 'test' in sys.argv: - LOGGING['handlers']['ocata_handler']['filename'] = 'logs/ocata.log' + #LOGGING['handlers']['ocata_handler']['filename'] = 'logs/ocata.log' REST_FRAMEWORK = {} import platform diff --git a/ocata/pom.xml b/ocata/pom.xml index aae5c5b7..51d9a95e 100644 --- a/ocata/pom.xml +++ b/ocata/pom.xml @@ -28,14 +28,6 @@ <packaging>pom</packaging> <name>multicloud/openstack/ocata</name> <description>multicloud for openstack ocata</description> - <dependencies> - <dependency> - <groupId>org.onap.multicloud.openstack</groupId> - <artifactId>multicloud-openstack-newton</artifactId> - <version>1.1.0</version> - <type>zip</type> - </dependency> - </dependencies> <properties> <encoding>UTF-8</encoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> diff --git a/ocata/requirements.txt b/ocata/requirements.txt index 841fe278..76a3c0b1 100644 --- a/ocata/requirements.txt +++ b/ocata/requirements.txt @@ -15,3 +15,6 @@ 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/ocata/tox.ini b/ocata/tox.ini index be63b80f..2fb81e7f 100644 --- a/ocata/tox.ini +++ b/ocata/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py35,cov +envlist = py27,cov skipsdist = true [tox:jenkins] |