Commit Graph

48 Commits

Author SHA1 Message Date
Abdullah Tahiri
3b82bf62f7 Console: Extend the Python interface 2023-05-23 14:24:45 +02:00
Abdullah Tahiri
9d9f928b2d Console: Extend framework with intended recipient and content type metainformation
==================================================================================

Limitations of the current framework:
- Codes the translated state only for TranslatedNotification as part of the type.
- Does not code the intended recipient (user, developer, ...)

Problems:
- Some errors are intended for developers, some errors may only be intended for users,
if, for example, there is another developer error which already contains all the information.
The current framework may lead to information duplication or to showing to the user developer
information, which is perceived as annoying.
- Logs shall be in English (report view), while every message to the user (UI) shall be translated.
The current framework can only differentiate where to report based on subscription (legacy logs do not
subscribe to notifications), and for notifications, whether it is translated or not depends on the type.
It is not possible to code errors or warnings that are already translated.

Solution:
- To extend the ILogger interface with additional metainformation, indicating the intended recipient
(User, Developer, All), and the content of the message (translated, untranslated, untranslatable). The latter
is useful for dynamic strings that won't find a match in the translation framework.

Bonus:
- This extended version allows to do away with translatednotification, as now any message can be independently
marked as translated or untranslated or untraslatable.
- It is now possible to provide the right icon of severity (error, warning, info), even when it is only user intended
and already translated.
2023-05-23 14:24:45 +02:00
Abdullah Tahiri
ee0c3ad5c1 Console/ILogger: Refactor and extension
=======================================

Refactor:
 - Substitute the use of variadic templates with parameter packs.
 - Use recently incorporated external library "fmt" to handle printf like formating.
 - Extensive cleaning of pragmas and unnecessary forward declarations.
 - Parameter packs and libfmt provide a much stronger type checking now, so
   conversions that are by standard implicit as bool to int need an explicit static_cast
   to avoid compilation warnings.

Extension:
 - Include a notifier field, so that the originator of the message can be provided. E.g. Document#DocumentObject
 - Include a new type of message called CriticalMessage, this message is intended to have
   special behaviour in the future. Namely, it will be used to notify forward compatilibity issues.
   It will be used to substitute the current signal/slot mechanism.
 - Include two new types of messages for user notifications (Notification and TranslatedNotification). This messages
   will be use to convey UI notifications intended for the user (such as non-intrusive message about the usage of a tool). There
   are two versions to mark whether the string provided as a message is already translated or not. When using the console system for
   notifications, these notifications may originate from the App or the Gui. In the former, it is generally the case that the strings
   of messages are not (yet) translated (but they can be marked with QT_TRANSLATE_NOOP). In the latter, often the messages to be provided
   are already translated.

Python support for CriticalMessage, Notification and TranslatedNofification, including shortcuts:

    Crt = FreeCAD.Console.PrintCritical
    Ntf = FreeCAD.Console.PrintNotification
    Tnf = FreeCAD.Console.PrintTranslatedNotification
2023-03-07 16:13:23 +01:00
wmayer
cd3960f456 Base: restore ConsoleSingleton::IsMsgTypeEnabled
For more details see comments on #7457
2022-11-21 23:18:37 +01:00
berniev
86eab9aa77 play 2022-09-24 16:35:01 +02:00
wmayer
d92eaf7a72 Base: fix several warnings reported by code analyzers 2022-08-02 13:04:50 +02:00
berniev
15419982d4 Base: Modernise ctors dtors defs etc 2022-08-02 12:37:46 +02:00
wmayer
f9bdc3aca7 App: use namespace prefix for classes in Base 2022-07-28 14:18:12 +02:00
wmayer
4101ab23bb Base: replace C macro with function and lambda expressions 2022-07-28 13:49:03 +02:00
marioalexis
c38a6759d9 Base: Clean up code and improve docstrings in Python Console module 2022-07-28 13:30:01 +02:00
Zheng, Lei
8bec44934b Fix mixed line endings 2022-04-26 12:52:55 -05:00
Chris Hennes
b5c72abee4 Base: PR6497 move return statement to new line 2022-03-29 12:34:34 -05:00
wmayer
e4d1ed8366 Base: rename BaseExceptionFreeCADError to PyExc_FC_GeneralError 2022-03-17 14:45:48 +01:00
wmayer
08b77bff08 Core/Mod: modernize C++11
* use nullptr
2022-03-09 21:55:31 +01:00
wmayer
18a7cc8d18 Base: [skip ci] change identation in Console.h 2022-03-09 01:04:16 +01:00
wmayer
91e4e468dd Base: move ILogger sub-classes to their own source files in order to reduce including stream classes in client code 2022-03-06 10:13:47 +01:00
wmayer
6ff1ccb140 Base: use forward declaration instead of including Python.h 2022-03-03 19:18:07 +01:00
Uwe
832a6eb43b [Base] Console and BaseClass: remove unused includes 2022-02-24 09:34:01 +01:00
luz paz
59b7e9fdd0 Base: remove Py2 code 2021-04-26 09:23:58 +02:00
Chris Hennes
52e861b181 LGTM: Remove unused Time() function
The ConsoleSingleton::Time() function is flagged by LGTM for using
two different unsafe time-related functions. It is not called anywhere
in the current codebase, and is not exposed in the Python API, so was
removed rather than being repaired.
2021-02-11 12:51:31 +01:00
luz paz
01b21e0d06 Base: Fix header uniformity, whitespace, and doxygen
[skip ci]
2020-11-22 18:12:16 +01:00
wmayer
4b8cf63c14 [skip ci] improve possibility to create a QApplication in a thread 2020-06-21 00:07:21 +02:00
luz.paz
ae72e2c762 Trivial code formatting for some {.cpp,.h} files 2020-04-06 12:55:27 +02:00
luz.paz
011e5aedfa src/Base: [skip ci] fix header uniformity
This PR fixes header uniformity across all `src/Base` files
2019-12-25 11:38:58 +01:00
wmayer
77bc9cd8d5 restore old behaviour of Python wrapper of Console class to increase flexibility when using in worker threads 2019-10-20 13:51:53 +02:00
wmayer
4a6b80dbb6 in RedirectStdOutput/RedirectStdError/RedirectStdLog only flush when last character is newline to avoid garbled output in log file 2019-10-20 13:42:51 +02:00
wmayer
5ba9bc6a16 minor optimization in ConsoleObserverFile, if prefix is unknown then still write passed message 2019-10-20 12:52:08 +02:00
ezzieyguywuf
9fcc18b08e Refactor and rename ConsoleObserver...
...Renamed to "ILogger", to designate that this is an Interface for a
Logger. This "Interface" is pure virtual, so that it cannot be
instantiated directly. This makes it clear that it is intended to be
derived.

