From 45bf89d977e195124eed22e19f40d2d035277f84 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 21 May 2023 14:47:47 +0200 Subject: [PATCH] Console: Convenience dedicated functions --- src/Base/Console.h | 78 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/src/Base/Console.h b/src/Base/Console.h index f7b68ee011..77657b5157 100644 --- a/src/Base/Console.h +++ b/src/Base/Console.h @@ -501,6 +501,16 @@ public: virtual ~ILogger() = 0; /** Used to send a Log message at the given level. + * @param notifiername A string identifying the entity generating the notification. + * It may be the Label of the App::Document or the full label of the App::DocumentObject. + * @param msg The message to be notified. + * @param level A valid level (Log, Message, Error, Notification, CriticalNotification, ...) + * @param recipient A valid intended recipient (All, Developer, User). + * Observers may decide to process only notifications when a certain recipient is intended. + * @param content A valid content property (Untranslated, Translatable, Untranslatable). + * Observers may decide not to process notifications if they are not translated or cannot be + * translated (are untranslatable). Or conversely, may decide not to process already translated + * notifications. It is up to the intended behaviour of the observer. */ virtual void SendLog(const std::string& notifiername, const std::string& msg, LogStyle level, IntendedRecipient recipient, ContentType content) = 0; @@ -607,9 +617,21 @@ public: /// Prints a warning Message with source indication template inline void Warning (const std::string & notifier, const char * pMsg, Args&&... args); + template + inline void DeveloperWarning (const std::string & notifier, const char * pMsg, Args&&... args); + template + inline void UserWarning (const std::string & notifier, const char * pMsg, Args&&... args); + template + inline void TranslatedUserWarning (const std::string & notifier, const char * pMsg, Args&&... args); /// Prints a error Message with source indication template inline void Error (const std::string & notifier, const char * pMsg, Args&&... args); + template + inline void DeveloperError (const std::string & notifier, const char * pMsg, Args&&... args); + template + inline void UserError (const std::string & notifier, const char * pMsg, Args&&... args); + template + inline void TranslatedUserError (const std::string & notifier, const char * pMsg, Args&&... args); /// Prints a log Message with source indication template inline void Log (const std::string & notifier, const char * pMsg, Args&&... args); @@ -833,6 +855,30 @@ inline void Base::ConsoleSingleton::Warning( const std::string & notifier, const Send(notifier, pMsg, std::forward(args)...); } +template +inline void Base::ConsoleSingleton::DeveloperWarning( const std::string & notifier, const char * pMsg, Args&&... args ) +{ + Send(notifier, pMsg, std::forward(args)...); +} + +template +inline void Base::ConsoleSingleton::UserWarning( const std::string & notifier, const char * pMsg, Args&&... args ) +{ + Send(notifier, pMsg, std::forward(args)...); +} + +template +inline void Base::ConsoleSingleton::TranslatedUserWarning( const std::string & notifier, const char * pMsg, Args&&... args ) +{ + Send(notifier, pMsg, std::forward(args)...); +} + template inline void Base::ConsoleSingleton::Error( const char * pMsg, Args&&... args ) { @@ -845,6 +891,30 @@ inline void Base::ConsoleSingleton::Error( const std::string & notifier, const c Send(notifier, pMsg, std::forward(args)...); } +template +inline void Base::ConsoleSingleton::DeveloperError( const std::string & notifier, const char * pMsg, Args&&... args ) +{ + Send(notifier, pMsg, std::forward(args)...); +} + +template +inline void Base::ConsoleSingleton::UserError( const std::string & notifier, const char * pMsg, Args&&... args ) +{ + Send(notifier, pMsg, std::forward(args)...); +} + +template +inline void Base::ConsoleSingleton::TranslatedUserError( const std::string & notifier, const char * pMsg, Args&&... args ) +{ + Send(notifier, pMsg, std::forward(args)...); +} + template inline void Base::ConsoleSingleton::Critical( const char * pMsg, Args&&... args ) { @@ -866,7 +936,9 @@ inline void Base::ConsoleSingleton::UserNotification( const char * pMsg, Args&&. template inline void Base::ConsoleSingleton::UserNotification( const std::string & notifier, const char * pMsg, Args&&... args ) { - Send(notifier, pMsg, std::forward(args)...); + Send(notifier, pMsg, std::forward(args)...); } template @@ -878,7 +950,9 @@ inline void Base::ConsoleSingleton::UserTranslatedNotification( const char * pMs template inline void Base::ConsoleSingleton::UserTranslatedNotification( const std::string & notifier, const char * pMsg, Args&&... args ) { - Send(notifier, pMsg, std::forward(args)...); + Send(notifier, pMsg, std::forward(args)...); } template