MCPcopy Create free account
hub / github.com/beefytech/Beef / DoBfLog

Method DoBfLog

IDEHelper/Compiler/BfSystem.cpp:25–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23#pragma warning(disable:4996)
24
25void Beefy::DoBfLog(int fileIdx, const char* fmt ...)
26{
27 static int entryNum = 0;
28 static bool onNewLine[10];
29 entryNum++;
30
31 static BfpFile* fp[10] = { NULL };
32 static bool openedLog[10] = { false };
33 static int64 logSize[10] = { 0 };
34 static int logCount[10] = { 0 };
35
36 if (logSize[fileIdx] >= 1 * 1024 * 1024 * 1024)
37 {
38 BfpFile_Release(fp[fileIdx]);
39 openedLog[fileIdx] = false;
40 }
41
42 if (!openedLog[fileIdx])
43 {
44 openedLog[fileIdx] = true;
45 logSize[fileIdx] = 0;
46
47 char exeName[512];
48 int len = 512;
49 BfpSystem_GetExecutablePath(exeName, &len, NULL);
50
51 String dbgName = exeName;
52 int dotPos = (int)dbgName.IndexOf('.');
53 if (dotPos != -1)
54 dbgName.RemoveToEnd(dotPos);
55 dbgName += StrFormat("_%d", fileIdx);
56
57 if (logCount[fileIdx] > 0)
58 dbgName += 'B';
59
60 dbgName += ".txt";
61
62 fp[fileIdx] = BfpFile_Create(dbgName.c_str(), BfpFileCreateKind_CreateAlways, (BfpFileCreateFlags)(BfpFileCreateFlag_Write | BfpFileCreateFlag_NoBuffering | BfpFileCreateFlag_ShareRead), BfpFileAttribute_Normal, NULL);
63 onNewLine[fileIdx] = true;
64 logCount[fileIdx]++;
65 }
66 if (fp[fileIdx] == NULL)
67 return;
68
69 char lineStr[4096];
70 int strOfs;
71 int maxChars;
72
73 if (onNewLine[fileIdx])
74 {
75 strOfs = sprintf(lineStr, "%d", entryNum) + 1;
76 lineStr[strOfs - 1] = ' ';
77 maxChars = 4095 - strOfs;
78 }
79 else
80 {
81 strOfs = 0;
82 maxChars = 4095;

Callers

nothing calls this directly

Calls 8

BfpFile_ReleaseFunction · 0.50
BfpFile_WriteFunction · 0.50
IndexOfMethod · 0.45
RemoveToEndMethod · 0.45
c_strMethod · 0.45
EndsWithMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected