-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow per scanner logging config
The following setup is now possible when scanners are run in own scripts: import gallia import gallia.log import gallia.command logger = gallia.log.get_logger("gallia") class Scanner1(gallia.command.Script): def main(self) -> None: logger.info(f"hi {self.__class__.__name__}") logger.error("error") logger.warning("warning") logger.notice("notice") logger.info("info") logger.debug("debug") logger.trace("trace") class Scanner2(gallia.command.Script): def main(self) -> None: logger.info(f"hi {self.__class__.__name__}") if __name__ == "__main__": # Each scanner sets up its own logging setup # with a logger called `gallia`. Scanner1().entry_point() Scanner2().entry_point() # Alternatively, a context manager can be used # for more fine grained control. with gallia.log.setup_logging( logger_name="gallia", stderr_level=gallia.log.Loglevel.DEBUG, logfile="test.log.zst", ) as h: Scanner1(logging_handler=h).entry_point() Scanner2(logging_handler=h).entry_point()
- Loading branch information
1 parent
07fc65e
commit 63c137e
Showing
6 changed files
with
241 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.