Allow logging across modules
Test: confirm logging from different modules Bug: 78279738 Change-Id: If51918fd7a4ad3ea3408109a39a293bcd56f71db
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
"""Utility functions for VNDK snapshot."""
|
||||
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
@@ -34,6 +35,24 @@ NOTICE_FILES_DIR_NAME = 'NOTICE_FILES'
|
||||
NOTICE_FILES_DIR_PATH = os.path.join(COMMON_DIR_PATH, NOTICE_FILES_DIR_NAME)
|
||||
|
||||
|
||||
def logger(name):
|
||||
return logging.getLogger(name)
|
||||
|
||||
|
||||
def set_logging_config(verbose_level):
|
||||
verbose_map = (logging.WARNING, logging.INFO, logging.DEBUG)
|
||||
verbosity = min(verbose_level, 2)
|
||||
logging.basicConfig(
|
||||
format='%(levelname)-8s [%(filename)s:%(lineno)d] %(message)s',
|
||||
level=verbose_map[verbosity])
|
||||
|
||||
|
||||
def check_call(cmd, logger=None):
|
||||
logger = logger or logging
|
||||
logger.debug('Running `{}`'.format(' '.join(cmd)))
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
|
||||
def get_android_build_top():
|
||||
ANDROID_BUILD_TOP = os.getenv('ANDROID_BUILD_TOP')
|
||||
if not ANDROID_BUILD_TOP:
|
||||
@@ -129,5 +148,4 @@ def fetch_artifact(branch, build, pattern, destination='.'):
|
||||
fetch_artifact_path, '--branch', branch, '--target=vndk', '--bid',
|
||||
build, pattern, destination
|
||||
]
|
||||
print 'Running `{}`'.format(' '.join(cmd))
|
||||
subprocess.check_call(cmd)
|
||||
check_call(cmd, logger(__name__))
|
||||
|
||||
Reference in New Issue
Block a user