Finally, got rid of all the individual log-style methods and replaced
with SendLog. The idea here is that day-to-day users will only interact
with ILogger through ConsoleSingleton (or, likely, LoggerSingleton in
the future). This singleton will manage an arbirtary collection of
ILogger, and call SendLog with the appropriate parameters based on what
the user requests.

Therefore, the singleton itself will have the individual Log, Message,
Error, etc... methods, while stil allowing us to simplify the code base
of ILogger and its derived classes.
2019-10-20 11:46:15 +02:00
Zheng, Lei
14fedb0965 Base: fix verbose checking in Console::Log() 2019-09-10 14:17:06 +02:00
Zheng, Lei
bfa68f2676 Console: improve console logging facility 2019-08-17 14:52:08 +02:00
Abdullah Tahiri
2eb5c70147 Base::Console avoid magic numbers and enable external string size checks 2019-04-24 17:56:37 +02:00
wmayer
b2a5f47e44 PVS: V560 A part of conditional expression is always true 2019-02-17 13:56:48 +01:00
wmayer
ddfa3c8843 remove kwd argument for functions only with flag METH_VARARGS 2018-08-08 17:39:32 +02:00
wmayer
1f2302141d + implement direct and queued mode in console class 2018-07-25 17:25:32 +02:00
wmayer
13b0bdb6a6 fix build failure on FreeBSD, support colored output to terminal 2017-06-18 12:26:05 +02:00
Yorik van Havre
ccebc7d16b py3: Base: files A-I ported to python3
issue 0000995
2017-05-17 16:39:28 +02:00
Zheng, Lei
f14ef7058d Console: added tag based log support 2017-05-13 17:46:38 +02:00
Ian Rees
8c40bb0ca2 Send console Log/Warning/Error to stderr vs stdout 2017-04-08 14:29:02 +02:00
Ian Rees
c30ce1a62d Linux/MacOS - only write colour codes to TTYs
This prevents the colour codes from showing up in piped output, file
redirects, etc.
2017-04-08 14:29:02 +02:00
Ian Rees
a8eb80ea49 Use colour output from main executable on MacOS 2017-04-08 14:29:02 +02:00
Kunda
de2392eb18 source typo fixes pt5
+ cleaning up some more non-short-URLs
Issue #2914
2017-03-04 13:07:13 -03:00
wmayer
de41dc46ec + Prefer prefix ++/-- operators for non-primitive types 2015-10-07 13:38:17 +02:00
Mateusz Skowroński
05f95c0506 Fix files encoding. Go from ISO8859-1 to UTF-8. 2015-09-21 19:50:49 -03:00
wmayer
896b566dd9 + test command to show race conditions in Console class
+ fix race conditions in Console class
2015-08-13 18:57:52 +02:00
Sebastian Hoogen
d49528b27e issue #1700 replace PyExc_Exception 2014-09-17 11:15:57 +02:00
Sebastian Hoogen
2583e50ea0 flush stdout after reseting the console color 2014-08-18 13:11:16 +02:00
wmayer
be9a76c797 Add method to check if console mode is on/off 2013-07-23 13:27:02 +02:00
wmayer
120ca87015 + unify DLL export defines to namespace names
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5000 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
2011-10-10 13:44:52 +00:00