diff options
author | Tomi Juvonen <tomi.juvonen@nokia.com> | 2016-12-08 07:33:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2016-12-08 07:33:51 +0000 |
commit | 75f48053575ebb04b7516016421c41c2a02f63cb (patch) | |
tree | da48d4c0ed3108a7ebadf491b232dfb244612ae8 /tests/inspector.py | |
parent | 2f60002bba5dd4d2c2071af6acf4f56e87fc13cc (diff) | |
parent | b7b37cfd508ca612c217e802b38b7a50d04e7e7e (diff) |
Merge "remove `Debug = True when run Flask and add logger"
Diffstat (limited to 'tests/inspector.py')
-rw-r--r-- | tests/inspector.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/inspector.py b/tests/inspector.py index 62614158..129a386a 100644 --- a/tests/inspector.py +++ b/tests/inspector.py @@ -12,6 +12,7 @@ import collections from flask import Flask from flask import request import json +import logger as doctor_log import os import time @@ -19,6 +20,8 @@ import novaclient.client as novaclient import nova_force_down +LOG = doctor_log.Logger('doctor_inspector').getLogger() + class DoctorInspectorSample(object): @@ -44,9 +47,9 @@ class DoctorInspectorSample(object): try: host=server.__dict__.get('OS-EXT-SRV-ATTR:host') self.servers[host].append(server) - app.logger.debug('get hostname=%s from server=%s' % (host, server)) + LOG.debug('get hostname=%s from server=%s' % (host, server)) except Exception as e: - app.logger.debug('can not get hostname from server=%s' % server) + LOG.error('can not get hostname from server=%s' % server) def disable_compute_host(self, hostname): for server in self.servers[hostname]: @@ -63,15 +66,14 @@ class DoctorInspectorSample(object): app = Flask(__name__) -app.debug = True inspector = DoctorInspectorSample() @app.route('/events', methods=['POST']) def event_posted(): - app.logger.debug('event posted at %s' % time.time()) - app.logger.debug('inspector = %s' % inspector) - app.logger.debug('received data = %s' % request.data) + LOG.info('event posted at %s' % time.time()) + LOG.info('inspector = %s' % inspector) + LOG.info('received data = %s' % request.data) d = json.loads(request.data) hostname = d['hostname'] event_type = d['type'] @@ -91,5 +93,6 @@ def main(): args = get_args() app.run(port=args.port) + if __name__ == '__main__': main() |