Merge branch 'log-enable-mt-safe' into master

Minor improvements to logging MT-safety.

See #23054.
This commit is contained in:
Vadim Zeitlin 2022-12-23 19:43:17 +01:00
commit 795190ffbe
2 changed files with 20 additions and 7 deletions

View file

@ -384,6 +384,9 @@ public:
All messages at levels strictly greater than the value returned by this
function are not logged at all.
Note that this function is *not* thread-safe and should only be used
from the main thread.
@see SetLogLevel(), IsLevelEnabled()
*/
static wxLogLevel GetLogLevel();
@ -395,6 +398,9 @@ public:
@a level is less than or equal to the maximal log level enabled for the
given @a component.
Note that this function is *not* thread-safe and should only be used
from the main thread.
@see IsEnabled(), SetLogLevel(), GetLogLevel(), SetComponentLevel()
@since 2.9.1
@ -427,6 +433,10 @@ public:
Specifies that log messages with level greater (numerically) than
@a logLevel should be ignored and not sent to the active log target.
Note that this function is *not* thread-safe and can only be called
from the main thread. To temporarily disable logging from the other
threads, use wxLogNull, which is safe to use from them.
@see SetComponentLevel()
*/
static void SetLogLevel(wxLogLevel logLevel);
@ -446,6 +456,9 @@ public:
Calling this function with @false argument disables all log messages
for the current thread.
This function is thread-safe and can be called by multiple threads
concurrently.
@see wxLogNull, IsEnabled()
@return
@ -457,6 +470,9 @@ public:
/**
Returns true if logging is enabled at all now.
This function is thread-safe and can be called by multiple threads
concurrently.
@see IsLevelEnabled(), EnableLogging()
*/
static bool IsEnabled();
@ -937,6 +953,8 @@ public:
}
@endcode
This class is thread-safe and can be used from both the main and the
backgrounds threads.
@library{wxbase}
@category{logging}

View file

@ -146,14 +146,9 @@ static inline wxUint16 CrackUint16(const char *m)
static wxFileOffset QuietSeek(wxInputStream& stream, wxFileOffset pos)
{
#if wxUSE_LOG
wxLogLevel level = wxLog::GetLogLevel();
wxLog::SetLogLevel(wxLOG_Debug - 1);
wxFileOffset result = stream.SeekI(pos);
wxLog::SetLogLevel(level);
return result;
#else
return stream.SeekI(pos);
wxLogNull noLog;
#endif
return stream.SeekI(pos);
}