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]
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,21 +19,38 @@ public:
|
||||||
using PrintFunction = Lambda <void (const char *)>;
|
using PrintFunction = Lambda <void (const char *)>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
File handle_;
|
String filename_;
|
||||||
PrintFunction printFun_;
|
PrintFunction printFun_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SimpleLogger () = default;
|
SimpleLogger () = default;
|
||||||
|
~SimpleLogger () = default;
|
||||||
|
|
||||||
~SimpleLogger () {
|
public:
|
||||||
handle_.close ();
|
class LogFile final {
|
||||||
}
|
private:
|
||||||
|
File handle_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
LogFile (StringRef filename) {
|
||||||
|
handle_.open (filename, "at");
|
||||||
|
}
|
||||||
|
|
||||||
|
~LogFile () {
|
||||||
|
handle_.close ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
void print (StringRef msg) {
|
||||||
|
if (!handle_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handle_.puts (msg.chars ());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void logToFile (const char *level, const char *msg) {
|
void logToFile (const char *level, const char *msg) {
|
||||||
if (!handle_) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
time_t ticks = time (&ticks);
|
time_t ticks = time (&ticks);
|
||||||
tm timeinfo {};
|
tm timeinfo {};
|
||||||
|
|
||||||
|
|
@ -46,7 +63,8 @@ private:
|
||||||
auto timebuf = strings.chars ();
|
auto timebuf = strings.chars ();
|
||||||
strftime (timebuf, StringBuffer::StaticBufferSize, "%Y-%m-%d %H:%M:%S", &timeinfo);
|
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:
|
public:
|
||||||
|
|
@ -83,11 +101,8 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initialize (StringRef filename, PrintFunction printFunction) {
|
void initialize (StringRef filename, PrintFunction printFunction) {
|
||||||
if (handle_) {
|
|
||||||
handle_.close ();
|
|
||||||
}
|
|
||||||
printFun_ = cr::move (printFunction);
|
printFun_ = cr::move (printFunction);
|
||||||
handle_.open (filename, "at");
|
filename_ = filename;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ elif isWindows and (isCLang or isGCC)
|
||||||
else
|
else
|
||||||
ldflags += [
|
ldflags += [
|
||||||
'-static-libgcc',
|
'-static-libgcc',
|
||||||
'-Wl,--add-stdcall-alias'
|
'-Wl,--kill-at'
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -899,7 +899,7 @@ CR_EXPORT void Meta_Init () {
|
||||||
|
|
||||||
// games GiveFnptrsToDll is a bit tricky
|
// games GiveFnptrsToDll is a bit tricky
|
||||||
#if defined(CR_WINDOWS)
|
#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)
|
# if defined (CR_ARCH_X86)
|
||||||
# pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
|
# pragma comment(linker, "/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1")
|
||||||
# endif
|
# endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue