Set the level of existing loggers to `WARNING`. By default, it will "disable" all existing loggers except the logger named "colossalai". Args: include (Optional[List[str]], optional): Loggers whose name in this list will be disabled. If set to `None`, `exclude` argument will
(include: Optional[List[str]] = None, exclude: List[str] = ["colossalai"])
| 20 | |
| 21 | |
| 22 | def disable_existing_loggers(include: Optional[List[str]] = None, exclude: List[str] = ["colossalai"]) -> None: |
| 23 | """Set the level of existing loggers to `WARNING`. By default, it will "disable" all existing loggers except the logger named "colossalai". |
| 24 | |
| 25 | Args: |
| 26 | include (Optional[List[str]], optional): Loggers whose name in this list will be disabled. |
| 27 | If set to `None`, `exclude` argument will be used. Defaults to None. |
| 28 | exclude (List[str], optional): Loggers whose name not in this list will be disabled. |
| 29 | This argument will be used only when `include` is None. Defaults to ['colossalai']. |
| 30 | """ |
| 31 | if include is None: |
| 32 | filter_func = lambda name: name not in exclude |
| 33 | else: |
| 34 | filter_func = lambda name: name in include |
| 35 | |
| 36 | for log_name in logging.Logger.manager.loggerDict.keys(): |
| 37 | if filter_func(log_name): |
| 38 | logging.getLogger(log_name).setLevel(logging.WARNING) |
no outgoing calls
searching dependent graphs…