Skip to content

Commit 58ff5aa

Browse files
authored
Add EMCC_LOGGING=0 to disable all logging (#19531)
This can be useful when running tests that want to check the stderr of emscripten. This was suggested as an aternative to #19085 and should fix #18607 but maybe isn't quite right to solve #18622. Fixes: #19085
1 parent 41e3e29 commit 58ff5aa

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.41 (in development)
2222
-----------------------
23+
- The log message that emcc will sometime print (for example when auto-building
24+
system libraries) can now be completely supressed by running with
25+
`EMCC_LOGGING=0`.
2326
- A new setting (`CHECK_NULL_WRITES`) was added to disabled the checking of
2427
address zero that is normally done when `STACK_OVERFLOW_CHECK` is enabled.
2528
(#19487)

test/test_other.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7118,6 +7118,7 @@ def test_realpath_2(self):
71187118
Resolved: "/" => "/"
71197119
''', self.run_js('a.out.js'))
71207120

7121+
@with_env_modify({'EMCC_LOGGING': '0'}) # this test assumes no emcc output
71217122
def test_no_warnings(self):
71227123
# build once before to make sure system libs etc. exist
71237124
self.run_process([EMXX, test_file('hello_libcxx.cpp')])
@@ -11281,10 +11282,8 @@ def test_bitcode_input(self):
1128111282
self.run_process([EMCC, '-c', '-o', 'main.o', 'main.bc'])
1128211283
self.assertTrue(building.is_wasm('main.o'))
1128311284

11285+
@with_env_modify({'EMCC_LOGGING': '0'}) # this test assumes no emcc output
1128411286
def test_nostdlib(self):
11285-
# First ensure all the system libs are built
11286-
self.run_process([EMCC, test_file('unistd/close.c')])
11287-
1128811287
err = 'symbol exported via --export not found: __errno_location'
1128911288
self.assertContained(err, self.expect_fail([EMCC, test_file('unistd/close.c'), '-nostdlib']))
1129011289
self.assertContained(err, self.expect_fail([EMCC, test_file('unistd/close.c'), '-nodefaultlibs']))

tools/shared.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@
2929
# Configure logging before importing any other local modules so even
3030
# log message during import are shown as expected.
3131
DEBUG = int(os.environ.get('EMCC_DEBUG', '0'))
32+
EMCC_LOGGING = int(os.environ.get('EMCC_LOGGING', '1'))
33+
log_level = logging.ERROR
34+
if DEBUG:
35+
log_level = logging.DEBUG
36+
elif EMCC_LOGGING:
37+
log_level = logging.INFO
3238
# can add %(asctime)s to see timestamps
33-
logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s',
34-
level=logging.DEBUG if DEBUG else logging.INFO)
39+
logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s', level=log_level)
3540
colored_logger.enable()
3641

3742
from .utils import path_from_root, exit_with_error, safe_ensure_dirs, WINDOWS

0 commit comments

Comments
 (0)