當前位置: 首頁>>代碼示例>>Python>>正文


Python logger.debug方法代碼示例

本文整理匯總了Python中loguru.logger.debug方法的典型用法代碼示例。如果您正苦於以下問題:Python logger.debug方法的具體用法?Python logger.debug怎麽用?Python logger.debug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在loguru.logger的用法示例。


在下文中一共展示了logger.debug方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: configure

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def configure(ctx):
    """
    Configure the following application settings:

    (1) Default encoding to load files.
    (2) HTTP/HTTPS proxy server URI (for url sub-command).

    Configurations are written to '~/.sqlitebiter'.
    You can remove these settings by deleting '~/.sqlitebiter'.
    """

    initialize_logger("{:s} file".format(PROGRAM_NAME), ctx.obj[Context.LOG_LEVEL])

    logger.debug("{} configuration file existence: {}".format(PROGRAM_NAME, app_config_mgr.exists))

    sys.exit(app_config_mgr.configure()) 
開發者ID:thombashi,項目名稱:sqlitebiter,代碼行數:18,代碼來源:__main__.py

示例2: __init__

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def __init__(
        self,
        path: typing.Union[bytes, str, os.PathLike],
        pre_load: bool = None,
        fps: int = None,
        *_,
        **__,
    ):
        assert os.path.isfile(path), f"video [{path}] not existed"
        self.path: str = str(path)
        self.data: typing.Optional[typing.Tuple[VideoFrame]] = tuple()

        self.fps: int = fps
        if fps:
            video_path = os.path.join(tempfile.mkdtemp(), f"tmp_{fps}.mp4")
            logger.debug(f"convert video, and bind path to {video_path}")
            toolbox.fps_convert(fps, self.path, video_path, constants.FFMPEG)
            self.path = video_path

        with toolbox.video_capture(self.path) as cap:
            self.frame_count = toolbox.get_frame_count(cap)
            self.frame_size = toolbox.get_frame_size(cap)

        if pre_load:
            self.load_frames() 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:27,代碼來源:video.py

示例3: load_frames

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def load_frames(self):
        # TODO full frames list can be very huge, for some devices
        logger.info(f"start loading {self.path} to memory ...")

        data: typing.List[VideoFrame] = []
        with toolbox.video_capture(self.path) as cap:
            success, frame = cap.read()
            while success:
                frame_object = VideoFrame.init(cap, frame)
                data.append(frame_object)
                success, frame = cap.read()

        # calculate memory cost
        each_cost = data[0].data.nbytes
        logger.debug(f"single frame cost: {each_cost} bytes")
        total_cost = each_cost * self.frame_count
        logger.debug(f"total frame cost: {total_cost} bytes")
        logger.info(
            f"frames loaded. frame count: {self.frame_count}. memory cost: {total_cost} bytes"
        )

        # lock the order
        self.data = tuple(data)
        # fix the length ( the last frame may be broken sometimes )
        self.frame_count = len(data) 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:27,代碼來源:video.py

示例4: fps_convert

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def fps_convert(
    target_fps: int, source_path: str, target_path: str, ffmpeg_exe: str = None
) -> int:
    # for portable ffmpeg
    if not ffmpeg_exe:
        ffmpeg_exe = r"ffmpeg"
    command: typing.List[str] = [
        ffmpeg_exe,
        "-i",
        source_path,
        "-r",
        str(target_fps),
        target_path,
    ]
    logger.debug(f"convert video: {command}")
    return subprocess.check_call(command) 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:18,代碼來源:toolbox.py

示例5: match_template_with_object

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def match_template_with_object(
    template: np.ndarray,
    target: np.ndarray,
    engine_template_cv_method_name: str = None,
    **kwargs,
) -> typing.Dict[str, typing.Any]:
    # change the default method
    if not engine_template_cv_method_name:
        engine_template_cv_method_name = "cv2.TM_CCOEFF_NORMED"

    fi = FindIt(
        engine=["template"],
        engine_template_cv_method_name=engine_template_cv_method_name,
        **kwargs,
    )
    # load template
    fi_template_name = "default"
    fi.load_template(fi_template_name, pic_object=template)

    result = fi.find(target_pic_name="", target_pic_object=target, **kwargs)
    logger.debug(f"findit result: {result}")
    return result["data"][fi_template_name]["TemplateEngine"] 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:24,代碼來源:toolbox.py

