forked from apify/apify-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.py
More file actions
32 lines (21 loc) · 1003 Bytes
/
log.py
File metadata and controls
32 lines (21 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from __future__ import annotations
import logging
from crawlee._log_config import CrawleeLogFormatter, configure_logger, get_configured_log_level
# Name of the logger used throughout the library (resolves to 'apify')
logger_name = __name__.split('.')[0]
# Logger used throughout the library
logger = logging.getLogger(logger_name)
class ActorLogFormatter(CrawleeLogFormatter): # noqa: D101 (Inherited from parent class)
pass
def _configure_logging() -> None:
apify_client_logger = logging.getLogger('apify_client')
configure_logger(apify_client_logger, remove_old_handlers=True)
level = get_configured_log_level()
# Keep apify_client logger quiet unless debug logging is requested
if level > logging.DEBUG:
apify_client_logger.setLevel(logging.INFO)
else:
apify_client_logger.setLevel(level)
# Use configured log level for apify logger
apify_logger = logging.getLogger('apify')
configure_logger(apify_logger, remove_old_handlers=True)