-
Notifications
You must be signed in to change notification settings - Fork 940
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
Provide unified logging interface #816
Conversation
Provides new logging interface that is ment to unify output that is produced in each part of RetDec decompiler. The interface is designed to provide eazy management of logging into files/tty. Currently each module od decompiler manages logging on its own. This is not sustainable state as change to logging interface is rather difficult.
Let's run TeamCity builds |
Fixed error, let's run TeamCity builds again. |
0c82d8f
to
d5898d9
Compare
cf76464
to
8a0fa3a
Compare
This module is now obsolete as all logging mechanisms have been transferred to retdec::io module.
Provides new option [-s|--silent] for retdec-decompiler executable. This option will force retdec not to output anything on stdout.
Provides way to specify Log/Error files to RetDec. This is useful for RetDec plugins that might this way control decompilation output.
Fixes bug provided by fbbff34.
Provides change to log interface. Before this commit logging was done on global objects. Now the logging should be made on temporary objects that are returned from special functions. The reason for this is for usage of colors on output. When temporary object is destructed default color is printed on required interface.
This way we can avoid not intentional usage of the Log interface. All functions of Log are ment to be used like: Log::info() Log::debug() Log::error()
Starting Windows aniversary update Windows terminals provide supprot for ANSI colors. This, however, needs to be enabled manually. More about this can be found here: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences?redirectedfrom=MSDN
Provides substitution of __has_include macro to OS_WINDOWS defined in utils/os.h. The reason for this is to maintain a level of consistency in RetDec source code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice.
@@ -2,6 +2,7 @@ | |||
|
|||
# dev | |||
|
|||
* Enhancement: Unified logging on stdout/stderr. Added option `--silent`. Printed text is colored only when output is a terminal ([#791](https://github.com/avast/retdec/issues/791). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @s3rvac suggested in some other place, it is better to add these entries after the merge to master
. It is then possible to reference the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus the risk of running into conflicts is much lower 🙂
In this PR I would like to introduce changes to the RetDec decompiler logging system. Before these changes each module controlled output on stdout/stderr on its own.
High-level changes:
--silent
to turn of logging on stdout."logFile"
to the retdec config."errFile"
to the retdec config.Changes above are particularly useful for users of the RetDec library. Before this PR there was no easy way to redirect RetDec's output when decompilation was called from
retdec::decompiler
function.Logging design:
retdec::utils::io::Log
with functionsinfo()
,error()
,set(...)
that control logging objects. More info in documentation.Log::info() << Log::Color::Yellow << "RetDec module" << std::endl
Log::error() << Log::Warning << "Unable to allocate stuff" << std::endl
With these changes, colors on output are managed in RetDec (before we used LLVM library). Logger class implemented to print output uses ANSI encoding for colors. This is supported on all POSIX terminals and Windows terminals following the Anniversary update. Changes were tested on Linux, macOS, and Windows. Colors are automatically disabled when output is not a terminal.