mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-02 12:47:41 +02:00
Tools: Added syncDebugLog to help debugging sync operations
This commit is contained in:
parent
0ccd8dee41
commit
fb935dde18
@ -1638,6 +1638,9 @@ packages/lib/services/synchronizer/migrations/2.js.map
|
|||||||
packages/lib/services/synchronizer/migrations/3.d.ts
|
packages/lib/services/synchronizer/migrations/3.d.ts
|
||||||
packages/lib/services/synchronizer/migrations/3.js
|
packages/lib/services/synchronizer/migrations/3.js
|
||||||
packages/lib/services/synchronizer/migrations/3.js.map
|
packages/lib/services/synchronizer/migrations/3.js.map
|
||||||
|
packages/lib/services/synchronizer/syncDebugLog.d.ts
|
||||||
|
packages/lib/services/synchronizer/syncDebugLog.js
|
||||||
|
packages/lib/services/synchronizer/syncDebugLog.js.map
|
||||||
packages/lib/services/synchronizer/syncInfoUtils.d.ts
|
packages/lib/services/synchronizer/syncInfoUtils.d.ts
|
||||||
packages/lib/services/synchronizer/syncInfoUtils.js
|
packages/lib/services/synchronizer/syncInfoUtils.js
|
||||||
packages/lib/services/synchronizer/syncInfoUtils.js.map
|
packages/lib/services/synchronizer/syncInfoUtils.js.map
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1621,6 +1621,9 @@ packages/lib/services/synchronizer/migrations/2.js.map
|
|||||||
packages/lib/services/synchronizer/migrations/3.d.ts
|
packages/lib/services/synchronizer/migrations/3.d.ts
|
||||||
packages/lib/services/synchronizer/migrations/3.js
|
packages/lib/services/synchronizer/migrations/3.js
|
||||||
packages/lib/services/synchronizer/migrations/3.js.map
|
packages/lib/services/synchronizer/migrations/3.js.map
|
||||||
|
packages/lib/services/synchronizer/syncDebugLog.d.ts
|
||||||
|
packages/lib/services/synchronizer/syncDebugLog.js
|
||||||
|
packages/lib/services/synchronizer/syncDebugLog.js.map
|
||||||
packages/lib/services/synchronizer/syncInfoUtils.d.ts
|
packages/lib/services/synchronizer/syncInfoUtils.d.ts
|
||||||
packages/lib/services/synchronizer/syncInfoUtils.js
|
packages/lib/services/synchronizer/syncInfoUtils.js
|
||||||
packages/lib/services/synchronizer/syncInfoUtils.js.map
|
packages/lib/services/synchronizer/syncInfoUtils.js.map
|
||||||
|
@ -60,6 +60,7 @@ import editorCommandDeclarations from './gui/NoteEditor/editorCommandDeclaration
|
|||||||
import ShareService from '@joplin/lib/services/share/ShareService';
|
import ShareService from '@joplin/lib/services/share/ShareService';
|
||||||
import checkForUpdates from './checkForUpdates';
|
import checkForUpdates from './checkForUpdates';
|
||||||
import { AppState } from './app.reducer';
|
import { AppState } from './app.reducer';
|
||||||
|
import syncDebugLog from '../lib/services/synchronizer/syncDebugLog';
|
||||||
// import { runIntegrationTests } from '@joplin/lib/services/e2ee/ppkTestUtils';
|
// import { runIntegrationTests } from '@joplin/lib/services/e2ee/ppkTestUtils';
|
||||||
|
|
||||||
const pluginClasses = [
|
const pluginClasses = [
|
||||||
@ -355,7 +356,14 @@ class Application extends BaseApplication {
|
|||||||
|
|
||||||
reg.logger().info('app.start: doing regular boot');
|
reg.logger().info('app.start: doing regular boot');
|
||||||
|
|
||||||
const dir = Setting.value('profileDir');
|
const dir: string = Setting.value('profileDir');
|
||||||
|
|
||||||
|
syncDebugLog.enabled = false;
|
||||||
|
|
||||||
|
if (dir.endsWith('dev-desktop-2')) {
|
||||||
|
syncDebugLog.enabled = true;
|
||||||
|
syncDebugLog.info(`Profile dir: ${dir}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Loads app-wide styles. (Markdown preview-specific styles loaded in app.js)
|
// Loads app-wide styles. (Markdown preview-specific styles loaded in app.js)
|
||||||
const filename = Setting.custom_css_files.JOPLIN_APP;
|
const filename = Setting.custom_css_files.JOPLIN_APP;
|
||||||
|
@ -20,8 +20,7 @@ export enum LogLevel {
|
|||||||
Debug = 40,
|
Debug = 40,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Target {
|
interface TargetOptions {
|
||||||
type: TargetType;
|
|
||||||
level?: LogLevel;
|
level?: LogLevel;
|
||||||
database?: any;
|
database?: any;
|
||||||
console?: any;
|
console?: any;
|
||||||
@ -36,6 +35,10 @@ interface Target {
|
|||||||
formatInfo?: string;
|
formatInfo?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Target extends TargetOptions {
|
||||||
|
type: TargetType;
|
||||||
|
}
|
||||||
|
|
||||||
export interface LoggerWrapper {
|
export interface LoggerWrapper {
|
||||||
debug: Function;
|
debug: Function;
|
||||||
info: Function;
|
info: Function;
|
||||||
@ -103,11 +106,11 @@ class Logger {
|
|||||||
return this.targets_;
|
return this.targets_;
|
||||||
}
|
}
|
||||||
|
|
||||||
addTarget(type: TargetType, options: any = null) {
|
addTarget(type: TargetType, options: TargetOptions = null) {
|
||||||
const target = { type: type };
|
const target = { type: type };
|
||||||
for (const n in options) {
|
for (const n in options) {
|
||||||
if (!options.hasOwnProperty(n)) continue;
|
if (!options.hasOwnProperty(n)) continue;
|
||||||
(target as any)[n] = options[n];
|
(target as any)[n] = (options as any)[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.targets_.push(target);
|
this.targets_.push(target);
|
||||||
|
@ -25,6 +25,7 @@ import JoplinDatabase from './JoplinDatabase';
|
|||||||
import { fetchSyncInfo, getActiveMasterKey, localSyncInfo, mergeSyncInfos, saveLocalSyncInfo, SyncInfo, syncInfoEquals, uploadSyncInfo } from './services/synchronizer/syncInfoUtils';
|
import { fetchSyncInfo, getActiveMasterKey, localSyncInfo, mergeSyncInfos, saveLocalSyncInfo, SyncInfo, syncInfoEquals, uploadSyncInfo } from './services/synchronizer/syncInfoUtils';
|
||||||
import { getMasterPassword, setupAndDisableEncryption, setupAndEnableEncryption } from './services/e2ee/utils';
|
import { getMasterPassword, setupAndDisableEncryption, setupAndEnableEncryption } from './services/e2ee/utils';
|
||||||
import { generateKeyPair } from './services/e2ee/ppk';
|
import { generateKeyPair } from './services/e2ee/ppk';
|
||||||
|
import syncDebugLog from './services/synchronizer/syncDebugLog';
|
||||||
const { sprintf } = require('sprintf-js');
|
const { sprintf } = require('sprintf-js');
|
||||||
const { Dirnames } = require('./services/synchronizer/utils/types');
|
const { Dirnames } = require('./services/synchronizer/utils/types');
|
||||||
|
|
||||||
@ -197,7 +198,7 @@ export default class Synchronizer {
|
|||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
logSyncOperation(action: any, local: any = null, remote: RemoteItem = null, message: string = null, actionCount: number = 1) {
|
logSyncOperation(action: string, local: any = null, remote: RemoteItem = null, message: string = null, actionCount: number = 1) {
|
||||||
const line = ['Sync'];
|
const line = ['Sync'];
|
||||||
line.push(action);
|
line.push(action);
|
||||||
if (message) line.push(message);
|
if (message) line.push(message);
|
||||||
@ -225,6 +226,8 @@ export default class Synchronizer {
|
|||||||
logger.debug(line.join(': '));
|
logger.debug(line.join(': '));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!['fetchingProcessed', 'fetchingTotal'].includes(action)) syncDebugLog.info(line.join(': '));
|
||||||
|
|
||||||
if (!this.progressReport_[action]) this.progressReport_[action] = 0;
|
if (!this.progressReport_[action]) this.progressReport_[action] = 0;
|
||||||
this.progressReport_[action] += actionCount;
|
this.progressReport_[action] += actionCount;
|
||||||
this.progressReport_.state = this.state();
|
this.progressReport_.state = this.state();
|
||||||
|
@ -8,6 +8,7 @@ import BaseItem from './BaseItem';
|
|||||||
import Resource from './Resource';
|
import Resource from './Resource';
|
||||||
import { isRootSharedFolder } from '../services/share/reducer';
|
import { isRootSharedFolder } from '../services/share/reducer';
|
||||||
import Logger from '../Logger';
|
import Logger from '../Logger';
|
||||||
|
import syncDebugLog from '../services/synchronizer/syncDebugLog';
|
||||||
const { substrWithEllipsis } = require('../string-utils.js');
|
const { substrWithEllipsis } = require('../string-utils.js');
|
||||||
|
|
||||||
const logger = Logger.create('models/Folder');
|
const logger = Logger.create('models/Folder');
|
||||||
@ -651,6 +652,8 @@ export default class Folder extends BaseItem {
|
|||||||
if (o.title == Folder.conflictFolderTitle()) throw new Error(_('Notebooks cannot be named "%s", which is a reserved title.', o.title));
|
if (o.title == Folder.conflictFolderTitle()) throw new Error(_('Notebooks cannot be named "%s", which is a reserved title.', o.title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syncDebugLog.info('Folder Save:', o);
|
||||||
|
|
||||||
return super.save(o, options).then((folder: FolderEntity) => {
|
return super.save(o, options).then((folder: FolderEntity) => {
|
||||||
this.dispatch({
|
this.dispatch({
|
||||||
type: 'FOLDER_UPDATE_ONE',
|
type: 'FOLDER_UPDATE_ONE',
|
||||||
|
@ -10,6 +10,7 @@ import Tag from './Tag';
|
|||||||
|
|
||||||
const { sprintf } = require('sprintf-js');
|
const { sprintf } = require('sprintf-js');
|
||||||
import Resource from './Resource';
|
import Resource from './Resource';
|
||||||
|
import syncDebugLog from '../services/synchronizer/syncDebugLog';
|
||||||
const { pregQuote, substrWithEllipsis } = require('../string-utils.js');
|
const { pregQuote, substrWithEllipsis } = require('../string-utils.js');
|
||||||
const { _ } = require('../locale');
|
const { _ } = require('../locale');
|
||||||
const ArrayUtils = require('../ArrayUtils.js');
|
const ArrayUtils = require('../ArrayUtils.js');
|
||||||
@ -664,6 +665,8 @@ export default class Note extends BaseItem {
|
|||||||
// Trying to fix: https://github.com/laurent22/joplin/issues/3893
|
// Trying to fix: https://github.com/laurent22/joplin/issues/3893
|
||||||
const oldNote = !isNew && o.id ? await Note.load(o.id) : null;
|
const oldNote = !isNew && o.id ? await Note.load(o.id) : null;
|
||||||
|
|
||||||
|
syncDebugLog.info('Save Note: P:', oldNote);
|
||||||
|
|
||||||
let beforeNoteJson = null;
|
let beforeNoteJson = null;
|
||||||
if (oldNote && this.revisionService().isOldNote(o.id)) {
|
if (oldNote && this.revisionService().isOldNote(o.id)) {
|
||||||
beforeNoteJson = JSON.stringify(oldNote);
|
beforeNoteJson = JSON.stringify(oldNote);
|
||||||
@ -680,6 +683,8 @@ export default class Note extends BaseItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syncDebugLog.info('Save Note: N:', o);
|
||||||
|
|
||||||
const note = await super.save(o, options);
|
const note = await super.save(o, options);
|
||||||
|
|
||||||
const changeSource = options && options.changeSource ? options.changeSource : null;
|
const changeSource = options && options.changeSource ? options.changeSource : null;
|
||||||
|
13
packages/lib/services/synchronizer/syncDebugLog.ts
Normal file
13
packages/lib/services/synchronizer/syncDebugLog.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// The sync debug log can be used to view from a single file a sequence of sync
|
||||||
|
// related events. In particular, it logs notes and folders being saved, and the
|
||||||
|
// relevant sync operations.
|
||||||
|
|
||||||
|
import Logger, { TargetType } from '../../Logger';
|
||||||
|
import { homedir } from 'os';
|
||||||
|
|
||||||
|
const syncDebugLog = new Logger();
|
||||||
|
syncDebugLog.addTarget(TargetType.File, {
|
||||||
|
path: `${homedir()}/synclog.txt`,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default syncDebugLog;
|
Loading…
Reference in New Issue
Block a user