Skip to content

chore: More logs for service#264

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
re2zero:bugfix
Jul 22, 2025
Merged

chore: More logs for service#264
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
re2zero:bugfix

Conversation

@re2zero
Copy link
Copy Markdown
Contributor

@re2zero re2zero commented Jul 22, 2025

Add more logs for service.

Log: More logs for service.

Summary by Sourcery

Add comprehensive debug logging to the calendar service modules to improve runtime traceability of constructors, destructors, method calls, database operations, D-Bus interactions, systemd timer control, and synchronization workflows.

Enhancements:

  • Instrument service constructors and destructors with debug logs
  • Add debug statements to account module methods for key state changes
  • Log database management and query operations in DDataBaseManagement and SqliteQuery
  • Trace D-Bus service method invocations and property changes in DAccountManagerService and DServiceBase
  • Include logging in synchronization, systemd timer control, and HuangLi modules for detailed execution flow

Add more logs for service.

Log: More logs for service.
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 22, 2025

Reviewer's Guide

This PR instruments the calendar service with extensive logging by inserting qCDebug/qCInfo/qCWarning calls (and adding necessary commondef includes) across the codebase. Key methods, constructors/destructors, decision branches, DB operations, sync flows, and timer controls now emit detailed runtime insights for improved observability.

Sequence diagram for logging in DAccountModule::setExpand

sequenceDiagram
    participant User as actor User
    participant DAccountModule
    participant DAccount
    participant DAccountDB
    User->>DAccountModule: setExpand(isExpand)
    DAccountModule->>DAccount: isExpandDisplay()
    alt State changed
        DAccountModule->>DAccount: setIsExpandDisplay(isExpand)
        DAccountModule->>DAccountDB: updateAccountInfo()
        DAccountModule->>DAccountModule: qCDebug log ("Setting expand state to ...")
    else State unchanged
        DAccountModule->>DAccountModule: qCDebug log ("Setting expand state to ...")
    end
Loading

Sequence diagram for logging in DAccountManagerService::getAccountList

sequenceDiagram
    participant Client as actor Client
    participant DAccountManagerService
    participant DAccountManageModule
    Client->>DAccountManagerService: getAccountList()
    DAccountManagerService->>DAccountManagerService: qCDebug log ("Getting account list")
    DAccountManagerService->>DAccountManagerService: clientWhite(0)
    alt Not whitelisted
        DAccountManagerService->>DAccountManagerService: qCDebug log ("Client not whitelisted, returning empty account list")
        DAccountManagerService-->>Client: ""
    else Whitelisted
        DAccountManagerService->>DAccountManageModule: getAccountList()
        DAccountManagerService->>DAccountManagerService: qCDebug log ("Retrieved account list with length: ...")
        DAccountManagerService-->>Client: accountList
    end
Loading

Sequence diagram for logging in DDataBaseManagement constructor (DB migration)

sequenceDiagram
    participant DDataBaseManagement
    participant DAccountManagerDataBase
    participant DAccountDataBase
    participant QSqlDatabase
    DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Creating DDataBaseManagement instance")
    DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Setting up database paths")
    DDataBaseManagement->>DDataBaseManagement: qCDebug log ("New database path: ...")
    alt New DB does not exist
        DDataBaseManagement->>DDataBaseManagement: qCDebug log ("New database does not exist, creating initial setup")
        DDataBaseManagement->>DAccountManagerDataBase: setDBPath(newDB)
        DDataBaseManagement->>DAccountManagerDataBase: initDBData()
        DDataBaseManagement->>DAccountManagerDataBase: getAccountList()
        DDataBaseManagement->>DAccountDataBase: setDBPath(localAccountDB)
        DDataBaseManagement->>DAccountDataBase: initDBData()
        DDataBaseManagement->>DAccountDataBase: getSysColor()
        DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Mapping system colors")
        DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Checking for old database at: ...")
        alt Old DB exists
            DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Found old database, starting migration from: ...")
            DDataBaseManagement->>QSqlDatabase: addDatabase("QSQLITE", "oldDB")
            DDataBaseManagement->>QSqlDatabase: open()
            DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Setting up default type mappings")
            DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Checking if old database has type table")
            alt Has type table
                DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Old database has type table, migrating types")
                DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Migrating old type colors")
            end
            DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Migrating schedule data")
            DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Checking if old database has reminder table")
            alt Has reminder table
                DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Migrating reminder data")
                DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Migrated ... reminder entries")
            end
            DDataBaseManagement->>DDataBaseManagement: qCDebug log ("Database migration completed successfully")
        else No old DB
            DDataBaseManagement->>DDataBaseManagement: qCDebug log ("No old database found, skipping migration")
        end
    else New DB exists
        DDataBaseManagement->>DDataBaseManagement: qCDebug log ("New database already exists, skipping initialization")
    end
