Skip to content

Commit

Permalink
[Python] Add flag to disable logging config (#3060)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
hykilpikonna authored Dec 11, 2024
1 parent 8477ac0 commit 86cf3f7
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 9 deletions.
1 change: 0 additions & 1 deletion python/mlc_llm/bench/api_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from mlc_llm.bench.request_record import Metrics, RequestRecord, ServerMetrics
from mlc_llm.support import logging

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/bench/request_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from mlc_llm.protocol.openai_api_protocol import ChatCompletionMessage, DebugConfig
from mlc_llm.support import logging

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/bench/request_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from mlc_llm.protocol.openai_api_protocol import ChatCompletionRequest
from mlc_llm.support import logging

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/cli/delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from mlc_llm.support.argparse import ArgumentParser
from mlc_llm.support.style import bold, green, red

logging.enable_logging()
logger = logging.getLogger(__name__)

GEN_CONFIG_OPTIONAL_ARGS = [
Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/cli/lib_delivery.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from mlc_llm.support.constants import MLC_TEMP_DIR
from mlc_llm.support.style import bold, green, red

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/cli/model_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from mlc_llm.support.config import ConfigBase
from mlc_llm.support.style import green, red

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/serve/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

from . import engine_base

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/serve/engine_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from mlc_llm.support.style import green
from mlc_llm.tokenizers import TextStreamer, Tokenizer

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion python/mlc_llm/serve/sync_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from mlc_llm.support import logging
from mlc_llm.tokenizers import TextStreamer, Tokenizer

logging.enable_logging()
logger = logging.getLogger(__name__)


Expand Down
3 changes: 3 additions & 0 deletions python/mlc_llm/support/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"""

import logging
import os


def enable_logging():
"""Enable MLC's default logging format"""
if os.getenv("MLC_UNSET_LOGGING"):
return
logging.basicConfig(
level=logging.INFO,
style="{",
Expand Down

0 comments on commit 86cf3f7

Please sign in to comment.