Commit Graph

56 Commits

Author SHA1 Message Date
Chris Hennes
67982f3963 Base: Add Console::DestructorError as noexcept
Create a new console output that eats exceptions so it is safe to use in a destructor.
2025-03-25 09:45:25 +01:00
bofdahof
4ceecd0857 Replace std::endl with '\n' 2025-03-21 23:30:41 -05:00
bofdahof
e4ebaba805 Exception.cpp 2025-03-21 22:39:41 -05:00
Chris Hennes
318d6e1555 Base: Stop exception from leaking from Console().*
These are sometimes used in destructors, where a raised exception calls terminate()
2025-02-21 10:56:41 -06:00
wmayer
1d5de9d356 Base: Fix console logging macros
The notifier string must be a std::string() instead of an empty C string as otherwise the wrong methods are called so
    that all messages are sent to the void.

    This regression was caused by commit dc08aa8e0f
2024-03-31 17:38:26 +02:00
Ladislav Michl
f1fdd2e2a9 Base: Replace if else with switch statement 2024-01-21 16:14:12 +01:00
wmayer
08b10cd287 fix cppcoreguidelines-*
* cppcoreguidelines-init-variables
* cppcoreguidelines-c-copy-assignment-signature
* cppcoreguidelines-macro-usage
* cppcoreguidelines-non-private-member-variables-in-classes
* cppcoreguidelines-pro-type-member-init
* cppcoreguidelines-slicing
* cppcoreguidelines-special-member-functions
* cppcoreguidelines-virtual-class-destructor
2023-11-16 01:22:09 +01:00
wmayer
39337ea12e fix bugprone-*
* bugprone-throw-keyword-missing
* bugprone-unhandled-self-assignment
* bugprone-suspicious-string-compare
* bugprone-reserved-identifier
* bugprone-narrowing-conversions
* bugprone-macro-parentheses
* bugprone-implicit-widening-of-multiplication-result
* bugprone-exception-escape
* bugprone-copy-constructor-init
2023-11-16 01:22:09 +01:00
wmayer
85ead154c4 fix readability-make-member-function-const 2023-11-16 01:22:09 +01:00
wmayer
f539138dd9 fix readability-*:
* readability-const-return-type
* readability-container-data-pointer
* readability-container-size-empty
* readability-delete-null-pointer
* readability-else-after-return
* readability-inconsistent-declaration-parameter-name
* readability-redundant-member-init
* readability-redundant-smartptr-get
* readability-redundant-string-cstr
* readability-use-anyofallof
* readability-static-definition-in-anonymous-namespace
* readability-static-accessed-through-instance
* readability-simplify-boolean-expr
2023-11-16 01:22:08 +01:00
wmayer
73a1e90e45 fix readability-identifier-length 2023-11-16 01:22:08 +01:00
wmayer
e85c383bff Base: apply clang format 2023-11-13 12:01:26 -05:00
wmayer
4fb07bcfd6 Base: modernize C++: use default member init 2023-08-23 19:51:44 +02:00
Abdullah Tahiri
dc08aa8e0f Console: Ensure macros have a notifier string 2023-06-01 19:25:00 +02:00
Abdullah Tahiri
cc091b2703 Console: Update loging macros to only send to developers 2023-05-25 14:09:06 +02:00
Abdullah Tahiri
d7ec60c2b4 Console: Improve the documentation 2023-05-23 14:24:45 +02:00
Abdullah Tahiri
cc13da5470 Console: Remove Translated Notification message
===============================================

With the new console extension, the translation state is coded separatedly.

Therefore, it is possible to code a Notification as translated without needing a specific type.

Additionally, any other message, such as Error of Warning can be translated.

It does not make sense to leave this message, if only for reasons of coherence and to simplify
maintainance of code.
2023-05-23 14:24:45 +02:00
Abdullah Tahiri
2bcee570da Console: Extend the Python interface 2023-05-23 14:24:45 +02:00
Abdullah Tahiri
45bf89d977 Console: Convenience dedicated functions 2023-05-23 14:24:45 +02:00
Abdullah Tahiri
e3702ac2d8 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
d06e99ae34 Console: wrong alignment 2023-03-26 11:33:57 +02:00
Abdullah Tahiri
c604d1741d 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
205c6e8931 Base: restore ConsoleSingleton::IsMsgTypeEnabled
For more details see comments on #7457
2022-11-21 23:18:37 +01:00
Uwe
4a2aff82a6 [TD] Gui, Dlg*: remove unused includes
- also sort includes
- also two whitespace changes
2022-10-09 19:14:31 +02:00
berniev
bf1c7eb345 play 2022-09-24 16:35:01 +02:00
wmayer
d2168f51b9 Base: modernize C++: replace 'typedef' with 'using' 2022-08-29 11:42:09 +02:00
marioalexis
eccf4fed96 Base: Clean up code and improve docstrings in Python Console module 2022-07-28 13:30:01 +02:00
wmayer
d0791a9494 Base: help clazy with export macro 2022-07-27 19:09:56 +02:00
wmayer
6384f367d2 Base: [skip ci] change identation in Console.h 2022-03-09 01:04:16 +01:00
wmayer
58a719e207 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
6c1e940b69 Base: use forward declaration instead of including Python.h 2022-03-03 19:18:07 +01:00
Uwe
c08c4c12ef [Base] Console and BaseClass: remove unused includes 2022-02-24 09:34:01 +01:00
Chris Hennes
a0bbb173f4 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
d5f6c096b8 Base: Fix header uniformity, whitespace, and doxygen
[skip ci]
2020-11-22 18:12:16 +01:00
luz.paz
6f11ed298a 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
33b0b1351e [skip ci] suppress -Wgnu-zero-variadic-macro-arguments for some headers 2019-11-13 22:38:09 +01:00
wmayer
f94bf69a3c fix -Winconsistent-missing-override 2019-10-20 13:23:41 +02:00
ezzieyguywuf
f27e4590a6 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
50cefc5104 Console: improve console logging facility 2019-08-17 14:52:08 +02:00
mwganson
3cc93d1961 [enable report view on warnings/erros] add reportoutputobserver class, manage report view visibility via QDocketWidget toggleViewAction() rather than directly with show(), remove unnecessary variables 2019-07-21 15:58:12 +02:00
mwganson
b20dd0da10 Show report view on all warnings or errors by default, can be disabled in preferences 2019-07-21 15:57:57 +02:00
Abdullah Tahiri
95ad7dcee6 MSVC2013 constexpr to const 2019-04-24 17:56:37 +02:00
Abdullah Tahiri
875197f4a1 Base::Console avoid magic numbers and enable external string size checks 2019-04-24 17:56:37 +02:00
wmayer
a9c4bcb5d6 remove kwd argument for functions only with flag METH_VARARGS 2018-08-08 17:39:32 +02:00
wmayer
b298e63bcc + implement direct and queued mode in console class 2018-07-25 17:25:32 +02:00
luz.paz
505488c4f9 Misc. typos
Found via `codespell`
2018-04-25 09:41:33 -03:00
luzpaz
128239b54a Typos: Various workbenches and misc.
[skip ci]
2017-12-25 10:58:10 +01:00
luzpaz
d5d45e2661 fix typos 2017-07-10 19:29:55 -03:00
Zheng, Lei
a6abf0b25a Console: added tag based log support 2017-05-13 17:46:38 +02:00
Ian Rees
f13aac4dd7 Send console Log/Warning/Error to stderr vs stdout 2017-04-08 14:29:02 +02:00