Skip to content

Commit

Permalink
doc: add todo about std::source_location for logMessage
Browse files Browse the repository at this point in the history
Co-authored-by: Loïc Bartoletti <lbartoletti@users.noreply.github.com>
  • Loading branch information
benoitdm-oslandia and lbartoletti committed Jan 27, 2025
1 parent 295a237 commit 7fc95bb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
7 changes: 0 additions & 7 deletions python/PyQt6/core/auto_generated/qgsmessagelog.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ window for the user.

static void logMessage( const QString &message, const QString &tag = QString(), Qgis::MessageLevel level = Qgis::MessageLevel::Warning, bool notifyUser = true,
const char *file = __builtin_FILE(), const char *function = __builtin_FUNCTION(), int line = __builtin_LINE() );
%Docstring
Adds a ``message`` to the log instance (and creates it if necessary).

If ``notifyUser`` is ``True``, then the message should be brought to the user's attention by various UI hints.
If it is ``False``, the message should appear in logs silently. Note that log viewer implementations may
only respect notification hints for certain message levels.
%End

signals:

Expand Down
7 changes: 0 additions & 7 deletions python/core/auto_generated/qgsmessagelog.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ window for the user.

static void logMessage( const QString &message, const QString &tag = QString(), Qgis::MessageLevel level = Qgis::MessageLevel::Warning, bool notifyUser = true,
const char *file = __builtin_FILE(), const char *function = __builtin_FUNCTION(), int line = __builtin_LINE() );
%Docstring
Adds a ``message`` to the log instance (and creates it if necessary).

If ``notifyUser`` is ``True``, then the message should be brought to the user's attention by various UI hints.
If it is ``False``, the message should appear in logs silently. Note that log viewer implementations may
only respect notification hints for certain message levels.
%End

signals:

Expand Down
8 changes: 8 additions & 0 deletions src/core/qgsmessagelog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ class CORE_EXPORT QgsMessageLog : public QObject
* If it is FALSE, the message should appear in logs silently. Note that log viewer implementations may
* only respect notification hints for certain message levels.
*/
// TODO: Update this code to use std::source_location from C++20 when transitioning to a fully C++20-compliant codebase.
// Currently, we rely on __builtin_XXX functions (e.g., __builtin_FILE(), __builtin_LINE()),
// which have been successfully tested across multiple systems (Windows, macOS, Linux, FreeBSD)
// and compilers (LLVM, GCC, MSVC).
// Note: We tested with LLVM on FreeBSD and macOS, and std::experimental::source_location is not available.
// It works fine with GNU. It also seems unavailable with MSVC.
// For now, we stick with __builtin_XXX because it is "portable" and functional across all tested environments.
// We'll switch to std::source_location once the transition to C++20 is complete.
static void logMessage( const QString &message, const QString &tag = QString(), Qgis::MessageLevel level = Qgis::MessageLevel::Warning, bool notifyUser = true,
const char *file = __builtin_FILE(), const char *function = __builtin_FUNCTION(), int line = __builtin_LINE() );

Expand Down

0 comments on commit 7fc95bb

Please sign in to comment.