Skip to content

Commit 4312b18

Browse files
goatwu1993cubic-dev-ai[bot]hayescode
authored
fix: fix chainlit sets logging while act as a library (#2683)
fix #2682 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Stop Chainlit from changing global logging when imported as a library. Move logging.basicConfig to the CLI entrypoint and remove it from chainlit.logger, while keeping socketio/engineio loggers at ERROR. <sup>Written for commit aff41d1. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Josh Hayes <[email protected]>
1 parent 8d3c457 commit 4312b18

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

backend/chainlit/cli/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import asyncio
2+
import logging
23
import os
4+
import sys
35

46
import click
57
import nest_asyncio
@@ -26,6 +28,13 @@
2628
from chainlit.secret import random_secret
2729
from chainlit.utils import check_file
2830

31+
logging.basicConfig(
32+
level=logging.INFO,
33+
stream=sys.stdout,
34+
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
35+
datefmt="%Y-%m-%d %H:%M:%S",
36+
)
37+
2938

3039
def assert_app():
3140
if (

backend/chainlit/logger.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
import logging
2-
import sys
3-
4-
logging.basicConfig(
5-
level=logging.INFO,
6-
stream=sys.stdout,
7-
format="%(asctime)s - %(message)s",
8-
datefmt="%Y-%m-%d %H:%M:%S",
9-
)
102

113
logging.getLogger("socketio").setLevel(logging.ERROR)
124
logging.getLogger("engineio").setLevel(logging.ERROR)

0 commit comments

Comments
 (0)