Loading

Class diagram for logging instrumentation in calendar service

classDiagram
    class DAccountModule {
        +DAccountModule(account, parent)
        +~DAccountModule()
        +getAccountInfo()
        +getExpand()
        +setExpand(isExpand)
        +getAccountState()
        +setAccountState(accountState)
        +getSyncState()
        +getSyncFreq()
        +setSyncFreq(freq)
        +getScheduleTypeList()
        +getScheduleTypeByID(typeID)
        +createScheduleType(typeInfo)
        +deleteScheduleTypeByID(typeID)
        +scheduleTypeByUsed(typeID)
        +updateScheduleType(typeInfo)
        +createSchedule(scheduleInfo)
        +updateSchedule(scheduleInfo)
        +getScheduleByScheduleID(scheduleID)
        +deleteScheduleByScheduleID(scheduleID)
        +querySchedulesWithParameter(params)
        +getRemindScheduleList(dtStart, dtEnd)
        +getSysColors()
        +account() const
        +updateRemindSchedules(isClear)
        +notifyMsgHanding(alarmID, operationNum)
        +remindJob(alarmID)
        +accountDownload()
        +uploadNetWorkAccountData()
        +getDtLastUpdate()
        +removeDB()
        +getScheduleTimesOn(dtStart, dtEnd, scheduleList, extend)
        +getFestivalSchedule(dtStart, dtEnd, key)
        +extendRecurrence(scheduleMap, schedule, dtStart, dtEnd, extend)
        +closeNotification(scheduleId)
        +getScheduleByRemind(remindData)
        +downloadTaskhanding(index)
        +uploadTaskHanding(open)
        +slotOpenCalendar(alarmID)
        +slotSyncState(syncState)
        +slotDateUpdate(updateType)
        +importSchedule(icsFilePath, typeID, cleanExists)
        +exportSchedule(icsFilePath, typeID)
    }
    class DAccountManageModule {
        +DAccountManageModule(parent)
        +getAccountList()
        +getCalendarGeneralSettings()
        +setCalendarGeneralSettings(cgSet)
        +getfirstDayOfWeek()
        +setFirstDayOfWeek(firstday)
        +getTimeFormatType()
        +setTimeFormatType(timeType)
        +remindJob(accountID, alarmID)
        +updateRemindSchedules(isClear)
        +notifyMsgHanding(accountID, alarmID, operationNum)
        +downloadByAccountID(accountID)
        +uploadNetWorkAccountData()
        +login()
        +logout()
        +isSupportUid()
        +calendarOpen(isOpen)
        +unionIDDataMerging()
        +initAccountDBusInfo(account)
        +removeUIdAccount(uidAccount)
        +addUIdAccount(uidAccount)
        +updateUIdAccount(oldAccount, uidAccount)
        +setUidSwitchStatus(account)
        +getGeneralSettings()
        +setGeneralSettings(cgSet)
        +slotFirstDayOfWeek(firstDay)
        +slotTimeFormatType(timeType)
        +getFirstDayOfWeekSource()
        +setFirstDayOfWeekSource(source)
        +getTimeFormatTypeSource()
        +setTimeFormatTypeSource(source)
        +slotUidLoginStatueChange(status)
        +slotSwitcherChange(state)
        +slotSettingChange()
        +slotClientIsOpen()
    }
    class DDataBaseManagement {
        +DDataBaseManagement()
        +newDatabasePath() const
        +setNewDatabasePath(newDatabasePath)
        +oldDatabasePath() const
        +setOldDatabasePath(oldDatabasePath)
        +databaseExists(databasePath, create)
        +hasLunnarField(db)
        +hasTypeDB(db)
        +hasRemindDB(db)
        +queryOldJobTypeData(db)
        +queryOldJobData(db, haslunar)
        +queryOldTypeColorData(db)
        +querOldRemindData(db)
        +hasTransfer() const
    }
    class DDataBase {
        +DDataBase(parent)
        +~DDataBase()
        +getDBPath() const
        +setDBPath(DBPath)
        +createUuid()
        +getConnectionName() const
        +setConnectionName(connectionName)
        +initDBData()
        +dbOpen()
        +dbFileExists()
        +removeDB()
    }
    class DRemindData {
        +DRemindData()
        +accountID() const
        +setAccountID(accountID)
        +scheduleID() const
        +setScheduleID(scheduleID)
        +recurrenceId() const
        +setRecurrenceId(recurrenceId)
        +remindCount() const
        +setRemindCount(remindCount)
        +notifyid() const
        +setNotifyid(notifyid)
        +dtRemind() const
        +setDtRemind(dtRemind)
        +dtStart() const
        +setDtStart(dtStart)
        +dtEnd() const
        +setDtEnd(dtEnd)
        +alarmID() const
        +setAlarmID(alarmID)
        +updateRemindTimeByCount()
        +updateRemindTimeByMesc(duration)
        +getRemindTimeByMesc(duration)
    }
    class DUploadTaskData {
        +DUploadTaskData()
        +sql_table_name(task_obj)
        +sql_table_primary_key(task_obj)
        +taskType() const
        +setTaskType(taskType)
        +taskObject() const
        +setTaskObject(taskObject)
        +objectId() const
        +setObjectId(objectId)
        +taskID() const
        +setTaskID(taskID)
        +dtCreate() const
        +setDtCreate(dtCreate)
    }
    class DServiceBase {
        +DServiceBase(path, interface, parent)
        +getPath() const
        +getInterface() const
        +getClientName()
        +clientWhite(index)
        +notifyPropertyChanged(interface, propertyName)
    }
    class DHuangLiDataBase {
        +DHuangLiDataBase(parent)
        +readJSON(filename, cache)
        +updateFestivalList()
        +queryFestivalList(year, month)
        +queryHuangLiByDays(days)
        +initDBData()
        +createDB()
    }
    class CalendarHuangLi {
        +CalendarHuangLi(parent)
        +getFestivalMonth(year, month)
        +getHuangLiDay(year, month, day)
        +getHuangLiMonth(year, month, fill)
        +getLunarInfoBySolar(year, month, day)
        +getLunarCalendarMonth(year, month, fill)
    }
