Skip to content

Commit

Permalink
Add EMCC_LOGGING=0 to disable all logging
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sbc100 committed Jun 5, 2023
1 parent accfb24 commit c6eed5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.

3.1.41 (in development)
-----------------------
- The log message that emcc will sometime print (for example when auto-building
system libraries) can now be completely supressed by running with
`EMCC_LOGGING=0`.
- A new setting (`CHECK_NULL_WRITES`) was added to disabled the checking of
address zero that is normally done when `STACK_OVERFLOW_CHECK` is enabled.
(#19487)
Expand Down
5 changes: 2 additions & 3 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7118,6 +7118,7 @@ def test_realpath_2(self):
Resolved: "/" => "/"
''', self.run_js('a.out.js'))

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

@with_env_modify({'EMCC_LOGGING': '0'}) # this test assumes no emcc output
def test_nostdlib(self):
# First ensure all the system libs are built
self.run_process([EMCC, test_file('unistd/close.c')])

err = 'symbol exported via --export not found: __errno_location'
self.assertContained(err, self.expect_fail([EMCC, test_file('unistd/close.c'), '-nostdlib']))
self.assertContained(err, self.expect_fail([EMCC, test_file('unistd/close.c'), '-nodefaultlibs']))
Expand Down
9 changes: 7 additions & 2 deletions tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@
# 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_LOGGING = int(os.environ.get('EMCC_LOGGING', '1'))
log_level = logging.ERROR
if DEBUG:
log_level = logging.DEBUG
elif EMCC_LOGGING:
log_level = logging.INFO
# 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

0 comments on commit c6eed5f

Please sign in to comment.