Commit Graph

56 Commits (8cb5f2a5673165d732790e6440e9cd90b71074d4)

Author SHA1 Message Date
elsid 6a67263d6b
Separate the log level and the flag for writing the log level 6 months ago
elsid 98a8dcbdbf
Limit log buffer size 6 months ago
elsid c83acac32c
Add a function to get debug level 6 months ago
elsid 0749cc4dac
Remove unused include 6 months ago
elsid 1bdc01273e
Move "debugging" function into Debug namespace 6 months ago
elsid ea84d1ce0c
Remove unused mode argument 6 months ago
elsid 89bb04e8fd
Exit with fatal error on duplicated instruction code
Instead of causing SIGABRT which is more confusing.
6 months ago
elsid 38f0533bcf
Write to log file records captured before configs are loaded 8 months ago
elsid 4ab5871dc4
Split Tee logic into different types 8 months ago
AnyOldName3 83e3718bed . c l a n g - f o r m a t 9 months ago
AnyOldName3 61364c874f Warn future me off wasting their time again 9 months ago
AnyOldName3 a7021bf9cc Clear std stream errors when reopening
Prior errors are no longer relevant.

Shouldn't make a difference unless you've tried printing something before the streams were set up.
9 months ago
AnyOldName3 1930bfeabb Support coloured terminal output on Windows
First try the modern Windowsy way, where we can directly query if escape sequences will be processed.
The function is available as far back as Windows 2000, but it just won't return the right flag until the Windows version is new enough.

If that fails, fall back to the Unixy way, as not all colour-supporting terminal emulators for Windows use the Win32 API to declare that capability.
The implementation isn't identical as isatty wasn't available without adding more headers, and we already have Windows.h in this file, so I might as well use the Win32 API instead of its POSIX-compatibility layer.
9 months ago
AnyOldName3 9638fbabb4 https://www.youtube.com/watch?v=2_6U9gkQeqY 10 months ago
AnyOldName3 ff3ffa13b6 Auto format 10 months ago
AnyOldName3 28131fd62b Fixes for a whole bunch of warnings
These warnings were always enabled, but we didn't see them due to https://gitlab.com/OpenMW/openmw/-/issues/7882.
I do not fully understand the cause of 7822 as I can't repro it in a minimal CMake project.

Some of these fixes are thought through.
Some are sensible best guesses.
Some are kind of a stab in the dark as I don't know whether there was a
possible bug the warning was telling me about that I've done nothing to
help by introducing a static_cast.

Nearly all of these warnings were about some kind of narrowing
conversion, so I'm not sure why they weren't firing with GCC and Clang,
which have -Wall -Wextra -pedantic set, which should imply -Wnarrowing,
and they can't have been affected by 7882.

There were also some warnings being triggered from Boost code.
The vast majority of library headers that do questionable things weren't
firing warnings off, but for some reason, /external:I wasn't putting
these Boost headers into external mode.

