File size: 814 Bytes
ef9200f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import logging
import os
class SpecificWarningFilter(logging.Filter):
def __init__(self, message_to_suppress: str):
"""Filter out a specific warning message based on its content.
This can be useful for filtering out specific warning messages from third party packages.
Args:
message_to_suppress (str): The warning message to suppress.
"""
super().__init__()
self.message_to_suppress = message_to_suppress
def filter(self, record: logging.LogRecord) -> bool:
return self.message_to_suppress not in record.getMessage()
def get_mosaicml_logger():
if os.environ.get(MOSAICML_PLATFORM_ENV_VAR, 'false').lower() == 'true' and os.environ.get(MOSAICML_ACCESS_TOKEN_ENV_VAR):
return MosaicMLLogger()
else:
return None |