Add more logs

This commit is contained in:
Andras Schmelczer 2025-01-06 22:25:51 +00:00
commit 4fc628ecef
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
3 changed files with 15 additions and 3 deletions

View file

@ -50,6 +50,10 @@ export class ObsidianFileEventHandler implements FileEventHandler {
public async onModify(file: TAbstractFile): Promise<void> { public async onModify(file: TAbstractFile): Promise<void> {
if (file instanceof TFile) { if (file instanceof TFile) {
if (file.basename.startsWith("console-log.iPhone")) {
return;
}
Logger.getInstance().info(`File modified: ${file.path}`); Logger.getInstance().info(`File modified: ${file.path}`);
await this.syncer.syncLocallyUpdatedFile({ await this.syncer.syncLocallyUpdatedFile({

View file

@ -8,21 +8,29 @@ export class ObsidianFileOperations implements FileOperations {
public constructor(private readonly vault: Vault) {} public constructor(private readonly vault: Vault) {}
public async listAllFiles(): Promise<RelativePath[]> { public async listAllFiles(): Promise<RelativePath[]> {
console.log("before getFiles");
const files = this.vault.getFiles(); const files = this.vault.getFiles();
console.log("after getFiles");
console.log(files);
return files.map((file) => file.path); return files.map((file) => file.path);
} }
public async read(path: RelativePath): Promise<Uint8Array> { public async read(path: RelativePath): Promise<Uint8Array> {
return new Uint8Array( console.log("before readBinary");
const result = new Uint8Array(
await this.vault.adapter.readBinary(normalizePath(path)) await this.vault.adapter.readBinary(normalizePath(path))
); );
console.log("after readBinary");
return result;
} }
public async getModificationTime(path: RelativePath): Promise<Date> { public async getModificationTime(path: RelativePath): Promise<Date> {
console.log("before stat");
const file = await this.vault.adapter.stat(normalizePath(path)); const file = await this.vault.adapter.stat(normalizePath(path));
if (!file) { if (!file) {
throw new Error(`File not found: ${path}`); throw new Error(`File not found: ${path}`);
} }
console.log("after stat");
return new Date(file.mtime); return new Date(file.mtime);
} }

View file

@ -98,7 +98,7 @@ export class SyncService {
Logger.getInstance().debug( Logger.getInstance().debug(
`Created document ${JSON.stringify( `Created document ${JSON.stringify(
response.data.relativePath response.data
)} with id ${response.data.documentId}` )} with id ${response.data.documentId}`
); );
@ -146,7 +146,7 @@ export class SyncService {
} }
Logger.getInstance().debug( Logger.getInstance().debug(
`Updated document ${response.data.relativePath} with id ${response.data.documentId}` `Updated document ${JSON.stringify(response.data)} with id ${response.data.documentId}`
); );
return response.data; return response.data;