chore: [log]More logs#357
Conversation
|
Note
详情{
"src/editorapplication.cpp": [
{
"line": " const QString acknowledgementLink = \"https://www.deepin.org/original/deepin-editor/\";",
"line_number": 14,
"rule": "S35",
"reason": "Url link | 6859e7727a"
}
],
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 376,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
Reviewer's GuideThis PR adds extensive logging instrumentation across the codebase—using qDebug, qInfo, and qWarning—to capture method entries/exits, parameter values, branch outcomes, and error conditions without altering business logic. Class Diagram for common/settings.cpp: Logging UpdatesclassDiagram
class CustemBackend {
+CustemBackend(QString filepath, QObject *parent) "+ logging added"
+doSync() "+ logging added"
+doSetOption(QString key, QVariant value) "+ logging added"
+QStringList keys() const "+ logging added"
+QVariant getOption(QString key) const "+ logging added"
+~CustemBackend() "+ logging added"
}
class Settings {
+Settings(QWidget *parent) "+ logging added"
+setSavePath(int id, QString path) "+ logging added"
+QString getSavePath(int id) "+ logging added"
+setSavePathId(int id) "+ logging added"
+~Settings() "+ logging added"
+setSettingDialog(DSettingsDialog *settingsDialog) "+ logging added"
+dtkThemeWorkaround(QWidget *parent, QString theme) "+ logging added"
+createSavingPathWgt(QObject* obj) "+ logging added"
+instance() "+ logging added"
+updateAllKeysWithKeymap(QString keymap) "+ logging added"
+removeLockFiles() "+ logging added"
+slotsigAdjustFont(QVariant value) "+ logging added"
+slotsigAdjustFontSize(QVariant value) "+ logging added"
+slotsigAdjustWordWrap(QVariant value) "+ logging added"
+slotsigSetLineNumberShow(QVariant value) "+ logging added"
+slotsigAdjustBookmark(QVariant value) "+ logging added"
+slotsigShowCodeFlodFlag(QVariant value) "+ logging added"
+slotsigShowBlankCharacter(QVariant value) "+ logging added"
+slotsigHightLightCurrentLine(QVariant value) "+ logging added"
+slotsigAdjustTabSpaceNumber(QVariant value) "+ logging added"
}
Class Diagram for editor/dtextedit.cpp: Logging UpdatesclassDiagram
class TextEdit {
+TextEdit(QWidget *parent) "+ logging added"
+~TextEdit() "+ logging added"
+insertTextEx(QTextCursor cursor, QString text) "+ logging added"
+insertMultiTextEx(QList~QPair~QTextCursor, QString~~ multiText) "+ logging added"
+deleteSelectTextEx(QTextCursor cursor) "+ logging added"
+deleteTextEx(QTextCursor cursor) "+ logging added"
+moveLineDownUp(bool up) "+ logging added"
+replaceAll(QString replaceText, QString withText, Qt::CaseSensitivity caseFlag) "+ logging added"
+replaceRest(QString replaceText, QString withText, Qt::CaseSensitivity caseFlag) "+ logging added"
+findKeywordForward(QString keyword) "+ logging added"
+redo_() "+ logging added"
+undo_() "+ logging added"
+findCursor(QString substr, QString text, int from, bool backward, int cursorPos, Qt::CaseSensitivity caseFlag) "+ logging added"
}
Class Diagram for editor/editwrapper.cpp: Logging UpdatesclassDiagram
class EditWrapper {
+setQuitFlag() "+ logging added"
+isQuit() "+ logging added"
+openFile(QString filepath, QString qstrTruePath, bool bIsTemFile) "+ logging added"
+readFile(QByteArray encode) "+ logging added"
+saveAsFile(QString newFilePath, QByteArray encodeName) "+ logging added"
+reloadFileEncode(QByteArray encode) "+ logging added"
+reloadFileHighlight(QString definitionName) "+ logging added"
+handleFileLoadFinished(QByteArray encode, QByteArray content, bool error) "+ logging added"
+updateModifyStatus(bool bModified) "+ logging added"
}
Class Diagram for controls/findbar.cpp: Logging UpdatesclassDiagram
class FindBar {
+FindBar(QWidget *parent) "+ logging added"
+activeInput(QString text, QString file, int row, int column, int scrollOffset) "+ logging added"
+findCancel() "+ logging added"
+handleContentChanged() "+ logging added"
+handleFindPrev() "+ logging added"
+handleFindNext() "+ logging added"
+hideEvent(QHideEvent *event) "+ logging added"
+keyPressEvent(QKeyEvent *e) "+ logging added"
+updateSizeMode() "+ logging added"
+setMismatchAlert(bool isAlert) "+ logging added"
+setSearched(bool searched) "+ logging added"
}
Class Diagram for common/iflytek_ai_assistant.cpp: Logging UpdatesclassDiagram
class IflytekAiAssistant {
+IflytekAiAssistant(QObject *parent) "+ logging added"
+CallStatus checkValid() "+ logging added"
+CallStatus isTtsInWorking() const "+ logging added"
+CallStatus isTtsEnable() const "+ logging added"
+CallStatus textToSpeech() "+ logging added"
+CallStatus stopTtsDirectly() const "+ logging added"
+CallStatus stopTtsDirectlyInternal() const "+ logging added"
+CallStatus getIatEnable() const "+ logging added"
+CallStatus speechToText() "+ logging added"
+CallStatus getTransEnable() const "+ logging added"
+CallStatus textToTranslate() "+ logging added"
+QString errorString(CallStatus ret) const "+ logging added"
+CallStatus isCopilotEnabled(QSharedPointer~QDBusInterface~ copilot) "+ logging added"
+checkAiExists() "+ logging added"
}
Class Diagram for common/utils.cpp: Logging UpdatesclassDiagram
class Utils {
<<static>> +QString getQrcPath(QString imageName) "+ logging added"
<<static>> +QString getQssPath(QString qssName) "+ logging added"
<<static>> +bool fileExists(QString path) "+ logging added"
<<static>> +bool fileIsWritable(QString path) "+ logging added"
<<static>> +QVariantMap getThemeMapFromPath(QString filepath) "+ logging added"
<<static>> +bool getSystemMemoryInfo(qlonglong totalMemory, qlonglong freeMemory) "+ logging added"
<<static>> +bool isMemorySufficientForOperation(OperationType operationType, qlonglong operationDataSize, qlonglong currentDocumentSize) "+ logging added"
}
Class Diagram for encodes/detectcode.cpp: Logging UpdatesclassDiagram
class DetectCode {
+QByteArray GetFileEncodingFormat(QString filepath, QByteArray content) "+ logging added"
+QByteArray UchardetCode(QString filepath) "+ logging added"
+void icuDetectTextEncoding(QString filePath, QByteArrayList listDetectRet) "+ logging added"
+bool detectTextEncoding(char *data, size_t len, char **detected, QByteArrayList listDetectRet) "+ logging added"
+QByteArray selectCoding(QByteArray ucharDetectdRet, QByteArrayList icuDetectRetList, float confidence) "+ logging added"
+bool ChangeFileEncodingFormat(QByteArray inputStr, QByteArray outStr, QString fromCode, QString toCode) "+ logging added"
+bool convertEncodingTextCodec(QByteArray inputStr, QByteArray outStr, QString fromCode, QString toCode) "+ logging added"
}
Class Diagram for startmanager.cpp: Logging UpdatesclassDiagram
class StartManager {
+StartManager *instance() "+ logging added"
+StartManager(QObject *parent) "+ logging added"
+bool checkPath(QString file) "+ logging added"
+void autoBackupFile() "+ logging added"
+int recoverFile(Window *window) "+ logging added"
+void openFilesInWindow(QStringList files) "+ logging added"
+void openFilesInTab(QStringList files) "+ logging added"
+Window *createWindow(bool alwaysCenter) "+ logging added"
+void slotCloseWindow() "+ logging added"
+void initBlockShutdown() "+ logging added"
+void slotCheckUnsaveTab() "+ logging added"
}
Class Diagram for editor/undolist.cpp: Logging UpdatesclassDiagram
class UndoList {
+UndoList() "+ logging added"
+~UndoList() "+ logging added"
+void appendCom(QUndoCommand* com) "+ logging added"
+void undo() "+ logging added"
+void redo() "+ logging added"
}
Class Diagram for controls/replacebar.cpp: Logging UpdatesclassDiagram
class ReplaceBar {
+ReplaceBar(QWidget *parent) "+ logging added"
+activeInput(QString text, QString file, int row, int column, int scrollOffset) "+ logging added"
+handleReplaceNext() "+ logging added"
+updateSizeMode() "+ logging added"
}
Class Diagram for editor/deletebackcommond.cpp: Logging UpdatesclassDiagram
class DeleteBackCommand {
+DeleteBackCommand(QTextCursor cursor, QPlainTextEdit *edit) "+ logging added"
+~DeleteBackCommand() "+ logging added"
+void undo() "+ logging added"
+void redo() "+ logging added"
}
class DeleteBackAltCommand {
+DeleteBackAltCommand(QList~QTextEdit::ExtraSelection~ selections, bool backward, QPlainTextEdit *edit) "+ logging added"
+~DeleteBackAltCommand() "+ logging added"
+void undo() "+ logging added"
+void redo() "+ logging added"
}
Class Diagram for widgets/ddropdownmenu.cpp: Logging UpdatesclassDiagram
class DDropdownMenu {
+DDropdownMenu(QWidget *parent) "+ logging added"
+~DDropdownMenu() "+ logging added"
+createEncodeMenu() "+ logging added in internal lambda"
+createHighLightMenu() "+ logging added in internal lambdas"
+eventFilter(QObject *object, QEvent *event) "+ logging added"
}
Class Diagram for common/text_file_saver.cpp: Logging UpdatesclassDiagram
class TextFileSaver {
+TextFileSaver(QTextDocument *document) "+ logging added"
+void setFilePath(QString filePath) "+ logging added"
+void setEncoding(QByteArray toEncode) "+ logging added"
+bool save() "+ logging added"
+bool saveAs(QString newFilePath) "+ logging added"
+bool saveToFile(QFileDevice file) "+ logging added"
+bool convertEncoding(QByteArray input, QByteArray output) const "+ logging added"
}
Class Diagram for editor/inserttextundocommand.cpp: Logging UpdatesclassDiagram
class InsertTextUndoCommand {
+InsertTextUndoCommand(QTextCursor textcursor, QString text, QPlainTextEdit *edit) "+ logging added"
+InsertTextUndoCommand(QList~QTextEdit::ExtraSelection~ selections, QString text, QPlainTextEdit *edit) "+ logging added"
+void undo() "+ logging added"
+void redo() "+ logging added"
}
class MidButtonInsertTextUndoCommand {
+MidButtonInsertTextUndoCommand(QTextCursor textcursor, QString text, TextEdit *edit) "+ logging added"
+void undo() "+ logging added"
+void redo() "+ logging added"
}
class DragInsertTextUndoCommand {
+DragInsertTextUndoCommand(QTextCursor textcursor, QString text, TextEdit *edit) "+ logging added"
+void undo() "+ logging added"
+void redo() "+ logging added"
}
Class Diagram for common/fileloadthread.cpp: Logging UpdatesclassDiagram
class FileLoadThread {
+FileLoadThread(QString filepath, QObject *parent) "+ logging added"
+~FileLoadThread() "+ logging added"
+void run() "+ logging added"
}
Class Diagram for controls/jumplinebar.cpp: Logging UpdatesclassDiagram
class JumpLineBar {
+JumpLineBar(DFloatingWidget *parent) "+ logging added"
+void focus() "+ logging added"
+void activeInput(QString file, int row, int column, int lineCount, int scrollOffset) "+ logging added"
+void updateSizeMode() "+ logging added"
}
Class Diagram for controls/tabbar.cpp: Logging UpdatesclassDiagram
class Tabbar {
+Tabbar(QWidget *parent) "+ logging added"
+void addTab(QString filePath, QString tabName, QString tipPath) "+ logging added"
+void closeTab(int index) "+ logging added"
+void updateTab(int index, QString filePath, QString tabName) "+ logging added"
+void onTabDrapStart() "+ logging added"
}
Class Diagram for controls/linebar.cpp: Logging UpdatesclassDiagram
class LineBar {
+LineBar(DLineEdit *parent) "+ logging added"
+void handleTextChangeTimer() "+ logging added"
+void handleTextChanged(QString str) "+ logging added"
+void focusOutEvent(QFocusEvent *e) "+ logging added"
+void keyPressEvent(QKeyEvent *e) "+ logging added"
}
Class Diagram for editor/FlashTween.cpp: Logging UpdatesclassDiagram
class FlashTween {
+FlashTween() "+ logging added"
+~FlashTween() "+ logging added"
+void startY(qreal t, qreal b, qreal c, qreal d, FunSlideInertial f) "+ logging added"
+void startX(qreal t, qreal b, qreal c, qreal d, FunSlideInertial f) "+ logging added"
+void __runY() "+ logging added"
+void __runX() "+ logging added"
}
Class Diagram for editor/insertblockbytextcommond.cpp: Logging UpdatesclassDiagram
class InsertBlockByTextCommand {
+InsertBlockByTextCommand(QString text, TextEdit *edit, EditWrapper* wrapper) "+ logging added"
+~InsertBlockByTextCommand() "+ logging added"
+void redo() "+ logging added"
+void undo() "+ logging added"
+void insertByBlock() "+ logging added"
}
Class Diagram for editor/showflodcodewidget.cpp: Logging UpdatesclassDiagram
class ShowFlodCodeWidget {
+ShowFlodCodeWidget(DWidget *parent) "+ logging added"
+~ShowFlodCodeWidget() "+ logging added"
+void clear() "+ logging added"
+void initHighLight(QString filepath, bool bIsLight) "+ logging added"
+void setStyle(bool bIsLineWrap) "+ logging added"
+void hideFirstBlock() "+ logging added"
+void appendText(QString strText, int maxWidth) "+ logging added"
}
Class Diagram for editorapplication.cpp: Logging UpdatesclassDiagram
class EditorApplication {
+EditorApplication(int &argc, char *argv[]) "+ logging added"
+~EditorApplication() "+ logging added"
+void handleQuitAction() "+ logging added"
+bool notify(QObject *object, QEvent *event) "+ logging added"
+void pressSpace(DPushButton *pushButton) "+ logging added"
}
Class Diagram for widgets/pathsettintwgt.cpp: Logging UpdatesclassDiagram
class PathSettingWgt {
+PathSettingWgt(QWidget* parent) "+ logging added"
+~PathSettingWgt() "+ logging added"
+void onBoxClicked(int id) "+ logging added"
+void onBtnClicked() "+ logging added"
}
Class Diagram for widgets/window.cpp: Logging UpdatesclassDiagram
class Window {
+Window(DMainWindow *parent) "+ logging added"
+~Window() "+ logging added"
+void showCenterWindow(bool bIsCenter) "+ logging added"
+void openFile() "+ logging added"
+bool saveFile() "+ logging added"
+void loadTheme(QString path) "+ logging added"
}
Class Diagram for common/eventlogutils.cpp: Logging UpdatesclassDiagram
class Eventlogutils {
+Eventlogutils *GetInstance() "+ logging added"
+void writeLogs(QJsonObject data) "+ logging added"
+Eventlogutils() "+ logging added"
}
Class Diagram for editor/uncommentselection.cpp: Logging UpdatesclassDiagram
class CommentDefinition {
+CommentDefinition() "+ logging added"
+void setComments(QString singleLineComment, QString multiLineCommentStart, QString multiLineCommentEnd) "+ logging added"
}
Class Diagram for common/config.cpp: Logging UpdatesclassDiagram
class ConfigModule {
<<static>> +bool detectIconvUse2005Standard() "+ logging added"
}
class Config {
+Config(QObject *parent) "+ logging added"
+~Config() "+ logging added"
+Config *instance() "+ logging added"
}
Class Diagram for editor/indenttextcommond.cpp: Logging UpdatesclassDiagram
class IndentTextCommand {
+IndentTextCommand(TextEdit* edit, int startpos, int endpos, int startline, int endline) "+ logging added"
+~IndentTextCommand() "+ logging added"
+void redo() "+ logging added"
+void undo() "+ logging added"
}
Class Diagram for main.cpp: Logging UpdatesclassDiagram
class ApplicationMain {
<<static>> +int main(int argc, char *argv[]) "+ logging added"
<<static>> +lambda_DGuiApplicationHelper_sizeModeChanged() "+ logging added"
}
Class Diagram for widgets/ColorSelectWdg.cpp: Logging UpdatesclassDiagram
class ColorSelectWdg {
+ColorSelectWdg(QString text, QWidget *parent) "+ logging added"
+~ColorSelectWdg() "+ logging added"
+void initWidget() "+ logging added in internal lambda"
}
Class Diagram for editor/replaceallcommond.cpp: Logging UpdatesclassDiagram
class ReplaceAllCommand {
+ReplaceAllCommand(QString oldText, QString newText, QTextCursor cursor, QUndoCommand *parent) "+ logging added"
+~ReplaceAllCommand() "+ logging added"
+void redo() "+ logging added"
+void undo() "+ logging added"
}
Class Diagram for thememodule/themelistview.cpp: Logging UpdatesclassDiagram
class ThemeListView {
+ThemeListView(QWidget *parent) "+ logging added"
+~ThemeListView() "+ logging added"
+void adjustScrollbarMargins() "+ logging added"
+bool eventFilter(QObject *obj, QEvent *event) "+ logging added"
+void selectionChanged(QItemSelection selected, QItemSelection deselected) "+ logging added"
}
Class Diagram for editor/endlineformatcommond.cpp: Logging UpdatesclassDiagram
class EndlineFormartCommand {
+EndlineFormartCommand(TextEdit* edit, BottomBar* bar, BottomBar::EndlineFormat from, BottomBar::EndlineFormat to) "+ logging added"
+~EndlineFormartCommand() "+ logging added"
+void undo() "+ logging added"
+void redo() "+ logging added"
}
Class Diagram for thememodule/themeitemdelegate.cpp: Logging UpdatesclassDiagram
class ThemeItemDelegate {
+ThemeItemDelegate(QObject *parent) "+ logging added"
+~ThemeItemDelegate() "+ logging added"
+void paint(QPainter *painter, QStyleOptionViewItem option, QModelIndex index) const "+ logging added"
+QSize sizeHint(QStyleOptionViewItem option, QModelIndex index) const "+ logging added"
}
Class Diagram for thememodule/themelistmodel.cpp: Logging UpdatesclassDiagram
class ThemeListModel {
+ThemeListModel(QObject *parent) "+ logging added"
+~ThemeListModel() "+ logging added"
+void setFrameColor(QString selectedColor, QString normalColor) "+ logging added"
+void setSelection(QString path) "+ logging added"
+QVariant data(QModelIndex index, int role) const "+ logging added"
+void initThemes() "+ logging added"
}
Class Diagram for common/dbusinterface.cpp: Logging UpdatesclassDiagram
class SaveFileInterface {
+SaveFileInterface(QString service, QString path, QDBusConnection connection, QObject *parent) "+ logging added"
+~SaveFileInterface() "+ logging added"
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @re2zero - I've reviewed your changes - here's some feedback:
- This change sprinkles qDebug calls across almost every constructor, event handler, and method—which will flood logs and could hurt performance; consider centralizing logging via Qt logging categories and guarding verbose messages behind log‐level checks so you can disable them in production builds.
- You’re adding debug statements into very high-frequency paths (keyPressEvent, paintEvent, etc.); wrap those in conditional compilation or log-level checks to avoid runtime overhead and excessive log churn.
- Instead of mixing qDebug and qInfo everywhere, define and use meaningful logging levels and categories (e.g. startup, file IO, UI events) so logs can be filtered and you avoid logging trivial or redundant information.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| CodeFlodArea::CodeFlodArea(LeftAreaTextEdit *leftAreaWidget) | ||
| { | ||
| qDebug() << "CodeFlodArea created"; |
There was a problem hiding this comment.
suggestion: Constructor/destructor logs are very consistent—consider a macro
A TRACE_OBJECT macro would help reduce repetition and maintain consistent logging across widgets.
Suggested implementation:
#include <QDebug>
#define TRACE_OBJECT(CLASSNAME) \
qDebug() << #CLASSNAME " created"; \
struct CLASSNAME##_DestructorTracer { \
~CLASSNAME##_DestructorTracer() { qDebug() << #CLASSNAME " destroyed"; } \
} CLASSNAME##_destructorTracerInstance;
CodeFlodArea::CodeFlodArea(LeftAreaTextEdit *leftAreaWidget)
{
TRACE_OBJECT(CodeFlodArea)
m_pLeftAreaWidget = leftAreaWidget;
}
CodeFlodArea::~CodeFlodArea()
{
// Destructor log handled by TRACE_OBJECT macro
}
For best practices, the TRACE_OBJECT macro should be defined in a common header (e.g., trace_object.h) and included where needed. If you want to trace only construction and destruction, you may want to refine the macro or use a base class for tracing. Adjust the macro location and usage as appropriate for your codebase.
Add more logs for log coverage. Log: Add more logs.
|
Note
详情{
"src/editorapplication.cpp": [
{
"line": " const QString acknowledgementLink = \"https://www.deepin.org/original/deepin-editor/\";",
"line_number": 14,
"rule": "S35",
"reason": "Url link | 6859e7727a"
}
],
"src/widgets/window.cpp": [
{
"line": " QString key = \"base/enable\";",
"line_number": 376,
"rule": "S106",
"reason": "Var naming | 64f28539d9"
}
]
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, re2zero The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
This pr cannot be merged! (status: unstable) |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
Add more logs for log coverage.
Log: Add more logs.
Summary by Sourcery
Add comprehensive logging statements across the application to improve traceability of configuration, file operations, editor actions, UI interactions, theming, commands, and application lifecycle.
Enhancements: