Enable more flexible logging redirection #1456
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Modified logger setup to allow more flexible logging redirection and multiplexing.
Interface changes
The current interface in which
log_file
is used to optionally specify a filename to log into:Was changed into an optional variable that accepts a
Collection
of either filenames or open streams:Notes
sys.stderr
logger, the new implementation replaces it. That is, if a list of log devices is specified there would be be nosys.stderr
logger by default anymore, unless it is specified (as seen in the example above)log_file
/log_devices
) is maintained: onlysys.stderr
will be createdCollection
, such aslog_devices=[]
, would result in no logger (same as settingconsole=False
)console
argument has no use anymore. However theconsole
argument was not removed to maintain compatibility and maybe will be used in the future for other purposesAdvantages
It is now way easier to open multiple loggers and redirect them to any file, stream or socket. This is very useful when trying to separate the emulated program output from logging output, or enable logging while fuzzing (which is currently hidden "behind" AFL box).
In the following example the logging output is redirected to another terminal pane to separate program output from logging output: