-
Notifications
You must be signed in to change notification settings - Fork 445
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
Floss python library disables all other loggers #291
Comments
Hey @capnspacehook We're really excited to hear that you're integrating FLOSS with Cuckoo; please let us know whatever we can do to assist! We've tried to design FLOSS in such a way that it can be used as a stand alone tool, or as a library. Therefore, your use case is perfectly valid. Our design for I would discourage you from invoking For example, internally at FireEye, we run FLOSS against all the malware we encounter on a daily basis. We have a custom script that invokes the FLOSS library, using the helpers in main to set things up, yet configuring the input/output formats slightly differently (JSON in, JSON out). It looks something like this:
|
Thanks for the detailed answer @williballenthin. I'm really excited to have the opportunity to work on these two amazing projects! I'm not actually importing or invoking floss.main.main(), and as I said above, floss.main.set_logging_level() is the only function that I see that will allow me to set Floss's logging level. I'm not sure how I would set Floss's logging level without using the floss.main.set_logging_level() function, which has the problems I mentioned above. I also can't just add |
Ah, right. Reading your initial comment a bit closer, I see this:
I think this is the expected way to configure the loggers. Its a bit of an exercise to figure out all the available loggers (in fact, I'm not sure how you're supposed to do this for a library, except by trial and error), but does allow for the most configurability. Grepping through the FLOSS source code, I see the following loggers:
And the loggers from libraries on which FLOSS depends:
I'd recommend either:
Do you have any ideas for how the logging might be better exposed/configured? |
@williballenthin The This would allow @capnspacehook to set his own basisconfig, log floss components how he wants to, and have a one-shot function that he can call to set all the misc library stuff to sane values without having to manage all those loggers himself. |
I guess for now I will just set all the loggers manually. That does work, though as you said it requires a bit of trial and error discovering all of the loggers. I was actually just going to say something like that @williamgibb. You hit the nail on the head there. |
@capnspacehook A PR for doing that should be... 2 lines of code? One to define the new function header and one to call said function from within the end of |
Well @williamgibb I would like for the new function to sets ALL of Floss's loggers to the value the user provides. So it would be more than just 2 lines, but I would be happy to submit a PR for that :) |
🎉 |
I've been working on integrating Floss with Cuckoo Sandbox, and I've come to a bit of a problem. When running Floss, the Cuckoo logs show extremely verbose logging information from Floss. When I tried to disable this behavior by using the floss.main.set_logging_level() function, it disabled Floss's logging, as by default it sets Floss's loggers to ERROR or CRITICAL levels, but it killed all of Cuckoo's logging as well.
After perusing the Floss's source, I found the problem in main.py at lines 214-217:
set_logging_level() removes all handlers of the root logger. So, if Floss is used as a library in an existing project with logging, there is no easy way to change Floss's logging level without killing all other logging, or by setting the level of the 10 or so loggers that are associated with Floss manually.
I would suggest that maybe set_logging_level() could be revised to take an additional argument that would determine if the root logger's handles are removed. This would allow for other projects to integrate with Floss more easily. I was going to do just that and make a pull request, but if the root logger has handlers, calling logging.basicConfig() in lines 219-224 would have no effect.
I'm not sure as of how to set Floss's logging level globally without using logging.basicConfig(), do you guys have any ideas?
The text was updated successfully, but these errors were encountered: