Skip to content

Commit 86cf3f7

Browse files
authored
[Python] Add flag to disable logging config (#3060)
Fixes #2780 This adds a environment variable `MLC_UNSET_LOGGING` to force the logging format to be disabled. It also removes `enable_logging` calls except for in MLC entrypoints (e.g. CLI main).
1 parent 8477ac0 commit 86cf3f7

File tree

10 files changed

+3
-9
lines changed

10 files changed

+3
-9
lines changed

python/mlc_llm/bench/api_endpoint.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from mlc_llm.bench.request_record import Metrics, RequestRecord, ServerMetrics
1313
from mlc_llm.support import logging
1414

15-
logging.enable_logging()
1615
logger = logging.getLogger(__name__)
1716

1817

python/mlc_llm/bench/request_processor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from mlc_llm.protocol.openai_api_protocol import ChatCompletionMessage, DebugConfig
2020
from mlc_llm.support import logging
2121

22-
logging.enable_logging()
2322
logger = logging.getLogger(__name__)
2423

2524

python/mlc_llm/bench/request_record.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from mlc_llm.protocol.openai_api_protocol import ChatCompletionRequest
99
from mlc_llm.support import logging
1010

11-
logging.enable_logging()
1211
logger = logging.getLogger(__name__)
1312

1413

python/mlc_llm/cli/delivery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from mlc_llm.support.argparse import ArgumentParser
1717
from mlc_llm.support.style import bold, green, red
1818

19-
logging.enable_logging()
2019
logger = logging.getLogger(__name__)
2120

2221
GEN_CONFIG_OPTIONAL_ARGS = [

python/mlc_llm/cli/lib_delivery.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from mlc_llm.support.constants import MLC_TEMP_DIR
1717
from mlc_llm.support.style import bold, green, red
1818

19-
logging.enable_logging()
2019
logger = logging.getLogger(__name__)
2120

2221

python/mlc_llm/cli/model_metadata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from mlc_llm.support.config import ConfigBase
1414
from mlc_llm.support.style import green, red
1515

16-
logging.enable_logging()
1716
logger = logging.getLogger(__name__)
1817

1918

python/mlc_llm/serve/engine.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
from . import engine_base
3232

33-
logging.enable_logging()
3433
logger = logging.getLogger(__name__)
3534

3635

python/mlc_llm/serve/engine_base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
from mlc_llm.support.style import green
2929
from mlc_llm.tokenizers import TextStreamer, Tokenizer
3030

31-
logging.enable_logging()
3231
logger = logging.getLogger(__name__)
3332

3433

python/mlc_llm/serve/sync_engine.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from mlc_llm.support import logging
3030
from mlc_llm.tokenizers import TextStreamer, Tokenizer
3131

32-
logging.enable_logging()
3332
logger = logging.getLogger(__name__)
3433

3534

python/mlc_llm/support/logging.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
"""
55

66
import logging
7+
import os
78

89

910
def enable_logging():
1011
"""Enable MLC's default logging format"""
12+
if os.getenv("MLC_UNSET_LOGGING"):
13+
return
1114
logging.basicConfig(
1215
level=logging.INFO,
1316
style="{",

0 commit comments

Comments
 (0)