示例6: _draw_bar

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def _draw_bar(result: ClassifierResult) -> Bar:
        # draw bar chart
        bar = Bar(init_opts=opts.InitOpts(bg_color=constants.BACKGROUND_COLOR))
        x_axis = sorted(list(result.get_stage_set()))
        y_axis = list()
        offset = result.get_offset()
        for each_stage_name in x_axis:
            ranges = result.get_specific_stage_range(each_stage_name)
            time_cost: float = 0.0
            for each in ranges:
                # last frame - first frame
                time_cost += each[-1].timestamp - each[0].timestamp + offset
            y_axis.append(time_cost)

        bar.add_xaxis(x_axis)
        bar.add_yaxis("time cost", y_axis)
        bar.set_global_opts(
            title_opts=opts.TitleOpts(title="Time Cost", subtitle="... of each stages"),
            toolbox_opts=opts.ToolboxOpts(is_show=True),
        )
        logger.debug(f"time cost: {dict(zip(x_axis, y_axis))}")
        return bar 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:24,代碼來源:reporter.py

示例7: __init__

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def __init__(
        self,
        size: typing.Tuple[typing.Union[int, float], typing.Union[int, float]],
        offset: typing.Tuple[typing.Union[int, float], typing.Union[int, float]] = None,
        *_,
        **__,
    ):
        """
        init crop hook, (height, width)

        :param size:
        :param offset:
        :param _:
        :param __:
        """
        super().__init__(*_, **__)

        self.size = size
        self.offset = offset or (0, 0)
        logger.debug(f"size: {self.size}")
        logger.debug(f"offset: {self.offset}") 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:23,代碼來源:hook.py

示例8: save_model

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def save_model(self, model_path: str, overwrite: bool = None):
        """
        save trained model

        :param model_path:
        :param overwrite:
        :return:
        """
        logger.debug(f"save model to {model_path}")
        # assert model file
        if os.path.isfile(model_path) and not overwrite:
            raise FileExistsError(
                f"model file {model_path} already existed, you can set `overwrite` True to cover it"
            )
        # assert model data is not empty
        assert self._model, "model is empty"
        with open(model_path, "wb") as f:
            pickle.dump(self._model, f) 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:20,代碼來源:svm.py

示例9: load_model

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def load_model(self, model_path: str, overwrite: bool = None):
        """
        load trained model

        :param model_path:
        :param overwrite:
        :return:
        """
        logger.debug(f"load model from {model_path}")
        # assert model file
        assert os.path.isfile(model_path), f"model file {model_path} not existed"
        # assert model data is empty
        if self._model and not overwrite:
            raise RuntimeError(
                f"model is not empty, you can set `overwrite` True to cover it"
            )

        # joblib raise an error ( i have no idea about how to fix it ) here, so use pickle instead
        with open(model_path, "rb") as f:
            self._model = pickle.load(f) 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:22,代碼來源:svm.py

示例10: load_model

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def load_model(self, model_path: str, overwrite: bool = None):
        """
        load trained model

        :param model_path:
        :param overwrite:
        :return:
        """
        logger.debug(f"load model from {model_path}")
        # assert model file
        assert os.path.isfile(model_path), f"model file {model_path} not existed"
        # assert model data is empty
        if self._model and not overwrite:
            raise RuntimeError(
                f"model is not empty, you can set `overwrite` True to cover it"
            )
        self._model = self.create_model()
        self._model.load_weights(model_path) 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:20,代碼來源:keras.py

示例11: _classify_frame

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def _classify_frame(
        self, frame: VideoFrame, threshold: float = None, *_, **__
    ) -> str:
        if not threshold:
            threshold = 0.85

        result = list()
        for each_stage_name, each_stage_pic_list in self.read():
            each_result = list()
            for target_pic in each_stage_pic_list:
                # apply hooks
                target_pic = self._apply_hook(VideoFrame(-1, -1.0, target_pic))
                target_pic = target_pic.data

                each_pic_ssim = toolbox.compare_ssim(frame.data, target_pic)
                each_result.append(each_pic_ssim)
            ssim = max(each_result)
            result.append((each_stage_name, ssim))
            logger.debug(f"stage [{each_stage_name}]: {ssim}")

        result = max(result, key=lambda x: x[1])
        if result[1] < threshold:
            logger.debug("not a known stage, set it -1")
            result = ("-1", result[1])
        return result[0] 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:27,代碼來源:ssim.py

