generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Debug logging in File.ts works; better logging (#2472)
* fix: Enable logging to work in File.ts, by delaying creation to execution * refactor: Extract function getFileLogger() * chore: Logging now shows inputs to replaceTaskWithTasks() * chore: Task logging is now debug(), not trace() - to match file-writing * chore: Add more logging to QueryRenderer * refactor: . Extract function logStartOfTaskEdit() * refactor: . Extract function logEndOfTaskEdit() * refactor: . Move logStartOfTaskEdit() & logEndOfTaskEdit() to LogTasksHelper.ts Preparing to re-use them. * fix: Remove accidental hard-coded string * chore: Add more detailed logging to Task.toggle() * refactor: . Move logging of task line number to logStartOfTaskEdit() And add quotes around the file name. * jsdoc: Document functions in LogTasksHelper.ts * comment: Document intended alignment of debug output
- Loading branch information
1 parent
5ed49e9
commit 978ffaf
Showing
4 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { Task } from '../Task'; | ||
import type { Logger } from './logging'; | ||
|
||
/** | ||
* Debug logging helper, for the start of Task-editing (or file-editing) operations | ||
* @param logger | ||
* @param codeLocation - a string description, such as 'callingFunctionName()'. | ||
* @param originalTask | ||
*/ | ||
export function logStartOfTaskEdit(logger: Logger, codeLocation: string, originalTask: Task) { | ||
logger.debug( | ||
`${codeLocation}: task line number: ${originalTask.taskLocation.lineNumber}. file path: "${originalTask.path}"`, | ||
); | ||
logger.debug(`${codeLocation} original: ${originalTask.originalMarkdown}`); | ||
} | ||
|
||
/** | ||
* Debug logging helper, for the completion of Task-editing (or file-editing) operations | ||
* @param logger | ||
* @param codeLocation - a string description, such as 'callingFunctionName()'. | ||
* @param newTasks | ||
*/ | ||
export function logEndOfTaskEdit(logger: Logger, codeLocation: string, newTasks: Task[]) { | ||
newTasks.map((task: Task, index: number) => { | ||
// Alignment of task lines is intentionally consistent between logStartOfTaskEdit() and this: | ||
logger.debug(`${codeLocation} ==> ${index + 1} : ${task.toFileLineString()}`); | ||
}); | ||
} |