Skip to content

Commit 14d9659

Browse files
authored
Ensure logging gets configured early on. NFC (#14979)
Otherwise, message from config.py that are logged during startup are not effected by EMCC_DEBUG=1.
1 parent 69964a9 commit 14d9659

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tools/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from . import utils
1111
from .utils import path_from_root, exit_with_error, __rootpath__, which
1212

13-
logger = logging.getLogger('shared')
13+
logger = logging.getLogger('config')
1414

1515
# The following class can be overridden by the config file and/or
1616
# environment variables. Specifically any variable whose name

tools/shared.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,33 @@
2525
print('error: emscripten requires python 3.6 or above', file=sys.stderr)
2626
sys.exit(1)
2727

28+
from . import colored_logger
29+
30+
# Configure logging before importing any other local modules so even
31+
# log message during import are shown as expected.
32+
DEBUG = int(os.environ.get('EMCC_DEBUG', '0'))
33+
# can add %(asctime)s to see timestamps
34+
logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s',
35+
level=logging.DEBUG if DEBUG else logging.INFO)
36+
colored_logger.enable()
37+
2838
from .tempfiles import try_delete
2939
from .utils import path_from_root, exit_with_error, safe_ensure_dirs, WINDOWS
30-
from . import cache, tempfiles, colored_logger
40+
from . import cache, tempfiles
3141
from . import diagnostics
3242
from . import config
3343
from . import filelock
3444
from . import utils
3545
from .settings import settings
3646

3747

38-
DEBUG = int(os.environ.get('EMCC_DEBUG', '0'))
3948
DEBUG_SAVE = DEBUG or int(os.environ.get('EMCC_DEBUG_SAVE', '0'))
4049
EXPECTED_NODE_VERSION = (4, 1, 1)
4150
EXPECTED_LLVM_VERSION = "14.0"
4251
PYTHON = sys.executable
4352

4453
# Used only when EM_PYTHON_MULTIPROCESSING=1 env. var is set.
4554
multiprocessing_pool = None
46-
47-
# can add %(asctime)s to see timestamps
48-
logging.basicConfig(format='%(name)s:%(levelname)s: %(message)s',
49-
level=logging.DEBUG if DEBUG else logging.INFO)
50-
colored_logger.enable()
5155
logger = logging.getLogger('shared')
5256

5357
# warning about absolute-paths is disabled by default, and not enabled by -Wall

0 commit comments

Comments
 (0)