WIP: Log loaded modules and actions #53

Draft
modulatingforce wants to merge 0 commits from Log-modules-acts into master

Initial description

Smol enhancement. In BotInstance constructor method init() , add logic that prints into the log the BotModules and botactions that were successfully loaded

At the moment, this functionality was implemented in main(), and spits out line by line as it went through the botactions vector

For this PR,

# Initial description Smol enhancement. In `BotInstance` constructor method `init()` , add logic that prints into the log the `BotModules` and `botactions` that were successfully loaded At the moment, this functionality was implemented in `main()`, and spits out line by line as it went through the `botactions` vector For this PR, - [ ] we'll need to move that implementation from `main()` moved to in the `BotInstance::init()` - Source logic here - https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/Log-modules-acts/src/main.rs#L26-L53 - needs to be moved somewhere here - https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/Log-modules-acts/src/core/botinstance.rs#L134-L143 - [ ] Adjust the logic so it is constructed in one easy line for debuggers to identify - [ ] [ _optional & intermediate_ ] add private methods to `ModulesManager` like `get_modules()` and `get_botactions()`
modulatingforce added this to the Forcebot Prototype 1.0 Push project 2024-03-29 20:33:04 -04:00
Author
Owner

Thinking about delegating or showcasing

Thinking about delegating or showcasing
Author
Owner

I wanted to flesh out the details a bit of this PR , but I think I'm intending to delegate this later

I wanted to flesh out the details a bit of this PR , but I think I'm intending to delegate this later
modulatingforce added the
Ownership
Needs Owner > May Delegate
label 2024-03-31 09:44:53 -04:00
Author
Owner

Just in case these are helpful for implementing

Related https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/Log-modules-acts/src/main.rs#L28-L53

From main() that logs each BotAction , but one line at a time

    {
        botlog::trace("Reading bot actions", Some("main()".to_string()), None);

        let actsdb = Arc::clone(&bot.botmodules.botactions);
        let actsdb_lock = actsdb.read().await;

        for acts in (*actsdb_lock).values() {
            for act in acts {

                let act_prelock = act;
                let act = act_prelock.read().await;

                let outstr = match &(*act) {
                    botmodules::BotAction::C(b) => {
                        format!("bot actions > Command : {}", b.command)
                    }
                    botmodules::BotAction::L(l) => {
                        format!("bot actions > Listener : {}", l.name)
                    }
                    _ => "Not a valid match??".to_string(),
                };

                botlog::info(outstr.as_str(), Some("main()".to_string()), None);
            }
        }
    }

Helpful ModulesManager methods


I'll say this is relatively intermediate because the Arc<RwLock<T>> involved and unpacking

Just in case these are helpful for implementing Related https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/Log-modules-acts/src/main.rs#L28-L53 From `main()` that logs each `BotAction` , but one line at a time ```rust { botlog::trace("Reading bot actions", Some("main()".to_string()), None); let actsdb = Arc::clone(&bot.botmodules.botactions); let actsdb_lock = actsdb.read().await; for acts in (*actsdb_lock).values() { for act in acts { let act_prelock = act; let act = act_prelock.read().await; let outstr = match &(*act) { botmodules::BotAction::C(b) => { format!("bot actions > Command : {}", b.command) } botmodules::BotAction::L(l) => { format!("bot actions > Listener : {}", l.name) } _ => "Not a valid match??".to_string(), }; botlog::info(outstr.as_str(), Some("main()".to_string()), None); } } } ``` --- Helpful `ModulesManager` methods - `fn moduleslist(&self) -> HashMap<BotModule,ModGroup>` - https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/Log-modules-acts/src/core/botmodules.rs#L629 - HINT : The returned HashMap is the same as `Arc::clone(&bot.botmodules.botactions)` above in `main()` , except without `Arc<RwLock<T>>` - `fn modstatus(&self, in_module: BotModule, in_chnl: Channel) -> StatusType ` - https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/Log-modules-acts/src/core/botmodules.rs#L646 - Returns `StatusType` of the Module . For example, Enabled/Disabled - refer to https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/Log-modules-acts/src/core/botmodules.rs#L457 --- I'll say this is relatively intermediate because the `Arc<RwLock<T>>` involved and unpacking
modulatingforce added
Complexity
Intermediate
and removed
Complexity
Basic
labels 2024-04-05 13:09:20 -04:00
notohh was assigned by modulatingforce 2024-04-07 21:18:26 -04:00
modulatingforce self-assigned this 2024-04-07 21:18:26 -04:00
Saru was assigned by modulatingforce 2024-04-07 21:18:26 -04:00
modulatingforce added
Ownership
Collab
and removed
Ownership
Needs Owner > May Delegate
labels 2024-04-07 21:18:36 -04:00
Author
Owner
  • Will schedule time to discuss requirements

Notohh is available this week-
5 am - 8pm or so

Sari -
After Wednesday

- [ ] Will schedule time to discuss requirements Notohh is available this week- 5 am - 8pm or so Sari - After Wednesday
All checks were successful
ci/woodpecker/push/cargo-checks Pipeline was successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin Log-modules-acts:Log-modules-acts
git checkout Log-modules-acts
Sign in to join this conversation.
No reviewers
No milestone
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: modulatingforce/forcebot_rs#53
No description provided.