Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better logging #989

Merged
merged 3 commits into from Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/bflib_basics.c
Expand Up @@ -373,8 +373,14 @@ int LbErrorLogClose(void)
return LbLogClose(&error_log);
}

FILE *file;

FILE *file = NULL;

void LbCloseLog()
{
fclose(file);
file = NULL;
}

int LbLog(struct TbLog *log, const char *fmt_str, va_list arg)
{
enum Header {
Expand Down
2 changes: 2 additions & 0 deletions src/bflib_basics.h
Expand Up @@ -146,6 +146,8 @@ int LbLogClose(struct TbLog *log);
int LbLogSetup(struct TbLog *log, const char *filename, ulong flags);
int LbLogSetPrefix(struct TbLog *log, const char *prefix);
int LbLogSetPrefixFmt(struct TbLog *log, const char *format, ...);

void LbCloseLog();
/******************************************************************************/
typedef void (__stdcall *TbNetworkCallbackFunc)(struct TbNetworkCallbackData *, void *);
/******************************************************************************/
Expand Down
10 changes: 10 additions & 0 deletions src/main.cpp
Expand Up @@ -5027,11 +5027,21 @@ void get_cmdln_args(unsigned short &argc, char *argv[])
}
}

LONG __stdcall Vex_handler(
_EXCEPTION_POINTERS *ExceptionInfo
)
{
LbJustLog("=== Crash ===");
LbCloseLog();
return 0;
}

int main(int argc, char *argv[])
{
char *text;
_DK_hInstance = GetModuleHandle(NULL);

AddVectoredExceptionHandler(0, &Vex_handler);
get_cmdln_args(bf_argc, bf_argv);

//TODO DLL_CLEANUP delete when won't be needed anymore
Expand Down