Do not keep log file opened while game process active.
Rename actions workflow. Fixed mingw-w64 stdcall handling.
This commit is contained in:
parent
51e8ace7ff
commit
e8b55acd23
4 changed files with 30 additions and 15 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -1,4 +1,4 @@
|
|||
name: YaPB Build
|
||||
name: YaPB
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
|
|
|
|||
|
|
@ -19,21 +19,38 @@ public:
|
|||
using PrintFunction = Lambda <void (const char *)>;
|
||||
|
||||
private:
|
||||
File handle_;
|
||||
String filename_;
|
||||
PrintFunction printFun_;
|
||||
|
||||
public:
|
||||
SimpleLogger () = default;
|
||||
~SimpleLogger () = default;
|
||||
|
||||
~SimpleLogger () {
|
||||
public:
|
||||
class LogFile final {
|
||||
private:
|
||||
File handle_;
|
||||
|
||||
public:
|
||||
LogFile (StringRef filename) {
|
||||
handle_.open (filename, "at");
|
||||
}
|
||||
|
||||
~LogFile () {
|
||||
handle_.close ();
|
||||
}
|
||||
|
||||
private:
|
||||
void logToFile (const char *level, const char *msg) {
|
||||
public:
|
||||
void print (StringRef msg) {
|
||||
if (!handle_) {
|
||||
return;
|
||||
}
|
||||
handle_.puts (msg.chars ());
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
void logToFile (const char *level, const char *msg) {
|
||||
time_t ticks = time (&ticks);
|
||||
tm timeinfo {};
|
||||
|
||||
|
|
@ -46,7 +63,8 @@ private:
|
|||
auto timebuf = strings.chars ();
|
||||
strftime (timebuf, StringBuffer::StaticBufferSize, "%Y-%m-%d %H:%M:%S", &timeinfo);
|
||||
|
||||
handle_.puts ("%s (%s): %s\n", timebuf, level, msg);
|
||||
LogFile lf (filename_);
|
||||
lf.print (strings.format ("%s (%s): %s\n", timebuf, level, msg));
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
@ -83,11 +101,8 @@ public:
|
|||
|
||||
public:
|
||||
void initialize (StringRef filename, PrintFunction printFunction) {
|
||||
if (handle_) {
|
||||
handle_.close ();
|
||||
}
|
||||
printFun_ = cr::move (printFunction);
|
||||
handle_.open (filename, "at");
|
||||
filename_ = filename;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ elif isWindows and (isCLang or isGCC)
|
|||
else
|
||||
ldflags += [
|
||||
'-static-libgcc',
|
||||
'-Wl,--add-stdcall-alias'
|
||||
'-Wl,--kill-at'
|
||||
]
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -899,7 +899,7 @@ CR_EXPORT void Meta_Init () {
|
|||
|
||||
// games GiveFnptrsToDll is a bit tricky
|
||||
#if defined(CR_WINDOWS)
|
||||
# if defined(CR_CXX_MSVC) || defined (CR_CXX_CLANG)
|
||||
# if defined(CR_CXX_MSVC) || (defined(CR_CXX_CLANG) && !defined(CR_CXX_GCC))
|
||||
# if defined (CR_ARCH_X86)
|
||||
# pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
|
||||
# endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue