#include "os.hpp"
#include "trace_writer.hpp"
-#include "trace_file.hpp"
+#include "trace_snappyfile.hpp"
#include "trace_format.hpp"
}
-void
-LocalWriter::open(void) {
-
- static unsigned dwCounter = 0;
-
- const char *szExtension = "trace";
- char szFileName[PATH_MAX];
- const char *lpFileName;
-
- lpFileName = getenv("TRACE_FILE");
- if (lpFileName) {
- strncpy(szFileName, lpFileName, PATH_MAX);
- }
- else {
- char szProcessName[PATH_MAX];
- char szCurrentDir[PATH_MAX];
- OS::GetProcessName(szProcessName, PATH_MAX);
- OS::GetCurrentDir(szCurrentDir, PATH_MAX);
-
- for (;;) {
- FILE *file;
-
- if (dwCounter)
- snprintf(szFileName, PATH_MAX, "%s%c%s.%u.%s", szCurrentDir, PATH_SEP, szProcessName, dwCounter, szExtension);
- else
- snprintf(szFileName, PATH_MAX, "%s%c%s.%s", szCurrentDir, PATH_SEP, szProcessName, szExtension);
-
- file = fopen(szFileName, "rb");
- if (file == NULL)
- break;
-
- fclose(file);
-
- ++dwCounter;
- }
- }
-
- OS::DebugMessage("apitrace: tracing to %s\n", szFileName);
-
- Writer::open(szFileName);
-}
-
-unsigned LocalWriter::beginEnter(const FunctionSig *sig) {
- OS::AcquireMutex();
-
- if (!m_file->isOpened()) {
- open();
- }
-
- return Writer::beginEnter(sig);
-}
-
-void LocalWriter::endEnter(void) {
- Writer::endEnter();
- OS::ReleaseMutex();
-}
-
-void LocalWriter::beginLeave(unsigned call) {
- OS::AcquireMutex();
- Writer::beginLeave(call);
-}
-
-void LocalWriter::endLeave(void) {
- Writer::endLeave();
- m_file->flush();
- OS::ReleaseMutex();
-}
-
-
} /* namespace Trace */