We need these warnings dealt with one way or another so we can switch
the default Windows CI from MSBuild (which doesn't do ccache) to Ninja
(which does).
I have the necessary magic for that on a branch, but the branch won't
build because of these warnings.
10 months ago
elsid 55501a02c0
Define only one crashCatcherInstall function 12 months ago
AnyOldName3 2ed584428c Add missing headers to components/CMakeLists.txt
Otherwise, they won't show up as part of the project in IDEs.
1 year ago
AnyOldName3 1bdcb5d6d9 Share the dump directory for crash and freeze dumps
This means the shared memory struct is just 255 bytes longer than a few
commits ago instead of 32K.

Also introduce a function for putting path strings in the shared memory
as there was too much copied and pasted code and it was error-prone.

Also free some handles once we're done with them so they don't leak.
1 year ago
AnyOldName3 48368f79b6 Update Windows crash dump path once we know where we're logging
Manual rewrite of 5102f4b11d
2 years ago
AnyOldName3 72d99237e3 This would never have happened had clang format not tried making this function wrogn in the first place 2 years ago
AnyOldName3 1bcbc4f53f Undo clang format change because clang format in CI disagrees with clang format on my computer 2 years ago
AnyOldName3 3bb3f58c73 Don't put crash dumps in Temp on Windows
Well... unless we fail to get the user profile directory.

Also put freeze dumps in a more appropriately-named file.

Discussed in https://gitlab.com/OpenMW/openmw/-/issues/7455

Manual rewrite of c21695c951

As well as that, I found a bug where the crash dump path was being converted from a std::filesystem::path to a utf8-encoded std::string, then passed to the crash catcher, which converted it to a std::filesystem::path implicitly, but using the system eight-bit code page, which wouldn't usually be UTF-8. That's now fixed by passing the function that expects a path a path instead of a string.
2 years ago
Shi Han a90e3b8c3b Move from std::atoi to std::from_char 2 years ago
elsid c44bc5ade5
Setup logging with properly initialized configuration manager
Default constructed instance may provide different paths from initialized one.
2 years ago
elsid 007ad4e4d1
Write crash log to temporary directory
To make sure current user has rights to do so.
2 years ago
clang-format-bot 88ec8a9523
Apply clang-format 2 years ago
Project579 5cf2a958eb Make conversions between std::chrono time_point and string safer by not using "localtime" directly. 2 years ago
clang-format-bot ddb0522bbf
Apply clang-format to code base 2 years ago
Project579 a13709c510 Replace implicit convertions from std::filesystem::path to std::string with correctly converting functions. 2 years ago
Project579 e5c417c968 Make sure all paths are passed as std::filesystem::path instead of std::string where possible. 2 years ago
Project579 4bb07282c9 Replace all remaining occurrences of boost::filesystem with std::filesystem. 2 years ago
elsid d2ed62ec3a
Allow to disable crash catcher on Windows 3 years ago
ζeh Matt 14bf9af056
Move implementation details of debugging.hpp to cpp, reduce includes 3 years ago
jvoisin 4e4debb1cb Remove even more of boost::filesystem 3 years ago
Petr Mikheev cf49b46d64 Show logs in the debug window
Some part of UI code is written by @andrew-app
3 years ago
elsid 0dcb1f5aac
Fix build on Windows
Use wrapper header over Windows.h to undefine far and near in a single place.
3 years ago
elsid e777e35414
Use system_clock for time in logs
high_resolution_clock may not give real time. MSVC implements it as
steady_clock that is basically CPU time which is usually desynchronized with
real time.
3 years ago
elsid 2d5ccc804b
Exchange binary messages between navmeshtool and launcher 3 years ago
Petr Mikheev dd5ba5c57b Redirect log only after parsing configuration 3 years ago
fredzio 4058e117ca Don't clobber game log file when we collect a stack trace.
When the crash catcher catch a signal it forks to collect data about its
parent. In the process the child reinitialize the log file, which ends
up empty.
4 years ago
CedricMocquillon 112437cf28 Change crash file to dmp on window to avoid renaming it 4 years ago
CedricMocquillon 73afc55462 Fork the current process to monitor exe, generate minidump on crash 4 years ago
Petr Mikheev 49c6e50c31 Print '--version' and '--help' messages without timestamps 4 years ago
Petr Mikheev 5734551ff3 Add time to logs. Redirect OSG log to OpenMW log. 4 years ago
AnyOldName3 89d73c5fc7 Only reroute stdout etc. to new console if not already redirected
This should fix the issue where Windows Release builds (compiled as
/SUBSYSTEM:WINDOWS instead of /SUBSYSTEM:CONSOLE) can't have their
output redirected.

Basically, a console application creates a console if not given one, so
you get a console window behind OpenMW while it's running. It was
decided that this was ugly, so we set Release builds to be windows
applications, which don't get an automatic console and don't
automatically connect to a console if given one anyway.

Of course, we still wanted to actually be able to print to a console if
given one, so we manually attach to the parent process' console if it
exists, then reopen the standard streams connected to CON, the Windows
pseudo-file representing the current console.

This is a little like connecting a second wire into a dumb terminal in
that you're pumping characters into the display rather than onto a
pipeline, so output can't be redirected.

It turns out, though, that if a /SUBSYSTEM:WINDOWS application has its
standard streams redirected by the calling process, it still gets its
handles as normal, so everything starts off connected just how we want
it and we were clobbering this good setup with the straight-to-console
fix.

All we need to do to fix that is check if we've got valid standard
handles and that they go somewhere useful, and if so, avoid reopening
them once the console is attached. Simples.
4 years ago
elsid 29f262e514
Fix crash on destructed stream usage 5 years ago
Andrei Kortunov 14b756a692 Use a generic logging system for RecastNavigation 6 years ago
Stanislaw Halik c5c160870d fix accidental header namespace inclusion 6 years ago
Stanislaw Halik f6c8842457 move to debugging.[ch]pp 6 years ago