Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EMCC_LOGGING=0 to disable all logging #19531

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

@kripken kripken Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit odd to me. It disables logging, but the test wants to check that there is no problem that causes logging. So it is really a test for the flag disabling logging, but not for the problems that can cause logging existing or not.

In practice most of those warnings are from clang, which EMCC_LOGGING doesn't handle. So I'm not too worried here in practice, I guess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EMCC_LOGGING only effect logging.. which is completely separate to the warnings system. EMCC_LOGGING does not effect warnings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. That's less worrying to me then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps its a little confusing... that emscripten uses both python's logging module and also its own "diagnostics.py" module?

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be WARN by default? (what was the default before? do we actually use WARN?)

Copy link
Collaborator Author

@sbc100 sbc100 Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EMCC_LOGGING default to 1, so the default here is, and was before, logging.INFO.

logging.ERROR is the new level introduced here that is only used if you explicitly set EMCC_LOGGING=0.

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