summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/java/jvpp/gen/jvpp_gen.py
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-01-26 11:39:27 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2018-01-27 10:50:52 +0000
commit568cc60b7097299cacb4341a4a70d8ef270f51b4 (patch)
tree32c33be07b8c836d779ea0efdcae9b47836f5abe /src/vpp-api/java/jvpp/gen/jvpp_gen.py
parent2f8d8fa50175bf775f66ff15aff2cf08138ccfbd (diff)
jvpp: use Python's logging API
Change-Id: Iec437e4672af1f0d1a24458afb977ba6fbeba4ed Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'src/vpp-api/java/jvpp/gen/jvpp_gen.py')
-rwxr-xr-xsrc/vpp-api/java/jvpp/gen/jvpp_gen.py52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/vpp-api/java/jvpp/gen/jvpp_gen.py b/src/vpp-api/java/jvpp/gen/jvpp_gen.py
index 9a1dad9c53d..79708abdf8a 100755
--- a/src/vpp-api/java/jvpp/gen/jvpp_gen.py
+++ b/src/vpp-api/java/jvpp/gen/jvpp_gen.py
@@ -18,6 +18,7 @@ import argparse
import sys
import os
import json
+import logging
from jvppgen import types_gen
from jvppgen import callback_gen
@@ -48,17 +49,33 @@ args = parser.parse_args()
sys.path.append(".")
cwd = os.getcwd()
-print "Generating Java API for %s" % args.inputfiles
-print "inputfiles %s" % args.inputfiles
+# Initialize logger
+try:
+ verbose = int(os.getenv("V", 0))
+except:
+ verbose = 0
+
+log_level = logging.WARNING
+if verbose == 1:
+ log_level = logging.INFO
+elif verbose >= 2:
+ log_level = logging.DEBUG
+
+logging.basicConfig(stream=sys.stdout, level=log_level)
+logger = logging.getLogger("JVPP GEN")
+logger.setLevel(log_level)
+
+
+logger.info("Generating Java API for %s" % args.inputfiles)
plugin_name = args.plugin_name
-print "plugin_name %s" % plugin_name
+logger.debug("plugin_name: %s" % plugin_name)
cfg = {}
base_package = 'io.fd.vpp.jvpp'
plugin_package = base_package + '.' + plugin_name
root_dir = os.path.abspath(args.root_dir)
-print "root_dir %s" % root_dir
+logger.debug("root_dir: %s" % root_dir)
work_dir = root_dir + "/target/" + plugin_package.replace(".","/")
try:
@@ -168,16 +185,23 @@ callback_facade_package = 'callfacade'
types_list, types_name = get_definitions(cfg['types'])
-types_gen.generate_types(types_list, plugin_package, types_package, args.inputfiles)
+types_gen.generate_types(types_list, plugin_package, types_package, args.inputfiles, logger)
func_list, func_name = get_definitions(cfg['messages'])
-dto_gen.generate_dtos(func_list, base_package, plugin_package, plugin_name.title(), dto_package, args.inputfiles)
-jvpp_impl_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, args.inputfiles)
-callback_gen.generate_callbacks(func_list, base_package, plugin_package, plugin_name.title(), callback_package, dto_package, args.inputfiles)
-notification_gen.generate_notification_registry(func_list, base_package, plugin_package, plugin_name.title(), notification_package, callback_package, dto_package, args.inputfiles)
-jvpp_c_gen.generate_jvpp(func_list, plugin_name, args.inputfiles, root_dir)
-jvpp_future_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package, callback_package, notification_package, future_package, args.inputfiles)
-jvpp_callback_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package, callback_package, notification_package, callback_facade_package, args.inputfiles)
-
-print "Java API for %s generated successfully" % args.inputfiles
+dto_gen.generate_dtos(func_list, base_package, plugin_package, plugin_name.title(), dto_package, args.inputfiles,
+ logger)
+jvpp_impl_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name, dto_package, args.inputfiles, logger)
+callback_gen.generate_callbacks(func_list, base_package, plugin_package, plugin_name.title(), callback_package,
+ dto_package, args.inputfiles, logger)
+notification_gen.generate_notification_registry(func_list, base_package, plugin_package, plugin_name.title(),
+ notification_package, callback_package, dto_package, args.inputfiles,
+ logger)
+jvpp_c_gen.generate_jvpp(func_list, plugin_name, args.inputfiles, root_dir, logger)
+jvpp_future_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package,
+ callback_package, notification_package, future_package, args.inputfiles, logger)
+jvpp_callback_facade_gen.generate_jvpp(func_list, base_package, plugin_package, plugin_name.title(), dto_package,
+ callback_package, notification_package, callback_facade_package, args.inputfiles,
+ logger)
+
+logger.info("Java API for %s generated successfully" % args.inputfiles)