tatuylonen / wikitextprocessor

Python package for WikiMedia dump processing (Wiktionary, Wikipedia etc). Wikitext parsing, template expansion, Lua module execution. For data extraction, bulk syntax checking, error detection, and offline formatting.
Other
90 stars 23 forks source link

Create `Logger` object and set `Logging.DEBUG` level #273

Closed xxyzz closed 3 months ago

xxyzz commented 3 months ago

Our previous code use the root logger configed in wiktextract code, but now wiktextract doesn't use root logger thus all info level logs are not printed.

kristian-clausal commented 3 months ago

I missed this, but I wonder if we need to set a logging level for the wikitextprocessor logger from inside wiktextract? Does INFO get a higher precedence than DEBUG, so INFO and WARNING will get through?

xxyzz commented 3 months ago

info is higher than debug: https://docs.python.org/3/library/logging.html#logging-levels so set level to debug enables info, default level is probably warning.

I think we're current use logging as printf and our default level is debug, so don't combine two packages' logger is simpler. Maybe we could consider how to use the logging library later if we don't want two separate log methods...

kristian-clausal commented 3 months ago

I meant that we might have to modify wikitextprocessor's logger's level, like we do with other loggers. It is correct to have two different loggers for wiktextract and wikitextprocessor, because they're two packages.

xxyzz commented 3 months ago

I'll pass the --verbose bool command option to Wtp.__init__, and set the logger debug level if it's False so we'll have the save level in two packages.

xxyzz commented 3 months ago

I added an extra not and wiktextract uses the --quiet option to set the debug log level.