Loading

File-Level Changes

Change Details Files
CalendarDataManager classes now emit detailed debug logs
  • Inserted qCDebug statements at ctor/dtor entry points
  • Logged key parameters in getters/setters (accountID, scheduleID, freq, state)
  • Logged decision branches and loop iterations in schedule and type operations
calendar-service/src/calendarDataManager/daccountmodule.cpp
calendar-service/src/calendarDataManager/daccountmanagemodule.cpp
calendar-service/src/calendarDataManager/duploadtaskdata.cpp
DBus service layer methods enhanced with entry/exit and property-change logs
  • Added debug logs during service initialization and signal connections
  • Logged clientWhite checks and getClientName results
  • Emitted logs around property change notifications and DBus calls
calendar-service/src/dbusservice/daccountmanagerservice.cpp
calendar-service/src/dbusservice/dhuangliservice.cpp
calendar-service/src/dbusservice/dservicebase.cpp
calendar-service/src/dbusservice/dservicemanager.cpp
calendar-service/src/synchronization/dbuscloudsync.cpp
Database management and query execution now traced
  • Logged DDataBaseManagement initialization, migration paths and mapping steps
  • Traced DDataBase open/create operations and file existence checks
  • Logged SqliteQuery exec, transaction, commit/rollback events
calendar-service/src/dbmanager/ddatabasemanagement.cpp
calendar-service/src/dbmanager/ddatabase.cpp
calendar-service/src/dbmanager/daccountmanagerdatabase.cpp
calendar-service/src/dbmanager/dhuanglidatabase.cpp
Synchronization workflow instrumented with debug logs
  • Logged SyncFileManage ctor/dtor and directory operations
  • Inserted logs for login/logout sync calls and DBus callbacks
  • Tracked data sync factory creation and DataSyncBase lifecycle events
  • Logged DUnionIDDav and SyncStack operations during sync flows
