Skip to content

Commit

Permalink
Log why entities are privatized in more detail.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartfeenstra committed Dec 29, 2023
1 parent a3fd5a7 commit 12878ad
Show file tree
Hide file tree
Showing 28 changed files with 240 additions and 194 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ Options:
Defaults to betty.json|yaml|yml in the current
working directory. This will make additional
commands available.
-v, --verbose Show verbose output, including debug log messages.
-vv, --more-verbose Show more verbose output, including all log
-v, --verbose Show verbose output, including informative log
messages.
-vv, --more-verbose Show more verbose output, including debug log
messages.
-vvv, --most-verbose Show most verbose output, including all log
messages.
--version Show the version and exit.
--help Show this message and exit.
Expand Down
8 changes: 7 additions & 1 deletion betty/assets/betty.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Betty VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-12-28 23:21+0000\n"
"POT-Creation-Date: 2023-12-29 01:05+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -587,6 +587,9 @@ msgstr ""
msgid "Presence"
msgstr ""

msgid "Presence of {person} at {event}"
msgstr ""

msgid "Presences"
msgstr ""

Expand All @@ -596,6 +599,9 @@ msgstr ""
msgid "Primary color (inactive)"
msgstr ""

msgid "Privatized person {privatized_person_id} ({privatized_person}) because they are likely still alive."
msgstr ""

msgid "Privatized {count} people because they are likely still alive."
msgstr ""

Expand Down
10 changes: 9 additions & 1 deletion betty/assets/locale/fr-FR/betty.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-12-28 23:21+0000\n"
"POT-Creation-Date: 2023-12-29 01:05+0000\n"
"PO-Revision-Date: 2020-11-27 19:49+0100\n"
"Last-Translator: \n"
"Language: fr\n"
Expand Down Expand Up @@ -668,6 +668,9 @@ msgstr ""
msgid "Presence"
msgstr ""

msgid "Presence of {person} at {event}"
msgstr ""

msgid "Presences"
msgstr ""

Expand All @@ -677,6 +680,11 @@ msgstr ""
msgid "Primary color (inactive)"
msgstr ""

msgid ""
"Privatized person {privatized_person_id} ({privatized_person}) because "
"they are likely still alive."
msgstr ""

msgid "Privatized {count} people because they are likely still alive."
msgstr ""

Expand Down
17 changes: 13 additions & 4 deletions betty/assets/locale/nl-NL/betty.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-12-28 23:21+0000\n"
"POT-Creation-Date: 2023-12-29 01:05+0000\n"
"PO-Revision-Date: 2022-04-08 01:58+0100\n"
"Last-Translator: \n"
"Language: nl\n"
Expand Down Expand Up @@ -703,6 +703,9 @@ msgstr ""
msgid "Presence"
msgstr "Aanwezigheid"

msgid "Presence of {person} at {event}"
msgstr "Aanwezigheid van {person} bij {event}"

msgid "Presences"
msgstr "Aanwezigheden"

Expand All @@ -712,8 +715,14 @@ msgstr "Primaire kleur (actief)"
msgid "Primary color (inactive)"
msgstr "Primaire kleur (inactief)"

msgid ""
"Privatized person {privatized_person_id} ({privatized_person}) because "
"they are likely still alive."
msgstr "Persoon {privatized_person_id} ({privatized_person}) geprivatiseerd omdat "
"men waarschijnlijk nog leeft."

msgid "Privatized {count} people because they are likely still alive."
msgstr ""
msgstr "{count} personen geprivatiseerd omdat zij waarschijnlijk nog leven."

msgid ""
"Privatized {count} {entity_type}, because they are associated with "
Expand All @@ -725,8 +734,8 @@ msgid ""
"({privatized_entity}) because of {reason_entity_type} {reason_entity_id} "
"({reason_entity})."
msgstr ""
"{privatized_entity_type} {privatized_entity_id} "
"({privatized_entity}) geprivatiseerd vanwege {reason_entity_type} {reason_entity_id} "
"{privatized_entity_type} {privatized_entity_id} ({privatized_entity}) "
"geprivatiseerd vanwege {reason_entity_type} {reason_entity_id} "
"({reason_entity})."

msgid "Privatizer"
Expand Down
10 changes: 9 additions & 1 deletion betty/assets/locale/uk/betty.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Betty VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-12-28 23:21+0000\n"
"POT-Creation-Date: 2023-12-29 01:05+0000\n"
"PO-Revision-Date: 2020-05-02 22:29+0100\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: uk\n"
Expand Down Expand Up @@ -668,6 +668,9 @@ msgstr ""
msgid "Presence"
msgstr ""

