-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use log helper #449
Use log helper #449
Conversation
I hope it is alright to log to stdout, I am uncertain what the result of our discussions on this topic was. Stdout is just easier because on stderr we would also have to worry about warnings (issued using |
da40b41
to
2d66e1f
Compare
Rebased onto current master |
424a68b
to
739cf8a
Compare
739cf8a
to
81f2569
Compare
Required a rebase after merging #365 |
81f2569
to
401ceb6
Compare
Rebased to keep up-to-date. Anything I can do to simplify review/merging? |
Need something like this for when modules are imported by other modules (no main in oletools is run, so no log_helper.enable_logging)
So glad we have the unittests, otherwise would never have found this
This is slightly more complicated since olevba has its own json-print functions that need to be made compatible with log_helper's json formatting
Make log_helper compatible with olevba which has its own print_json function and does not (yet?) use logging to create json.
Logging uses the default StreamHandler, which per default sends its output to sys.stderr. However, the surrounding '[', ']' are printed to stdout. Fix that.
This constant is needed for enable_logging() functions. It is the only reason for `import logging` in common-logging-enabled modules. Easier to provide it in log_helper
This is part of LoggerAdapter only since python 3.2
Do not need the last meta-information return code json output from olevba any more
Help debugging
Logging in mraptor is used for debugging olevba only
VBA stomping warning might occur here
On my test VM this reduces test time for this one test from 33s to 10s
401ceb6
to
b8ba847
Compare
Rebased onto current master |
Thanks :) |
This is a much improved version over PR #447
Starting point is the "TODO: use log_helper" in crypto.py. This lead to using log_helper also in olevba which in turn meant making log_helper and olevba's own json-output compatible.
During work on this I realized that some logging output goes to stdout, some to stderr. Fixed that by making stdout the default for all log output.
As decalage noticed:
enable_logging
functions are required to allow logging output when importing oletools modules from other packages. Added/Updated these for olevba, crypto and record_base. Added a unittest to ensure this works.