Commit Graph

207 Commits

Author SHA1 Message Date
Arrigo Marchiori
c86bcf962d Use wxASCII_STR() on string literals
Fix the build with wxNO_IMPLICIT_WXSTRING_ENCODING.
2020-07-17 17:52:16 +02:00
Vadim Zeitlin
d7f19ee610 Fix spelling in comments and documentation using codespell
Apply the utility from https://github.com/codespell-project/codespell/
to fix spelling issues in the headers under both include and interface
directories and add a file with a couple of exceptions.

The exact command line used was:

    $ codespell -w -I misc/scripts/codespell.ignore -i 3 in*
2020-06-27 22:56:22 +02:00
Vadim Zeitlin
71ed744c76 Simplify wxLogXXX() macros implementation at some cost of brevity
Avoid using plenty of intermediate macros, which made the code quite
difficult to understand and just wxDO_IF() helper directly instead.

This makes individual macros definitions slightly longer, but allows to
get rid of several helper macros, so the total number of lines is
actually smaller but, more importantly, the new code is much easier to
parse for a human reader.
2020-03-10 02:42:08 +01:00
Lauri Nurmi
32ead5a0ff Fix dangling else warnings at all wx(V)LogXXX calls
Earlier this was fixed for some but not all variants of wx(V)LogXXX.

See #11829.
2020-03-10 02:42:08 +01:00
Vadim Zeitlin
1f9dd05797 Stop passing wxString by value to wxLog::GetComponentLevel()
This function is almost exclusively called from IsLevelEnabled() which
doesn't get inlined (at least by MSVS) when wxString is passed by value
to it, and so had to be updated to take a const reference instead, which
means that a copy is always going to be made anyhow, so don't try to be
smart and avoid it -- it doesn't work anyhow and just results in unusual
code, requiring explanatory comments (not needed any longer) and
upsetting static code analyzers.

No real changes.

See https://github.com/wxWidgets/wxWidgets/pull/1387
2019-07-08 10:04:14 +02:00
Vadim Zeitlin
a1bd57d1d8 Make wxLog non-copyable
It doesn't make sense to copy objects of this class and this wouldn't
work correctly due to the presence of m_formatter field.

See https://github.com/wxWidgets/wxWidgets/pull/1389
2019-07-07 02:54:20 +02:00
orbitcowboy
8dfd799fd5 Use const for constant local variables in wxWidgets headers
This avoids warnings from MSVS 2017 static analyzer when C++ core rule
set is activated.

Closes https://github.com/wxWidgets/wxWidgets/pull/819
2018-07-21 16:16:32 +02:00
Vadim Zeitlin
39dc254bf4 Don't call time() from wxLogRecordInfo ctor
This is a tiny optimization (or maybe not so tiny on platforms other
than Linux where time() might not as fast as just reading a memory
location), but mostly is done to work around faketime bug[*] which
prevented it from being used for testing programs using wxWidgets, such
as our own unit tests because time() was called from wxLogTrace() in
wxCSConv::DoCreate() called when creating global conversion objects
during the library initialization.

Arguably, it might be better to avoid calling wxLogTrace() during the
initialization, but this can't be done as simply and this change might
have a small performance benefit too.

[*] https://github.com/wolfcw/libfaketime/issues/132
2017-11-29 02:22:16 +01:00
Vadim Zeitlin
46fe849db6 Restore access to wxLogStderr::m_fp from derived classes
This was allowed before, but m_fp became private after the refactoring
of a7dddd9f3b.

Make it protected again now to avoid breaking existing code that
accesses it.
2017-11-07 22:40:32 +01:00
Vadim Zeitlin
a7dddd9f3b Refactor wxLog and wxMessageOutput classes to avoid duplication
Add wxMessageOutputWithConv mix-in class to avoid duplicating the same
code in wxLogStream and wxMessageOutputStderr.