示例12: _prune

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def _prune(
        threshold: float,
        stages: typing.List[typing.Tuple[str, typing.List[VideoFrame]]],
    ) -> typing.List[typing.Tuple[str, typing.List[VideoFrame]]]:
        logger.debug(
            f"start pruning ranges, origin length is {len(stages)}, threshold is {threshold}"
        )
        after = list()
        for i in range(len(stages)):
            index, frames = stages[i]
            for j in range(i + 1, len(stages)):
                next_index, next_frames = stages[j]
                ssim_list = toolbox.multi_compare_ssim(frames, next_frames)
                min_ssim = min(ssim_list)
                logger.debug(f"compare {index} with {next_index}: {ssim_list}")
                if min_ssim > threshold:
                    logger.debug(f"stage {index} has been pruned")
                    break
            else:
                after.append(stages[i])
        return after 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:23,代碼來源:cut_result.py

示例13: pick

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def pick(
        self, frame_count: int = None, is_random: bool = None, *_, **__
    ) -> typing.List[int]:
        if not frame_count:
            frame_count = 3
        logger.debug(
            f"pick {frame_count} frames "
            f"from {self.start}({self.start_time}) "
            f"to {self.end}({self.end_time}) "
            f"on video {self.video.path}"
        )

        result = list()
        if is_random:
            return random.sample(range(self.start, self.end), frame_count)
        length = self.get_length()

        # https://github.com/williamfzc/stagesepx/issues/37
        frame_count += 1
        for _ in range(1, frame_count):
            cur = int(self.start + length / frame_count * _)
            result.append(cur)
        return result 
開發者ID:williamfzc,項目名稱:stagesepx,代碼行數:25,代碼來源:cut_range.py

示例14: write

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def write(self,msg,level='info'):
        "Write out a message"
        fname = inspect.stack()[2][3] #May be use a entry-exit decorator instead        
        d = {'caller_func': fname}                    
        if level.lower()== 'debug': 
            logger.debug("{module} | {msg}",module=d['caller_func'],msg=msg)                      
        elif level.lower()== 'info':
            logger.info("{module} | {msg}",module=d['caller_func'],msg=msg)           
        elif level.lower()== 'warn' or level.lower()=='warning':           
            logger.warning("{module} | {msg}",module=d['caller_func'],msg=msg)
        elif level.lower()== 'error':
            logger.error("{module} | {msg}",module=d['caller_func'],msg=msg)            
        elif level.lower()== 'critical':   
            logger.critical("{module} | {msg}",module=d['caller_func'],msg=msg)            
        else:
            logger.critical("Unknown level passed for the msg: {}", msg) 
開發者ID:qxf2,項目名稱:makemework,代碼行數:18,代碼來源:Base_Logging.py

示例15: release

# 需要導入模塊: from loguru import logger [as 別名]
# 或者: from loguru.logger import debug [as 別名]
def release(self):
        """Create a zipfile release with the current version number defined in bl_info dict in __init__.py"""
        # Builds dir
        builds = Path('.', 'builds')
        if not builds.exists():
            builds.mkdir()

        # Extract the version number from the __init__.py file.
        regex = r"\"version\":\s*(\(\d\,\s*\d\,\s*\d\))"
        with Path('__init__.py').open('r') as f:
            string = f.read().replace("\n", '')
            match = re.findall(regex, string, re.MULTILINE)[0]
            log.debug(match)
            log.info(f'Create release version: {match}')
        postfix = '.'.join([str(x) for x in eval(match)])

        # Zip all needed file into a realease.
        zip_file = builds / f'Projectors {postfix}.zip'
        with zipfile.ZipFile(zip_file, 'w') as zf:
            for f in Path('.').glob('*.py'):
                zf.write(f)
            zf.write('README.md')
            zf.write('LICENSE')
        return f'A realease zipfile was created: {zip_file}' 
開發者ID:Ocupe,項目名稱:Projectors,代碼行數:26,代碼來源:cmd.py


注:本文中的loguru.logger.debug方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。