Skip to content

Commit

Permalink
Change default log level to WARN to avoid spamming stderr
Browse files Browse the repository at this point in the history
By default we don't want random messages such as `cache:INFO: generating
system asset:` from appearing on stdout.

EMCC_DEBUG and EMCC_VERBOSE can be used enable more info.

Fixes: #18622, #18607
  • Loading branch information
sbc100 committed Mar 28, 2023
1 parent bd95d10 commit 9ac0d2d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def main():
settings.LTO = args.lto

if args.verbose:
shared.PRINT_STAGES = True
shared.EMCC_VERBOSE = True

if args.pic:
settings.RELOCATABLE = 1
Expand Down
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3504,7 +3504,7 @@ def consume_arg_file():
elif check_flag('--ignore-dynamic-linking'):
options.ignore_dynamic_linking = True
elif arg == '-v':
shared.PRINT_STAGES = True
shared.EMCC_VERBOSE = True
elif check_arg('--shell-file'):
options.shell_path = consume_arg_file()
elif check_arg('--source-map-base'):
Expand Down
2 changes: 1 addition & 1 deletion emsymbolizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def get_args():
parser.add_argument('address', help='Address to lookup')
args = parser.parse_args()
if args.verbose:
shared.PRINT_STAGES = 1
shared.EMCC_VERBOSE = True
shared.DEBUG = True
return args

Expand Down
1 change: 1 addition & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def test_emcc_v(self):
self.assertContained('Target: wasm32-unknown-emscripten', proc.stderr)
self.assertNotContained('this is dangerous', proc.stderr)

@with_env_modify({'EMCC_VERBOSE': '1'})
def test_emcc_check(self):
proc = self.run_process([EMCC, '--check'], stdout=PIPE, stderr=PIPE)
self.assertEqual(proc.stdout, '')
Expand Down
14 changes: 9 additions & 5 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@
# Configure logging before importing any other local modules so even
# log message during import are shown as expected.
DEBUG = int(os.environ.get('EMCC_DEBUG', '0'))
EMCC_VERBOSE = int(os.getenv('EMCC_VERBOSE', '0'))
if DEBUG:
log_level = logging.DEBUG
elif EMCC_VERBOSE:
log_level = logging.INFO
else:
log_level = logging.WARN
# can add %(asctime)s to see timestamps
logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s',
level=logging.DEBUG if DEBUG else logging.INFO)
logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s', level=log_level)
colored_logger.enable()

from .utils import path_from_root, exit_with_error, safe_ensure_dirs, WINDOWS
Expand Down Expand Up @@ -618,7 +624,7 @@ def target_environment_may_be(environment):
def print_compiler_stage(cmd):
"""Emulate the '-v' of clang/gcc by printing the name of the sub-command
before executing it."""
if PRINT_STAGES:
if EMCC_VERBOSE:
print(' "%s" %s' % (cmd[0], shlex_join(cmd[1:])), file=sys.stderr)
sys.stderr.flush()

Expand Down Expand Up @@ -787,5 +793,3 @@ def get_llvm_target():
setup_temp_dirs()

cache.setup(config.CACHE)

PRINT_STAGES = int(os.getenv('EMCC_VERBOSE', '0'))
2 changes: 1 addition & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_top_level_ninja_file():
def run_ninja(build_dir):
diagnostics.warning('experimental', 'ninja support is experimental')
cmd = ['ninja', '-C', build_dir, f'-j{shared.get_num_cores()}']
if shared.PRINT_STAGES:
if shared.EMCC_VERBOSE:
cmd.append('-v')
shared.check_call(cmd, env=clean_env())

Expand Down
1 change: 1 addition & 0 deletions tools/toolchain_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from contextlib import ContextDecorator

logger = logging.getLogger('profiler')
logger.setLevel(logging.INFO)

from . import response_file

Expand Down

0 comments on commit 9ac0d2d

Please sign in to comment.