Also derive wxLogStderr from wxMessageOutputStderr to reuse its code
without having to create a temporary object of this type (which will be
more expensive now that doing it involves creating a heap-allocated
conversion object copy).
2017-11-04 16:19:06 +01:00
Lauri Nurmi
6b73bd9136 Allow specifying character set for wxLogStderr and wxLogStream.
Until now, a mixture of non-UTF-8 and UTF-8 could be written in some circumstances.
2017-11-04 15:47:18 +02:00
Lauri Nurmi
902130f64e Use the new wxSysErrorMsgStr() instead of wxSysErrorMsg() 2016-11-21 19:15:20 +02:00
Lauri Nurmi
343318d73e Add a thread-safe wxSysErrorMsgStr()
Implement wxSysErrorMsg's functionality without using static buffers;
have the caller provide the buffer. When the caller uses the original
API and does not provide a buffer, a static buffer is still used.
wxSysErrorMsgStr() returns a wxString.

Also use strerror_r() instead of strerror() on platforms other than MSW.
2016-11-21 19:15:19 +02:00
Vadim Zeitlin
da7388c9c8 Make wxLogInfo() work even without wxLog::SetVerbose()
It's confusing that wxLogInfo() and wxLogVerbose() are exactly the same and
the former, and not only the latter, doesn't do anything unless SetVerbose()
had been called, even if the log level is wxLOG_Info or higher.

Fix this by checking for GetVerbose() in wxLogVerbose() only and making
wxLogInfo() check the log level only. This makes it very similar to
wxLogMessage() but this is not such a bad thing.

Also improve wxLogVerbose() documentation.
2016-03-04 15:17:35 +01:00
Tobias Taschner
8282c1be0f Remove Windows CE support
Windows CE doesn't seem to be supported by Microsoft any longer. Last CE
release was in early 2013 and the PocketPC and Smartphone targets supported by
wxWidgets are long gone.

The build files where already removed in an earlier cleanup this commit
removes all files, every #ifdef and all documentation regarding the Windows CE
support.

Closes https://github.com/wxWidgets/wxWidgets/pull/81
2015-09-23 00:52:30 +02:00
Vadim Zeitlin
1ca1d77e01 Remove the inclusions of wx/cocoa headers which don't exist any more.
This should have been part of r76735: in addition to removing the old Cocoa
port headers, also remove the references to them from the common include
files.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76806 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-07-02 13:28:42 +00:00
Vadim Zeitlin
49b8d79c87 Remove (Open)Watcom support.
This compiler is not being developed since several years and almost certainly
can't be used to build the current wxWidgets sources anyhow, so remove all
support for it, including a lot of extremely ugly workarounds for its bugs
with template functions.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76546 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-05-16 13:01:06 +00:00
Vadim Zeitlin
f4b80e5337 Remove MSVC6 support.
Don't support this compiler any more, this allows to get rid of tons of
MSVC6-specific workarounds, in particular we can now use Bind() and natural
template functions calls in the library code.

Also remove MSVC6 project and solution files and don't generate them when
bakefile_gen is ran any more (removing the remaining occurrences of msvc6prj
from the bakefiles results in weird bake-time errors, so it's simpler to just
leave them there).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-05-15 22:32:17 +00:00
Paul Cornett
8b4ae731d3 use wxOVERRIDE
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76220 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-03-30 00:02:23 +00:00
Paul Cornett
967a94c91a remove WXWIN_COMPATIBILITY_2_6, add WXWIN_COMPATIBILITY_3_0
closes #15792

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75532 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-01-04 20:07:33 +00:00
Vadim Zeitlin
ff701a5de9 Revert wxDO_LOG_IF_ENABLED() change for MSVC6 in r74735.
The old solution worked fine for that compiler and the new one fails when
wxLogXXX() is used inside a switch statement to the wrong rules used by VC6
for the scope of the variables defined inside the for loop.

Simply revert back to using the old version for it, this will be easy to
re-revert after 3.0 by simply removing the check for it.

See #11829.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-09-05 14:10:34 +00:00
Vadim Zeitlin
66b370d05f Rewrite wxLogXXX() macros to avoid "ambiguous else" warnings.
Use a dummy for loop instead of an if statement to avoid all problems with the
dangling else clauses: both the need for an artificially inversed "if" to make
the code like

	if ( something )
		wxLogError("...");
	else
		something-else;

to work as expected and to avoid warnings given by some versions of g++ and
clang for the code above advising to add explicit braces.

