Skip to content

Commit

Permalink
WIP - Thu, Nov 23 10:33 PM
Browse files Browse the repository at this point in the history
  • Loading branch information
scott-rc committed Nov 24, 2023
1 parent 214af01 commit 8411cd8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/services/filesync/filesync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ export class FileSync {
readonly log = createLogger({
name: "filesync",
fields: () => ({
app: this.app.slug,
filesVersion: String(this.filesVersion),
mtime: this.mtime,
state: {
app: this.app.slug,
filesVersion: String(this.filesVersion),
mtime: this.mtime,
},
}),
});

Expand Down Expand Up @@ -357,6 +359,7 @@ export class FileSync {

const stats = await fs.stat(this.directory.absolute(normalizedPath));
if (stats.mtime.getTime() > this.mtime) {
this.log.trace("detected local change", { path: normalizedPath, mtime: stats.mtime.getTime() });
changes.set(normalizedPath, { type: "update" });
}
}
Expand Down Expand Up @@ -491,7 +494,7 @@ export class FileSync {
},
});

await this._save({ filesVersion: remoteFilesVersion, mtime: Date.now() });
await this._save({ filesVersion: remoteFilesVersion, mtime: Date.now() + 1 });

printlns`→ Sent {gray ${dayjs().format("hh:mm:ss A")}}`;
printChanges({ changes, tense: "present", limit: 10, mt: 0 });
Expand Down Expand Up @@ -561,7 +564,7 @@ export class FileSync {
}
});

await this._save({ filesVersion: String(filesVersion), mtime: Date.now() });
await this._save({ filesVersion: String(filesVersion), mtime: Date.now() + 1 });

return new Changes([
...created.map((path) => [path, { type: "create" }] as const),
Expand Down
15 changes: 9 additions & 6 deletions src/services/output/log/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,25 @@ export const createLogger = ({
}): Logger => {
const createLog = (level: Level): Log => {
return (msg, messageFields) => {
const shouldLog = alwaysEnabled || (config.debug && isLevelEnabled(level));
const shouldSendToSentry = level >= Level.INFO;
if (!shouldLog && !shouldSendToSentry) {
return;
}

const fields = { ...unthunk(globalFields), ...unthunk(loggerFields), ...messageFields };
if ("error" in fields) {
fields.error = serializeError(fields.error);
}

if (alwaysEnabled || (config.debug && isLevelEnabled(level))) {
if (shouldLog) {
const format = formatters[config.format];
stream.write(format(level, name, msg, fields));
}

if (level < Level.INFO) {
// don't send debug logs to Sentry
return;
if (shouldSendToSentry) {
addSentryBreadcrumb({ level: "log", message: msg, data: fields });
}

addSentryBreadcrumb({ level: "log", message: msg, data: fields });
};
};

Expand Down

0 comments on commit 8411cd8

Please sign in to comment.