diff --git a/scripts/migrate-to-droid-log.ts b/scripts/migrate-to-droid-log.ts new file mode 100755 index 000000000..3698b62a0 --- /dev/null +++ b/scripts/migrate-to-droid-log.ts @@ -0,0 +1,66 @@ +#!/usr/bin/env ts-node + +import * as fs from 'fs'; +import * as path from 'path'; + +const filesToMigrate = [ + 'src/app/core/persistence/android-db-adapter.service.ts', + 'src/app/features/android/android-interface.ts', + 'src/app/features/android/store/android.effects.ts', +]; + +function migrateFile(filePath: string): void { + console.log(`Processing ${filePath}...`); + + let content = fs.readFileSync(filePath, 'utf8'); + let modified = false; + + // Replace Log.* method calls with DroidLog.* + const logPattern = /\bLog\.(log|err|error|info|warn|debug|verbose|critical)\b/g; + if (logPattern.test(content)) { + content = content.replace(logPattern, 'DroidLog.$1'); + modified = true; + } + + // Update imports + if (modified) { + // Check if file already imports from log + if ( + content.includes("from '../../../../core/log'") || + content.includes('from "../../../core/log"') || + content.includes('from "../../core/log"') || + content.includes('from "../core/log"') || + content.includes("from '../../../../core/log'") || + content.includes("from '../../../core/log'") || + content.includes("from '../../core/log'") || + content.includes("from '../core/log'") + ) { + // Replace Log import with DroidLog + content = content.replace( + /import\s*{\s*([^}]*)\bLog\b([^}]*)\}\s*from\s*['"][^'"]*core\/log['"]/g, + (match, before, after) => { + const imports = (before + after) + .split(',') + .map((s) => s.trim()) + .filter((s) => s && s !== 'Log'); + imports.push('DroidLog'); + return `import { ${imports.join(', ')} } from '${match.includes('"') ? match.split('"')[1] : match.split("'")[1]}'`; + }, + ); + } else { + console.log(`Warning: Could not find log import in ${filePath}`); + } + } + + if (modified) { + fs.writeFileSync(filePath, content); + console.log(`✓ Migrated ${filePath}`); + } else { + console.log(`- No changes needed in ${filePath}`); + } +} + +// Process all files +filesToMigrate.forEach(migrateFile); + +console.log('\nMigration complete!'); diff --git a/scripts/migrate-to-task-log.ts b/scripts/migrate-to-task-log.ts new file mode 100755 index 000000000..42906ac2e --- /dev/null +++ b/scripts/migrate-to-task-log.ts @@ -0,0 +1,143 @@ +#!/usr/bin/env ts-node + +import * as fs from 'fs'; +import * as path from 'path'; +import * as glob from 'glob'; + +const taskFiles = glob.sync('src/app/features/tasks/**/*.ts', { + ignore: ['**/*.spec.ts', '**/node_modules/**'], +}); + +console.log(`Found ${taskFiles.length} task files to check`); + +let totalChanges = 0; + +function getRelativeImportPath(fromFile: string, toFile: string): string { + const fromDir = path.dirname(fromFile); + let relativePath = path.relative(fromDir, toFile).replace(/\\/g, '/'); + if (!relativePath.startsWith('.')) { + relativePath = './' + relativePath; + } + return relativePath.replace(/\.ts$/, ''); +} + +function migrateFile(filePath: string): void { + let content = fs.readFileSync(filePath, 'utf8'); + let modified = false; + let localChanges = 0; + + // Skip if file already uses TaskLog + if (content.includes('TaskLog')) { + return; + } + + // Replace console.* calls + const consolePatterns = [ + { pattern: /\bconsole\.log\(/g, replacement: 'TaskLog.log(' }, + { pattern: /\bconsole\.error\(/g, replacement: 'TaskLog.err(' }, + { pattern: /\bconsole\.info\(/g, replacement: 'TaskLog.info(' }, + { pattern: /\bconsole\.warn\(/g, replacement: 'TaskLog.warn(' }, + { pattern: /\bconsole\.debug\(/g, replacement: 'TaskLog.debug(' }, + ]; + + for (const { pattern, replacement } of consolePatterns) { + const matches = content.match(pattern); + if (matches) { + content = content.replace(pattern, replacement); + modified = true; + localChanges += matches.length; + } + } + + // Replace Log.* method calls with TaskLog.* + const logPattern = /\bLog\.(log|err|error|info|warn|debug|verbose|critical)\b/g; + const logMatches = content.match(logPattern); + if (logMatches) { + content = content.replace(logPattern, 'TaskLog.$1'); + modified = true; + localChanges += logMatches.length; + } + + // Update imports + if (modified) { + const logPath = getRelativeImportPath(filePath, 'src/app/core/log.ts'); + + // Check if file already imports from log + const importRegex = new RegExp( + `import\\s*{([^}]*)}\\s*from\\s*['"]${logPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}['"]`, + ); + const existingImport = content.match(importRegex); + + if (existingImport) { + // Update existing import + const imports = existingImport[1] + .split(',') + .map((s) => s.trim()) + .filter((s) => s && s !== 'Log'); + if (!imports.includes('TaskLog')) { + imports.push('TaskLog'); + } + content = content.replace( + importRegex, + `import { ${imports.join(', ')} } from '${logPath}'`, + ); + } else { + // Check for any Log import + const anyLogImport = content.match( + /import\s*{\s*([^}]*)\bLog\b([^}]*)\}\s*from\s*['"][^'"]*core\/log['"]/, + ); + if (anyLogImport) { + // Replace with TaskLog + content = content.replace( + /import\s*{\s*([^}]*)\bLog\b([^}]*)\}\s*from\s*['"][^'"]*core\/log['"]/g, + (match, before, after) => { + const imports = (before + after) + .split(',') + .map((s) => s.trim()) + .filter((s) => s && s !== 'Log'); + imports.push('TaskLog'); + const importPath = match.includes('"') + ? match.split('"')[1] + : match.split("'")[1]; + return `import { ${imports.join(', ')} } from '${importPath}'`; + }, + ); + } else if (!content.includes('TaskLog')) { + // Add new import at the top + const importStatement = `import { TaskLog } from '${logPath}';\n`; + + // Find the right place to insert the import + const firstImportMatch = content.match(/^import\s+/m); + if (firstImportMatch) { + const position = firstImportMatch.index!; + content = + content.slice(0, position) + importStatement + content.slice(position); + } else { + // If no imports, add after any leading comments + const afterComments = content.match(/^(\/\*[\s\S]*?\*\/|\/\/.*$)*/m); + if (afterComments) { + const position = afterComments[0].length; + content = + content.slice(0, position) + + (position > 0 ? '\n' : '') + + importStatement + + content.slice(position); + } else { + content = importStatement + content; + } + } + } + } + } + + if (modified) { + fs.writeFileSync(filePath, content); + console.log(`✓ ${filePath} (${localChanges} changes)`); + totalChanges += localChanges; + } +} + +// Process all files +taskFiles.forEach(migrateFile); + +console.log(`\nMigration complete! Total changes: ${totalChanges}`); diff --git a/src/app/core/log.ts b/src/app/core/log.ts index 3f0040722..c63fb4f8c 100644 --- a/src/app/core/log.ts +++ b/src/app/core/log.ts @@ -244,3 +244,6 @@ export const SyncLog = Log.withContext('sync'); export const PFLog = Log.withContext('pf'); export const PluginLog = Log.withContext('plugin'); export const IssueLog = Log.withContext('issue'); +export const DroidLog = Log.withContext('droid'); + +export const TaskLog = Log.withContext('task'); diff --git a/src/app/core/persistence/android-db-adapter.service.ts b/src/app/core/persistence/android-db-adapter.service.ts index 1099a62f3..fbe5ced49 100644 --- a/src/app/core/persistence/android-db-adapter.service.ts +++ b/src/app/core/persistence/android-db-adapter.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { androidInterface } from '../../features/android/android-interface'; -import { Log } from '../log'; +import { DroidLog } from '../log'; @Injectable({ providedIn: 'root', @@ -16,7 +16,7 @@ export class AndroidDbAdapterService { async load(key: string): Promise { const data = await androidInterface.loadFromDbWrapped(key); - Log.log('load', key, data); + DroidLog.log('load', key, data); return typeof data === 'string' ? JSON.parse((data as string).replace(/\n/g, '\\n')) @@ -24,7 +24,7 @@ export class AndroidDbAdapterService { } async save(key: string, data: unknown): Promise { - Log.log('save', key, data); + DroidLog.log('save', key, data); return await androidInterface.saveToDbWrapped(key, JSON.stringify(data)); } diff --git a/src/app/features/android/android-interface.ts b/src/app/features/android/android-interface.ts index ab1cb8222..4fe26d9f1 100644 --- a/src/app/features/android/android-interface.ts +++ b/src/app/features/android/android-interface.ts @@ -2,7 +2,7 @@ import { IS_ANDROID_WEB_VIEW } from '../../util/is-android-web-view'; import { nanoid } from 'nanoid'; import { BehaviorSubject, merge, Observable, Subject } from 'rxjs'; import { mapTo } from 'rxjs/operators'; -import { Log } from '../../core/log'; +import { DroidLog } from '../../core/log'; export interface AndroidInterface { getVersion?(): string; @@ -124,5 +124,5 @@ if (IS_ANDROID_WEB_VIEW) { delete requestMap[rId]; }; - Log.log('Android Web View interfaces initialized', androidInterface); + DroidLog.log('Android Web View interfaces initialized', androidInterface); } diff --git a/src/app/features/android/store/android.effects.ts b/src/app/features/android/store/android.effects.ts index e834a8e23..077545c2f 100644 --- a/src/app/features/android/store/android.effects.ts +++ b/src/app/features/android/store/android.effects.ts @@ -8,7 +8,7 @@ import { LocalNotifications } from '@capacitor/local-notifications'; import { SnackService } from '../../../core/snack/snack.service'; import { IS_ANDROID_WEB_VIEW } from '../../../util/is-android-web-view'; import { LocalNotificationSchema } from '@capacitor/local-notifications/dist/esm/definitions'; -import { Log } from '../../../core/log'; +import { DroidLog } from '../../../core/log'; // TODO send message to electron when current task changes here @@ -31,11 +31,11 @@ export class AndroidEffects { try { const checkResult = await LocalNotifications.checkPermissions(); if (checkResult.display === 'denied') { - Log.log(await LocalNotifications.requestPermissions()); - Log.log(await LocalNotifications.changeExactNotificationSetting()); + DroidLog.log(await LocalNotifications.requestPermissions()); + DroidLog.log(await LocalNotifications.changeExactNotificationSetting()); } } catch (error) { - Log.err(error); + DroidLog.err(error); this._snackService.open({ type: 'ERROR', msg: error?.toString() || 'Notifications not supported', @@ -59,7 +59,7 @@ export class AndroidEffects { const checkResult = await LocalNotifications.checkPermissions(); if (checkResult.display === 'granted') { const pendingNotifications = await LocalNotifications.getPending(); - Log.log({ pendingNotifications }); + DroidLog.log({ pendingNotifications }); if (pendingNotifications.notifications.length > 0) { await LocalNotifications.cancel({ notifications: pendingNotifications.notifications.map((n) => ({ @@ -91,7 +91,7 @@ export class AndroidEffects { }); } } catch (error) { - Log.err(error); + DroidLog.err(error); this._snackService.open({ type: 'ERROR', msg: error?.toString() || 'Notifications not supported', diff --git a/src/app/features/tasks/add-task-bar/add-task-bar.component.ts b/src/app/features/tasks/add-task-bar/add-task-bar.component.ts index 1c77a8c14..cc2baf936 100644 --- a/src/app/features/tasks/add-task-bar/add-task-bar.component.ts +++ b/src/app/features/tasks/add-task-bar/add-task-bar.component.ts @@ -47,7 +47,7 @@ import { TranslatePipe } from '@ngx-translate/core'; import { IssueIconPipe } from '../../issue/issue-icon/issue-icon.pipe'; import { TagComponent } from '../../tag/tag/tag.component'; import { TaskCopy } from '../task.model'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; @Component({ selector: 'add-task-bar', @@ -307,7 +307,7 @@ export class AddTaskBarComponent implements AfterViewInit, OnDestroy { const task = await this._taskService .getByIdOnce$(this._lastAddedTaskId) .toPromise(); - Log.log(additionalFields, tagsToRemove, task); + TaskLog.log(additionalFields, tagsToRemove, task); this._taskService.updateTags( task, diff --git a/src/app/features/tasks/add-task-bar/add-task-bar.service.ts b/src/app/features/tasks/add-task-bar/add-task-bar.service.ts index bd5058840..e06258302 100644 --- a/src/app/features/tasks/add-task-bar/add-task-bar.service.ts +++ b/src/app/features/tasks/add-task-bar/add-task-bar.service.ts @@ -30,7 +30,7 @@ import { T } from '../../../t.const'; import { IssueService } from '../../issue/issue.service'; import { assertTruthy } from '../../../util/assert-truthy'; import { DEFAULT_PROJECT_COLOR } from '../../work-context/work-context.const'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; @Injectable({ providedIn: 'root', @@ -185,7 +185,7 @@ export class AddTaskBarService { return item.taskId; } else if (item.taskId) { if (!item.projectId) { - Log.log(item); + TaskLog.log(item); throw new Error('Weird add task case1'); } this._projectService.moveTaskToTodayList(item.taskId, item.projectId); @@ -205,7 +205,7 @@ export class AddTaskBarService { item.issueType, this._workContextService.activeWorkContextId as string, ); - Log.log(res); + TaskLog.log(res); if (!res) { return await this._issueService.addTaskFromIssue({ issueProviderKey: item.issueType, @@ -306,7 +306,7 @@ export class AddTaskBarService { try { return !!task.title.toLowerCase().match(searchText.toLowerCase()); } catch (e) { - Log.err('RegEx Error', e); + TaskLog.err('RegEx Error', e); return false; } } diff --git a/src/app/features/tasks/add-task-bar/short-syntax-to-tags.ts b/src/app/features/tasks/add-task-bar/short-syntax-to-tags.ts index 69bc8b9e6..d9d06ac5c 100644 --- a/src/app/features/tasks/add-task-bar/short-syntax-to-tags.ts +++ b/src/app/features/tasks/add-task-bar/short-syntax-to-tags.ts @@ -9,7 +9,7 @@ import { Tag } from '../../tag/tag.model'; import { Project } from '../../project/project.model'; import { getWorklogStr } from '../../../util/get-work-log-str'; import { ShortSyntaxConfig } from '../../config/global-config.model'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; export interface ShortSyntaxTag { title: string; @@ -67,7 +67,7 @@ export const shortSyntaxToTags = ({ if (r.taskChanges.timeSpentOnDay && r.taskChanges.timeSpentOnDay[getWorklogStr()]) { time = msToString(r.taskChanges.timeSpentOnDay[getWorklogStr()]) + '/' + time; } - Log.log(time); + TaskLog.log(time); shortSyntaxTags.push({ title: time, diff --git a/src/app/features/tasks/dialog-task-detail-panel/dialog-task-detail-panel.component.ts b/src/app/features/tasks/dialog-task-detail-panel/dialog-task-detail-panel.component.ts index 11533ee67..51c1711a0 100644 --- a/src/app/features/tasks/dialog-task-detail-panel/dialog-task-detail-panel.component.ts +++ b/src/app/features/tasks/dialog-task-detail-panel/dialog-task-detail-panel.component.ts @@ -42,7 +42,7 @@ export class DialogTaskDetailPanelComponent implements OnDestroy { isSkipToggle: true, }), ); - // this.task$.subscribe((v) => Log.log(`task$`, v)); + // this.task$.subscribe((v) => TaskLog.log(`task$`, v)); } // close(): void { diff --git a/src/app/features/tasks/short-syntax.ts b/src/app/features/tasks/short-syntax.ts index c93342c79..9c0107fc0 100644 --- a/src/app/features/tasks/short-syntax.ts +++ b/src/app/features/tasks/short-syntax.ts @@ -284,15 +284,15 @@ const parseTagChanges = (task: Partial, allTags?: Tag[]): TagChanges = taskChanges.title = taskChanges.title.trim(); } - // Log.log(task.title); - // Log.log('newTagTitles', regexTagTitles); - // Log.log('newTagTitlesTrimmed', regexTagTitlesTrimmedAndFiltered); - // Log.log('allTags)', allTags.map(tag => `${tag.id}: ${tag.title}`)); - // Log.log('task.tagIds', task.tagIds); - // Log.log('task.title', task.title); + // TaskLog.log(task.title); + // TaskLog.log('newTagTitles', regexTagTitles); + // TaskLog.log('newTagTitlesTrimmed', regexTagTitlesTrimmedAndFiltered); + // TaskLog.log('allTags)', allTags.map(tag => `${tag.id}: ${tag.title}`)); + // TaskLog.log('task.tagIds', task.tagIds); + // TaskLog.log('task.title', task.title); } } - // Log.log(taskChanges); + // TaskLog.log(taskChanges); return { taskChanges, diff --git a/src/app/features/tasks/store/short-syntax.effects.ts b/src/app/features/tasks/store/short-syntax.effects.ts index dd5aa302d..8cc99a179 100644 --- a/src/app/features/tasks/store/short-syntax.effects.ts +++ b/src/app/features/tasks/store/short-syntax.effects.ts @@ -34,7 +34,7 @@ import { WorkContextService } from '../../work-context/work-context.service'; import { INBOX_PROJECT } from '../../project/project.const'; import { devError } from '../../../util/dev-error'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; @Injectable() export class ShortSyntaxEffects { @@ -110,7 +110,7 @@ export class ShortSyntaxEffects { projects, ); if (environment.production) { - Log.log('shortSyntax', r); + TaskLog.log('shortSyntax', r); } const isAddDefaultProjectIfNecessary: boolean = !!defaultProjectId && diff --git a/src/app/features/tasks/store/task-due.effects.ts b/src/app/features/tasks/store/task-due.effects.ts index 8ecdf16c9..366b495ee 100644 --- a/src/app/features/tasks/store/task-due.effects.ts +++ b/src/app/features/tasks/store/task-due.effects.ts @@ -19,7 +19,7 @@ import { selectTodayTaskIds } from '../../work-context/store/work-context.select import { AddTasksForTomorrowService } from '../../add-tasks-for-tomorrow/add-tasks-for-tomorrow.service'; import { getWorklogStr } from '../../../util/get-work-log-str'; import { environment } from '../../../../environments/environment'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; @Injectable() export class TaskDueEffects { @@ -99,7 +99,7 @@ export class TaskDueEffects { .map((task) => task.id); if (!environment.production && missingTaskIds.length > 0) { - Log.err( + TaskLog.err( '[TaskDueEffects] Found tasks due today missing from TODAY tag:', { tasksDueToday: tasksDueToday.length, diff --git a/src/app/features/tasks/store/task.reducer.ts b/src/app/features/tasks/store/task.reducer.ts index b48acd07d..8e8701555 100644 --- a/src/app/features/tasks/store/task.reducer.ts +++ b/src/app/features/tasks/store/task.reducer.ts @@ -57,7 +57,7 @@ import { PlannerActions } from '../../planner/store/planner.actions'; import { getWorklogStr } from '../../../util/get-work-log-str'; import { TaskSharedActions } from '../../../root-store/meta/task-shared.actions'; import { TimeTrackingActions } from '../../time-tracking/store/time-tracking.actions'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; export const TASK_FEATURE_NAME = 'tasks'; @@ -281,14 +281,14 @@ export const taskReducer = createReducer( on(moveSubTaskUp, (state, { id, parentId }) => { const parentTask = state.entities[parentId]; if (!parentTask) { - Log.err(`Parent task ${parentId} not found`); + TaskLog.err(`Parent task ${parentId} not found`); return state; } const parentSubTaskIds = parentTask.subTaskIds; // Check if the subtask is actually in the parent's subtask list if (!parentSubTaskIds.includes(id)) { - Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`); + TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`); return state; } @@ -306,14 +306,14 @@ export const taskReducer = createReducer( on(moveSubTaskDown, (state, { id, parentId }) => { const parentTask = state.entities[parentId]; if (!parentTask) { - Log.err(`Parent task ${parentId} not found`); + TaskLog.err(`Parent task ${parentId} not found`); return state; } const parentSubTaskIds = parentTask.subTaskIds; // Check if the subtask is actually in the parent's subtask list if (!parentSubTaskIds.includes(id)) { - Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`); + TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`); return state; } @@ -331,14 +331,14 @@ export const taskReducer = createReducer( on(moveSubTaskToTop, (state, { id, parentId }) => { const parentTask = state.entities[parentId]; if (!parentTask) { - Log.err(`Parent task ${parentId} not found`); + TaskLog.err(`Parent task ${parentId} not found`); return state; } const parentSubTaskIds = parentTask.subTaskIds; // Check if the subtask is actually in the parent's subtask list if (!parentSubTaskIds.includes(id)) { - Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`); + TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`); return state; } @@ -356,14 +356,14 @@ export const taskReducer = createReducer( on(moveSubTaskToBottom, (state, { id, parentId }) => { const parentTask = state.entities[parentId]; if (!parentTask) { - Log.err(`Parent task ${parentId} not found`); + TaskLog.err(`Parent task ${parentId} not found`); return state; } const parentSubTaskIds = parentTask.subTaskIds; // Check if the subtask is actually in the parent's subtask list if (!parentSubTaskIds.includes(id)) { - Log.err(`Subtask ${id} not found in parent ${parentId} subtasks`); + TaskLog.err(`Subtask ${id} not found in parent ${parentId} subtasks`); return state; } diff --git a/src/app/features/tasks/store/task.reducer.util.ts b/src/app/features/tasks/store/task.reducer.util.ts index 832742cef..8f8328a2a 100644 --- a/src/app/features/tasks/store/task.reducer.util.ts +++ b/src/app/features/tasks/store/task.reducer.util.ts @@ -11,7 +11,7 @@ import { calcTotalTimeSpent } from '../util/calc-total-time-spent'; import { taskAdapter } from './task.adapter'; import { filterOutId } from '../../../util/filter-out-id'; import { Update } from '@ngrx/entity'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; export const getTaskById = (taskId: string, state: TaskState): Task => { if (!state.entities[taskId]) { @@ -38,7 +38,9 @@ export const reCalcTimeSpentForParentIfParent = ( if (parentId) { const parentTask = state.entities[parentId]; if (!parentTask) { - Log.err(`Parent task ${parentId} not found in reCalcTimeSpentForParentIfParent`); + TaskLog.err( + `Parent task ${parentId} not found in reCalcTimeSpentForParentIfParent`, + ); return state; } @@ -82,7 +84,9 @@ export const reCalcTimeEstimateForParentIfParent = ( ): TaskState => { const parentTask = state.entities[parentId]; if (!parentTask) { - Log.err(`Parent task ${parentId} not found in reCalcTimeEstimateForParentIfParent`); + TaskLog.err( + `Parent task ${parentId} not found in reCalcTimeEstimateForParentIfParent`, + ); return state; } @@ -94,9 +98,9 @@ export const reCalcTimeEstimateForParentIfParent = ( return upd && upd.id === id ? { ...task, ...upd.changes } : task; }) .filter((task): task is Task => !!task); - // Log.log( + // TaskLog.log( // subTasks.reduce((acc: number, st: Task) => { - // Log.log( + // TaskLog.log( // (st.isDone ? 0 : Math.max(0, st.timeEstimate - st.timeSpent)) / 60 / 1000, // ); // diff --git a/src/app/features/tasks/task-attachment/task-attachment.service.ts b/src/app/features/tasks/task-attachment/task-attachment.service.ts index 54ae09fdd..0cbfc585e 100644 --- a/src/app/features/tasks/task-attachment/task-attachment.service.ts +++ b/src/app/features/tasks/task-attachment/task-attachment.service.ts @@ -12,7 +12,7 @@ import { } from './task-attachment.actions'; import { TaskState } from '../task.model'; import { createFromDrop } from 'src/app/core/drop-paste-input/drop-paste-input'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; @Injectable({ providedIn: 'root', @@ -23,7 +23,7 @@ export class TaskAttachmentService { addAttachment(taskId: string, taskAttachment: TaskAttachment): void { if (!taskAttachment) { - Log.err('No valid attachment passed'); + TaskLog.err('No valid attachment passed'); return; } diff --git a/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.ts b/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.ts index a1c7e53de..1a1c396ed 100644 --- a/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.ts +++ b/src/app/features/tasks/task-context-menu/task-context-menu-inner/task-context-menu-inner.component.ts @@ -70,7 +70,7 @@ import { TaskSharedActions } from '../../../../root-store/meta/task-shared.actio import { selectTodayTagTaskIds } from '../../../tag/store/tag.reducer'; import { isToday } from '../../../../util/is-today.util'; import { MenuTouchFixDirective } from '../menu-touch-fix.directive'; -import { Log } from '../../../../core/log'; +import { TaskLog } from '../../../../core/log'; @Component({ selector: 'task-context-menu-inner', @@ -404,7 +404,7 @@ export class TaskContextMenuInnerComponent implements AfterViewInit { archiveInstances, targetProject, ]) => { - Log.log({ + TaskLog.log({ reminderCfg, nonArchiveInstancesWithSubTasks, archiveInstances, @@ -537,7 +537,7 @@ export class TaskContextMenuInnerComponent implements AfterViewInit { private async _schedule(selectedDate: Date, isRemoveFromToday = false): Promise { if (!selectedDate) { - Log.err('no selected date'); + TaskLog.err('no selected date'); return; } diff --git a/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts b/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts index 1013fcbc0..6d7d86c2f 100644 --- a/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts +++ b/src/app/features/tasks/task-detail-panel/task-detail-panel.component.ts @@ -308,9 +308,9 @@ export class TaskDetailPanelComponent implements OnInit, AfterViewInit, OnDestro } }); } - // this.issueIdAndType$.subscribe((v) => Log.log('issueIdAndType$', v)); - // this.issueDataTrigger$.subscribe((v) => Log.log('issueDataTrigger$', v)); - // this.issueData$.subscribe((v) => Log.log('issueData$', v)); + // this.issueIdAndType$.subscribe((v) => TaskLog.log('issueIdAndType$', v)); + // this.issueDataTrigger$.subscribe((v) => TaskLog.log('issueDataTrigger$', v)); + // this.issueData$.subscribe((v) => TaskLog.log('issueData$', v)); // NOTE: check work-view component for more info } diff --git a/src/app/features/tasks/task-list/task-list.component.ts b/src/app/features/tasks/task-list/task-list.component.ts index 3c42e6569..736332d15 100644 --- a/src/app/features/tasks/task-list/task-list.component.ts +++ b/src/app/features/tasks/task-list/task-list.component.ts @@ -37,7 +37,7 @@ import { MatIcon } from '@angular/material/icon'; import { TaskComponent } from '../task/task.component'; import { AsyncPipe } from '@angular/common'; import { TaskViewCustomizerService } from '../../task-view-customizer/task-view-customizer.service'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; export type TaskListId = 'PARENT' | 'SUB'; export type ListModelId = DropListModelSource | string; @@ -132,7 +132,7 @@ export class TaskListComponent implements OnDestroy, AfterViewInit { // const targetModelId = drag.dropContainer.data.listModelId; const targetModelId = drop.data.listModelId; const isSubtask = !!task.parentId; - // Log.log(drag.data.id, { isSubtask, targetModelId, drag, drop }); + // TaskLog.log(drag.data.id, { isSubtask, targetModelId, drag, drop }); // return true; if (targetModelId === 'OVERDUE' || targetModelId === 'LATER_TODAY') { return false; @@ -159,7 +159,7 @@ export class TaskListComponent implements OnDestroy, AfterViewInit { const srcListData = ev.previousContainer.data; const targetListData = ev.container.data; const draggedTask = ev.item.data; - Log.log({ + TaskLog.log({ ev, srcListData, targetListData, @@ -221,7 +221,7 @@ export class TaskListComponent implements OnDestroy, AfterViewInit { ...targetListData.filteredTasks.filter((t) => t.id !== draggedTask.id), draggedTask, ]; - Log.log(srcListData.listModelId, '=>', targetListData.listModelId, { + TaskLog.log(srcListData.listModelId, '=>', targetListData.listModelId, { targetTask, draggedTask, newIds, diff --git a/src/app/features/tasks/task.service.ts b/src/app/features/tasks/task.service.ts index cc1640865..adeb6c21f 100644 --- a/src/app/features/tasks/task.service.ts +++ b/src/app/features/tasks/task.service.ts @@ -87,7 +87,7 @@ import { TaskSharedActions } from '../../root-store/meta/task-shared.actions'; import { getWorklogStr } from '../../util/get-work-log-str'; import { INBOX_PROJECT } from '../project/project.const'; import { GlobalConfigService } from '../config/global-config.service'; -import { Log } from '../../core/log'; +import { TaskLog } from '../../core/log'; @Injectable({ providedIn: 'root', @@ -285,7 +285,7 @@ export class TaskService { workContextId, }); - Log.log(task, additional); + TaskLog.log(task, additional); this._store.dispatch( TaskSharedActions.addTask({ diff --git a/src/app/features/tasks/task/task.component.ts b/src/app/features/tasks/task/task.component.ts index f67bd76bd..c1dcce2d8 100644 --- a/src/app/features/tasks/task/task.component.ts +++ b/src/app/features/tasks/task/task.component.ts @@ -85,7 +85,7 @@ import { TaskSharedActions } from '../../../root-store/meta/task-shared.actions' import { environment } from '../../../../environments/environment'; import { TODAY_TAG } from '../../tag/tag.const'; import { GlobalTrackingIntervalService } from '../../../core/global-tracking-interval/global-tracking-interval.service'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; @Component({ selector: 'task', @@ -597,7 +597,7 @@ export class TaskComponent implements OnDestroy, AfterViewInit { focusTitleForEdit(): void { const taskTitleEditEl = this.taskTitleEditEl(); if (!taskTitleEditEl || !taskTitleEditEl.textarea().nativeElement) { - Log.log(taskTitleEditEl); + TaskLog.log(taskTitleEditEl); throw new Error('No el'); } taskTitleEditEl.textarea().nativeElement.focus(); @@ -711,7 +711,7 @@ export class TaskComponent implements OnDestroy, AfterViewInit { archiveInstances, targetProject, ]) => { - Log.log({ + TaskLog.log({ reminderCfg, nonArchiveInstancesWithSubTasks, archiveInstances, diff --git a/src/app/features/tasks/util/play-done-sound.ts b/src/app/features/tasks/util/play-done-sound.ts index cd892be0f..248c23da6 100644 --- a/src/app/features/tasks/util/play-done-sound.ts +++ b/src/app/features/tasks/util/play-done-sound.ts @@ -1,5 +1,5 @@ import { SoundConfig } from '../../config/global-config.model'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; export const playDoneSound = (soundCfg: SoundConfig, nrOfDoneTasks: number = 0): void => { const speed = 1; @@ -8,13 +8,13 @@ export const playDoneSound = (soundCfg: SoundConfig, nrOfDoneTasks: number = 0): const file = `${BASE}/${soundCfg.doneSound}`; // const speed = 0.5; // const a = new Audio('/assets/snd/done4.mp3'); - // Log.log(a); + // TaskLog.log(a); // a.volume = .4; // a.playbackRate = 1.5; // (a as any).mozPreservesPitch = false; // (a as any).webkitPreservesPitch = false; // a.play(); - Log.log(file); + TaskLog.log(file); const pitchFactor = soundCfg.isIncreaseDoneSoundPitch ? // prettier-ignore diff --git a/src/app/features/tasks/util/remind-option-to-milliseconds.ts b/src/app/features/tasks/util/remind-option-to-milliseconds.ts index d551d8669..d64da14e3 100644 --- a/src/app/features/tasks/util/remind-option-to-milliseconds.ts +++ b/src/app/features/tasks/util/remind-option-to-milliseconds.ts @@ -1,6 +1,6 @@ import { TaskReminderOptionId } from '../task.model'; import { devError } from '../../../util/dev-error'; -import { Log } from '../../../core/log'; +import { TaskLog } from '../../../core/log'; export const remindOptionToMilliseconds = ( due: number, @@ -55,7 +55,7 @@ export const millisecondsDiffToRemindOption = ( } else if (diff <= 0) { return TaskReminderOptionId.AtStart; } else { - Log.log(due, remindAt); + TaskLog.log(due, remindAt); devError('Cannot determine remind option. Invalid params'); return TaskReminderOptionId.DoNotRemind; }