Closes #11829.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74735 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-08-31 17:41:16 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
81b93d3e85 Fix wxVLogStatus definition.
This macro can be used with 2 arguments (format and argptr) or 3 (the frame
pointer as an additional first argument), so don't define it as taking 2
arguments but as a macro without arguments, as we already do for
wxVLogSysErrorfor the same reasons.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72421 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-09-01 22:38:40 +00:00
Vadim Zeitlin
d98a58c543 Use __WINDOWS__ for OS kind checks and reserve __WXMSW__ for GUI toolkit.
This change prepares the way for using wxGTK under Windows as this would
still define __WINDOWS__ but use __WXGTK__ instead of __WXMSW__.

Closes #14064.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70796 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-03-04 00:29:31 +00:00
Vadim Zeitlin
bd362275b8 Remove Palm OS port.
The platform targeted by this port doesn't exist any more and the port never
achieved really working state so remove the code to avoid having to maintain
it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70345 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2012-01-15 01:05:28 +00:00
Vadim Zeitlin
4ffdb64018 Add wxLogFormatter to allow easier wxLog output customization.
Delegate the log string creation to wxLogFormatter. This allows defining a
custom object of a class derived from it to customize the log output instead
of having to override DoLogRecord() in wxLog itself.

Closes #13792.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70086 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-12-22 13:35:01 +00:00
Vadim Zeitlin
d65e9d5707 Move "static" keyword out from wxDEPRECATED() macros to placate icc.
Intel compiler gives warnings if the static keyword is not at the beginning of
the declaration and this happened when using it inside wxDEPRECATED() and
related macros because the declaration started with __declspec(deprecated) or
__attribute__((deprecated)) instead.

To avoid this problem, simply move "static" outside the macro.

Closes #12932.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66966 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-02-19 12:32:59 +00:00
Francesco Montorsi
e4431849b4 Implement wx-prefixed macros versions of DECLARE/IMPLEMENT_APP_* macros.
Implement compatibility aliases for non-prefixed macro names.
Require a final semicolon where possible.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64531 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-06-09 13:23:13 +00:00
Vadim Zeitlin
ff46415213 Compilation fix for wxUSE_LOG_DEBUG==0 case.
Don't do anything in wxDISABLE_DEBUG_LOGGING_IN_RELEASE_BUILD() if we don't
use debug logging anyhow.

Closes #12070.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64333 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-05-18 10:29:52 +00:00
Vadim Zeitlin
55e5154d2c Make calling wxLog::IsAllowedTraceMask() safe during static init time.
Although using wxLog during statics initialization is not recommended, it may
still happen, possibly indirectly so make it work correctly by using an
accessor function for the array of trace masks which ensures that this array
is always correctly initialized before being used.

Closes #11592.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63063 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2010-01-04 12:22:42 +00:00
Vadim Zeitlin
7d9550df50 Define wxDEBUG_LEVEL in both debug and release builds as 1.
By default include assertions and debug logging in both debug and release
builds but disable them in application release builds (when NDEBUG is
defined).

Also update (more accurately, replace) debugging overview.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61886 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-09-12 11:28:52 +00:00
Vadim Zeitlin
03647350fc No changes, just removed hard tabs and trailing white space.
This commit is huge but there are no non-white-space changes in it.

Some files containing third-party sources (src/msw/wince/time.cpp,
src/x11/pango*.cpp) were left unchanged.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61724 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-08-21 10:41:26 +00:00
Vadim Zeitlin
b0d58b0ea8 Fix compilation for wxUSE_LOG==0.
Move wxObject and wxFrame forward declarations so that they are accessible to
empty wxLogXXX() functions defined in wxUSE_LOG==0 case too.

Also take wxFormatString, not wxString, in these functions to avoid overload
ambiguities.

Closes #11103.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-08-18 01:22:57 +00:00
Vadim Zeitlin
b804f9924d Fix last error display in wxLogSysError().
After recent changes of wxLogXXX() functions into macros the last error was
overwritten by wxString::Format() called between the call to wxLogSysError()
and wxLog::CallDoLogNow() which called wxSysErrorCode() and so its original
value was lost and, unless the last error was specified explicitly, it always
came out as 0.

To fix this, call wxSysErrorCode() directly when calling wxLogSysError(). This
may be unnecessary (if the error is given explicitly) but there doesn't seem
to be any other way to fix it and the overhead of calling wxSysErrorCode()
shouldn't be that big.

