MCPcopy Create free account
hub / github.com/BruceDevices/firmware / startSessionLog

Function startSessionLog

src/modules/wifi/clients.cpp:148–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void startSessionLog(ClientProtocol protocol) {
149 withClientLock([&]() {
150 closeSessionLogUnlocked();
151
152 if (!bruceConfig.TerminalLog || !sdcardMounted) return;
153
154 if (!SD.exists("/Bruce")) SD.mkdir("/Bruce");
155 if (!SD.exists("/Bruce/Terminal")) SD.mkdir("/Bruce/Terminal");
156
157 String basePath = "/Bruce/Terminal/" + String(getProtocolName(protocol)) + "-" +
158 sanitizeSessionLogComponent(sessionHost);
159 for (uint16_t index = 1; index < 10000; ++index) {
160 String candidate = basePath + "_" + String(index) + ".log";
161 if (SD.exists(candidate)) continue;
162
163 sessionLogFile = SD.open(candidate, FILE_WRITE);
164 if (!sessionLogFile) return;
165
166 sessionLogEnabled = true;
167 sessionLogPath = candidate;
168
169 String header = "=== Bruce Terminal Session ===\n";
170 header += "Protocol: " + String(getProtocolName(protocol)) + "\n";
171 header += "Host: " + sessionHost + "\n";
172 if (!sessionUser.isEmpty()) header += "User: " + sessionUser + "\n";
173 header += "Port: " + String(sessionPort) + "\n";
174 header += "Started at millis: " + String(millis()) + "\n";
175 header += "==============================\n";
176 appendSessionLogUnlocked(header.c_str(), header.length());
177 return;
178 }
179 });
180}
181
182void setClientTaskHandle(TaskHandle_t handle) {
183 withClientLock([&]() { clientTaskHandle = handle; });

Callers 2

ssh_setupFunction · 0.85
telnet_setupFunction · 0.85

Calls 6

withClientLockFunction · 0.85
closeSessionLogUnlockedFunction · 0.85
getProtocolNameFunction · 0.85
millisFunction · 0.85
appendSessionLogUnlockedFunction · 0.85

Tested by

no test coverage detected