mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
ft build: subcollection for logs
This commit is contained in:
@@ -88,8 +88,8 @@ app.post("/", jsonParser, async (req: any, res: any) => {
|
||||
});
|
||||
}
|
||||
|
||||
const streamLogger = createStreamLogger(configPath, Date.now());
|
||||
streamLogger("streamLogger created");
|
||||
const streamLogger = await createStreamLogger(configPath, Date.now());
|
||||
await streamLogger("streamLogger created");
|
||||
|
||||
const success = await generateConfig(configPath, user, streamLogger);
|
||||
if (!success) {
|
||||
@@ -100,7 +100,7 @@ app.post("/", jsonParser, async (req: any, res: any) => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
streamLogger("generateConfig success");
|
||||
await streamLogger("generateConfig success");
|
||||
|
||||
let hasEnvError = false;
|
||||
|
||||
|
||||
@@ -93,39 +93,26 @@ function parseSparksConfig(
|
||||
return "[]";
|
||||
}
|
||||
|
||||
function createStreamLogger(
|
||||
async function createStreamLogger(
|
||||
tableConfigPath: string,
|
||||
startTimeStamp: number
|
||||
// emitFn
|
||||
) {
|
||||
const fullLog: string[] = [];
|
||||
console.log("socketLogger created");
|
||||
const logRef = db
|
||||
.doc(tableConfigPath)
|
||||
.collection("ftBuildLogs")
|
||||
.doc(startTimeStamp.toString());
|
||||
await logRef.set({ startTimeStamp });
|
||||
console.log(
|
||||
`streamLogger created. tableConfigPath: ${tableConfigPath}, startTimeStamp: ${startTimeStamp}`
|
||||
);
|
||||
|
||||
return async (log: string) => {
|
||||
console.log(log);
|
||||
fullLog.push(log);
|
||||
await db.doc(tableConfigPath).update({
|
||||
ftBuild: {
|
||||
log,
|
||||
tableConfigPath,
|
||||
startTimeStamp,
|
||||
fullLog,
|
||||
},
|
||||
await logRef.update({
|
||||
fullLog,
|
||||
});
|
||||
// if (!emitFn) {
|
||||
// // await logErrorToDB({
|
||||
// // errorDescription: `Invalid socket (${configPath})`,
|
||||
// // user,
|
||||
// // });
|
||||
// } else {
|
||||
// fullLog.push(log);
|
||||
// emitFn("log", {
|
||||
// log,
|
||||
// tableConfigPath,
|
||||
// startTimeStamp,
|
||||
// fullLog,
|
||||
// });
|
||||
// }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user