Skip to content

Commit

Permalink
code.core>modify.refactor: add error log containing line string into …
Browse files Browse the repository at this point in the history
…`maketagdoc` subcommand
  • Loading branch information
pwnfan committed Aug 1, 2023
1 parent b7c9c08 commit c1910ef
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tagmark/tools/maketagdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from tqdm import tqdm

from tagmark.core.data import TagmarkFilter
from tagmark.core.log import LogHandler, LogLevel, get_level_logger
from tagmark.core.tag import TagItem
from tagmark.tools.convert import tagmark as tagmark_convert

Expand All @@ -33,6 +34,15 @@ def __init__(
condition_json_path: Path | None = None,
is_ban_condition: bool = True,
):
self._logger = get_level_logger(
name="tagmark",
level=LogLevel.INFO,
handlers=[
LogHandler.CONSOLE,
],
)
self._logger.bind(scope="TagDocMaker")

self._tagmark_data_json_path: Path = tagmark_data_json_path
self._tags_json_path: Path = tags_json_path
self._config_path: Path = config_path
Expand Down Expand Up @@ -112,7 +122,15 @@ def make(self, cheat_sheet_template: str) -> str:
iterable=cheat_sheet_template.splitlines(keepends=True),
desc="processing by lines...",
):
new_lines.append(self._format_line(line=_line))
try:
new_lines.append(self._format_line(line=_line))
except Exception as err:
self._logger.error(
line=_line,
msg=err,
exc_info=True,
)
raise err
return "".join(new_lines)

def _format_line(self, line: str) -> str:
Expand Down

0 comments on commit c1910ef

Please sign in to comment.