import os

import carb
import carb.settings


def _get_setting(path, default=None):
    setting = carb.settings.get_settings().get(path)
    return setting if setting is not None else default


def _to_log_str(s: str) -> str:
    return f"[omni.kit.extpath.git]: {s}"


# print() instead of carb.log_info when this env var is set:
_debug_print = bool(os.getenv("OMNI_KIT_EXTPATH_GIT_DEBUG", default=False))


def _info(s):
    s = _to_log_str(s)
    carb.log_info(s)
    if _debug_print:
        print(s)


def _print(s):
    s = _to_log_str(s)
    carb.log_info(s)
    print(_to_log_str(s))


def _error(s):
    carb.log_error(_to_log_str(s))

def _warn(s):
    carb.log_warn(_to_log_str(s))
