""" * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & * AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. """ from __future__ import annotations import logging _PREFIX = "[RTX Remix]" __all__ = ["get_logger"] class _PrefixFilter(logging.Filter): def filter(self, record: logging.LogRecord) -> bool: if record.args: record.msg = record.msg % record.args record.args = () if isinstance(record.msg, str) and not record.msg.startswith(_PREFIX): record.msg = f"{_PREFIX} {record.msg}" return True def get_logger(name: str | None = None) -> logging.Logger: logger = logging.getLogger(name or "comfyui_rtx_remix") if not any(isinstance(filt, _PrefixFilter) for filt in logger.filters): logger.addFilter(_PrefixFilter()) root_logger = logging.getLogger() if not root_logger.handlers and not logger.handlers: handler = logging.StreamHandler() handler.setFormatter(logging.Formatter("%(message)s")) logger.addHandler(handler) logger.setLevel(logging.INFO) logger.propagate = False return logger