Skip to content

Commit d2dce83

Browse files
committed
feat: add log file to curator cache
1 parent 18940f2 commit d2dce83

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/bespokelabs/curator/llm/llm.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from bespokelabs.curator.constants import _CURATOR_DEFAULT_CACHE_DIR
1515
from bespokelabs.curator.db import MetadataDB
1616
from bespokelabs.curator.llm.prompt_formatter import PromptFormatter
17-
from bespokelabs.curator.log import logger
17+
from bespokelabs.curator.log import add_file_handler, logger
1818
from bespokelabs.curator.request_processor._factory import _RequestProcessorFactory
1919
from bespokelabs.curator.request_processor.config import BackendParamsType
2020

@@ -218,6 +218,7 @@ def __call__(
218218

219219
run_cache_dir = os.path.join(curator_cache_dir, fingerprint)
220220
os.makedirs(run_cache_dir, exist_ok=True)
221+
add_file_handler(run_cache_dir)
221222

222223
session_id = self._request_processor.viewer_client.create_session(metadata_dict)
223224
metadata_dict["session_id"] = session_id

src/bespokelabs/curator/log.py

-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from rich.console import Console
66
from rich.logging import RichHandler
77

8-
from bespokelabs.curator.constants import _CURATOR_DEFAULT_CACHE_DIR
9-
108
LOG_FORMAT = "%(asctime)s | %(levelname)-8s | %(module)s:%(lineno)d - %(message)s"
119
ROOT_LOG_LEVEL = logging.DEBUG
1210

@@ -29,14 +27,8 @@ def _init_logger(self):
2927
self.logger = logging.getLogger("curator")
3028
self.logger.setLevel(ROOT_LOG_LEVEL)
3129
if not self.logger.handlers:
32-
log_file = os.path.join(os.path.expanduser(_CURATOR_DEFAULT_CACHE_DIR), "curator.log")
33-
formatter = logging.Formatter(LOG_FORMAT)
34-
file_handler = logging.handlers.RotatingFileHandler(log_file, maxBytes=5 * 1024 * 1024, backupCount=5)
35-
file_handler.setLevel(logging.DEBUG)
36-
file_handler.setFormatter(formatter)
3730
rich_handler = RichHandler(console=_CONSOLE)
3831
rich_handler.setLevel(logging.INFO)
39-
self.logger.addHandler(file_handler)
4032

4133
self.logger.addHandler(rich_handler)
4234

0 commit comments

Comments
 (0)