calendar-service/src/synchronization/syncfilemanage.cpp
calendar-service/src/synchronization/syncoperation.cpp
calendar-service/src/unionIDDav/dsyncdatafactory.cpp
calendar-service/src/unionIDDav/ddatasyncbase.cpp
calendar-service/src/unionIDDav/dunioniddav.cpp
AlarmManager now reports reminder scheduling and notifications
  • Logged systemd timer build/stop actions and reminder job execution
  • Logged notification payload creation, notify IDs, and message handling branches
  • Traced DRemindData time updates (by count and ms)
calendar-service/src/alarmManager/dalarmmanager.cpp
calendar-service/src/alarmManager/dreminddata.cpp
Systemd timer control actions now produce log entries
  • Logged CSystemdTimerControl construction and destruction
  • Emitted info logs for starting/stopping download, upload, remind timers
  • Logged creation of systemd user paths
calendar-service/src/csystemdtimercontrol.cpp
Main application startup and translation loading instrumented
  • Logged loading of translators, directory paths and fallback logic
  • Tracked DDataBaseManagement and DServiceManager initialization
  • Logged delayed remind job update execution
calendar-service/src/main.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link
Copy Markdown

  • 敏感词检查失败, 检测到2个文件存在敏感词
详情
{
    "calendar-service/src/dbmanager/dhuanglidatabase.cpp": [
        {
            "line": "const QString HolidayUpdateURLPrefix =\"https://cdn-nu-common.uniontech.com/deepin-calendar\";",
            "line_number": 21,
            "rule": "S35",
            "reason": "Url link | 0b2e847e1f"
        }
    ],
    "calendar-service/src/calendarDataManager/daccountmanagemodule.cpp": [
        {
            "line": "const QString firstDayOfWeek_key = \"firstDayOfWeek\";",
            "line_number": 12,
            "rule": "S106",
            "reason": "Var naming | dc5ba3cd3f"
        },
        {
            "line": "const QString shortTimeFormat_key = \"shortTimeFormat\";",
            "line_number": 13,
            "rule": "S106",
            "reason": "Var naming | 7e44ab71d7"
        },
        {
            "line": "const QString firstDayOfWeekSource_key = \"firstDayOfWeekSource\";",
            "line_number": 14,
            "rule": "S106",
            "reason": "Var naming | 615e50c973"
        },
        {
            "line": "const QString shortTimeFormatSource_key = \"shortTimeFormatSource\";",
            "line_number": 15,
            "rule": "S106",
            "reason": "Var naming | da98f021ed"
        }
    ]
}

@deepin-ci-robot
Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@re2zero
Copy link
Copy Markdown
Contributor Author

re2zero commented Jul 22, 2025

/merge

@deepin-bot deepin-bot Bot merged commit 71af5d5 into linuxdeepin:develop/snipe Jul 22, 2025
20 checks passed
@re2zero re2zero deleted the bugfix branch July 22, 2025 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants