Skip to content

Commit

Permalink
Try to fix logging for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Vort committed Jul 12, 2023
1 parent b95e606 commit 4451a77
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions daemon/i2pd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,11 @@ int main( int argc, char* argv[] )
return i2p::qt::RunQT (argc, argv);
}
#else
int main( int argc, char* argv[] )
{
if (Daemon.init(argc, argv))
{
if (Daemon.start())
Daemon.run ();
else
return EXIT_FAILURE;
Daemon.stop();
}
return EXIT_SUCCESS;
}
#endif

#ifdef _WIN32
#include <windows.h>
#include <fstream>
#include <thread>
#include <ctime>
#include <chrono>
#include <mutex>
#include <vector>
#include <iomanip>
Expand Down Expand Up @@ -78,13 +64,17 @@ void StartProfiling()
lastRequestTime = now;
DumpProfileData();
}
Sleep(250);
std::this_thread::sleep_for(std::chrono::milliseconds(250));
if (timeThreadExiting)
return;
}
});

#ifdef _WIN32
crstatfs.open("crstat.txt", std::ios::app);
#else
crstatfs.open("/tmp/crstat.txt", std::ios::app);
#endif
}

void StopProfiling()
Expand All @@ -96,16 +86,33 @@ void StopProfiling()
timeThread = nullptr;
}

int main( int argc, char* argv[] )
{
StartProfiling();
if (Daemon.init(argc, argv))
{
if (Daemon.start())
Daemon.run ();
else
return EXIT_FAILURE;
Daemon.stop();
}
StopProfiling();
return EXIT_SUCCESS;
}
#endif

#ifdef _WIN32
#include <windows.h>

int CALLBACK WinMain(
_In_ HINSTANCE hInstance,
_In_ HINSTANCE hPrevInstance,
_In_ LPSTR lpCmdLine,
_In_ int nCmdShow
)
{
StartProfiling();
int r = main(__argc, __argv);
StopProfiling();
return r;
}
#endif

0 comments on commit 4451a77

Please sign in to comment.