Also add a unit test checking that wxLogSysError() behaves as expected.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61692 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-08-18 01:22:48 +00:00
Vadim Zeitlin
89d62794e4 Implement wxVLogTrace() accidentally removed by recent changes.
Also change the unit test to test wxVLogTrace() as well as wxLogTrace.

Closes #11011.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-23 13:40:44 +00:00
Vadim Zeitlin
e55919d892 No changes, just fix a typo: wxGuiLog was used instead of wxLogGui.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61449 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-18 11:18:21 +00:00
Vadim Zeitlin
5d7526b0b8 fix log target auto creation broken by recent changes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61432 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-15 12:36:09 +00:00
Vadim Zeitlin
53ff8df7d5 Make wxLog::EnableLogging() and wxLogNull thread-specific.
Disabling logging in a single thread (even the main one) shouldn't disable
logs from the background threads which should disable their logging themselves
as/if needed.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61423 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-13 13:21:52 +00:00
Vadim Zeitlin
acad886cb4 Add support for thread-specific log targets.
A worker thread can now have its own log target which will be used directly
by the log functions instead of buffering log output in the main thread; the
GUI thread in the thread sample shows how it works.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61422 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-13 11:09:26 +00:00
Vadim Zeitlin
16b1f6fc50 Removed critical section protecting last repeat counter.
It is not needed any longer now that this is only used by
wxLog::OnLogInMainThreade() which is only called from the main thread.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61417 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-12 17:09:33 +00:00
Vadim Zeitlin
232addd1cd Made wxLogXXX() functions thread-safe.
They can now be called from any thread and will buffer the messages until the
current log target is flushed from the main thread. This makes earlier code to
do the same thing specifically for wxLogWindow unnecessary and also allows to
use wxLogMessage() in the thread sample instead of using manual logging there.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-12 17:02:30 +00:00
Vadim Zeitlin
c602c59b6e Add component-level filtering to wxLog.
Each log message is now associated with its component, "wx" by default for
messages generated by wxWidgets and wxLOG_COMPONENT in general (which is empty
by default). Each component may have its own log level and they are
hierarchical allowing fine configuration of what exactly is logged.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61414 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-12 14:56:23 +00:00
Vadim Zeitlin
b356aa554a don't mark GetTraceMask() deprecated as we use it in the same header which provokes warnings when including it from outside wx
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61367 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-09 22:00:30 +00:00
Vadim Zeitlin
c279530ba9 fix MSVC compilation: as string literals are of non-const char* type with this compiler, they are implicitly convertible to void* resulting in overloading ambiguities with wxLogger::Log()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-09 21:39:29 +00:00
Vadim Zeitlin
ff2e9e2cc4 implement wxLogTrace(wxTraceMask, format, ...) overload too
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61364 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-09 20:30:27 +00:00
Vadim Zeitlin
af58844636 Add information about the log message generation location to wxLog.
This means that wxLog::DoLogRecord() can now retrieve the file name, line
number and the function where the message was logged.

An unfortunate consequence of this change is that now

	if ( condition )
		wxLogError("Whatever");

results in a warning from g++ 4.x with -Wparentehses, so extra parentheses had
to be added in many places.

Finally, also allow storing arbitrary attributes in wxLogRecordInfo. This had
to be added to implement our own overloaded wxLogStatus() and wxLogSysError()
and will probably be useful for the others as well.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61363 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-09 20:26:34 +00:00
Vadim Zeitlin
ae2070fb77 fix VC6 warnings about not enough parameters for wxDEPRECATED_BUT_USED_INTERNALLY_INLINE
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61357 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-09 15:13:52 +00:00
Vadim Zeitlin
ba3af1010d added wxLog::IsLevelEnabled() helper; document it and a few related functions which were not, or poorly, documented
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61348 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-08 14:16:55 +00:00
Vadim Zeitlin
bc73d5aec8 Changed wxLog DoLogXXX() callbacks and introduced wxLogRecordInfo.
The main logging callback is now DoLogRecord() with DoLogTextAtLevel() and
DoLogText() provided for convenience. The old DoLog() and DoLogString() are
still called but deprecated and their overloads taking wxString which were
only added in 2.9.0 are removed.

wxLogRecordInfo allows associating more information than just the time stamp
with the log record; for now only the logging thread id was added but more
fields will make their appearance soon.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61346 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2009-07-08 13:47:33 +00:00