Provide unified logging interface#816
Merged
PeterMatula merged 15 commits intomasterfrom Jul 23, 2020
Merged
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.
Contributor
Author
|
Let's run TeamCity builds |
Contributor
Author
|
Fixed error, let's run TeamCity builds again. |
0c82d8f to
d5898d9
Compare
cf76464 to
8a0fa3a
Compare
added 14 commits
July 22, 2020 13:43
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.
PeterMatula
approved these changes
Jul 23, 2020
|
|
||
| # 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). |
Collaborator
There was a problem hiding this comment.
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.
Member
There was a problem hiding this comment.
Plus the risk of running into conflicts is much lower 🙂
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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:
--silentto 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::decompilerfunction.Logging design:
retdec::utils::io::Logwith functionsinfo(),error(),set(...)that control logging objects. More info in documentation.Log::info() << Log::Color::Yellow << "RetDec module" << std::endlLog::error() << Log::Warning << "Unable to allocate stuff" << std::endlWith 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.