msgid "Presence of {person} at {event}"
msgstr ""

msgid "Presences"
msgstr ""

Expand All @@ -677,6 +680,11 @@ msgstr ""
msgid "Primary color (inactive)"
msgstr ""

msgid ""
"Privatized person {privatized_person_id} ({privatized_person}) because "
"they are likely still alive."
msgstr ""

msgid "Privatized {count} people because they are likely still alive."
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion betty/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ def __init__(self, localizer: Localizer):
async def clear(self) -> None:
with suppress(FileNotFoundError):
shutil.rmtree(fs.CACHE_DIRECTORY_PATH)
logging.getLogger().info(self._localizer._('All caches cleared.'))
logging.getLogger(__name__).info(self._localizer._('All caches cleared.'))
62 changes: 32 additions & 30 deletions betty/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def catch_exceptions() -> Iterator[None]:
sys.exit(0)
pass
except Exception as e:
logger = logging.getLogger()
logger = logging.getLogger(__name__)
if isinstance(e, UserFacingError):
logger.error(str(e))
else:
Expand Down Expand Up @@ -93,10 +93,8 @@ async def _init_ctx_app(
return
ctx.obj['initialized'] = True

logger = logging.getLogger()
if logger.level > logging.INFO:
logger.setLevel(logging.INFO)
logger.addHandler(CliHandler())
logging.getLogger().addHandler(CliHandler())
logger = logging.getLogger(__name__)

app = App()
ctx.obj['commands'] = {
Expand Down Expand Up @@ -143,26 +141,20 @@ async def _init_ctx_app(
))


def _init_ctx_verbose(
ctx: Context,
__: Option | Parameter | None = None,
verbose: bool = False,
) -> None:
if verbose:
logger = logging.getLogger()
if logger.level > logging.DEBUG:
logger.setLevel(logging.DEBUG)


def _init_ctx_more_verbose(
ctx: Context,
__: Option | Parameter | None = None,
more_verbose: bool = False,
) -> None:
if more_verbose:
logger = logging.getLogger()
if logger.level > logging.NOTSET:
logger.setLevel(logging.NOTSET)
def _build_init_ctx_verbosity(
logger_name: str | None,
logger_level: int,
) -> Callable[[Context, Option | Parameter | None, bool], None]:
def _init_ctx_verbosity(
ctx: Context,
__: Option | Parameter | None = None,
is_verbose: bool = False,
) -> None:
if is_verbose:
logger = logging.getLogger(logger_name)
if logger.getEffectiveLevel() > logger_level:
logger.setLevel(logger_level)

Check warning on line 156 in betty/cli.py

View check run for this annotation

Codecov / codecov/patch

betty/cli.py#L154-L156

Added lines #L154 - L156 were not covered by tests
return _init_ctx_verbosity


class _BettyCommands(click.MultiCommand):
Expand Down Expand Up @@ -194,8 +186,8 @@ def get_command(self, ctx: Context, cmd_name: str) -> Command | None:
is_eager=True,
default=False,
is_flag=True,
help='Show verbose output, including debug log messages.',
callback=_init_ctx_verbose,
help='Show verbose output, including informative log messages.',
callback=_build_init_ctx_verbosity('betty', logging.INFO),
)
@click.option(
'-vv',
Expand All @@ -204,11 +196,21 @@ def get_command(self, ctx: Context, cmd_name: str) -> Command | None:
is_eager=True,
default=False,
is_flag=True,
help='Show more verbose output, including all log messages.',
callback=_init_ctx_more_verbose,
help='Show more verbose output, including debug log messages.',
callback=_build_init_ctx_verbosity('betty', logging.DEBUG),
)
@click.option(
'-vvv',
'--most-verbose',
'most_verbose',
is_eager=True,
default=False,
is_flag=True,
help='Show most verbose output, including all log messages.',
callback=_build_init_ctx_verbosity('betty', logging.NOTSET),
)
@click.version_option(about.version_label(), message=about.report(), prog_name='Betty')
def main(app: App, verbose: bool, more_verbose: bool) -> None:
def main(app: App, verbose: bool, more_verbose: bool, most_verbose: bool) -> None:
pass


Expand Down
2 changes: 1 addition & 1 deletion betty/deriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(
self._localizer = localizer

async def derive(self) -> None:
logger = logging.getLogger()
logger = logging.getLogger(__name__)
for derivable_event_type in self._derivable_event_type:
created_derivations = 0
updated_derivations = 0
Expand Down
Loading

0 comments on commit 12878ad

Please sign in to comment.