Skip to content

Conversation

@G4PLS
Copy link
Member

@G4PLS G4PLS commented Jun 19, 2025

This adds Plugin Based logging to StreamController.
It adds a log file for every plugin using loguru.

I added custom file retention as Im using date/time based log names that are different on every start. I did this because that makes it easy to only display the latest informations in the about window of the plugin

@ImDevinC
Copy link
Contributor

I can definitely see benefits here, but I'm also curious if the multiple log files will make it more challenging to grab data from users when they need support. The functionality itself looks good, but will wait for @Core447 to chime in

@ImDevinC
Copy link
Contributor

Nevermind, I see my confusion. This doesn't replace the base plugin logger, this creates a new logger specifically for troubleshooting. I think this is a good start, but I think this could be expanded upon a little more to make it more user friendly. Something like the following:

  1. On the existing StreamController Plugin Settings page (the one that shows all plugins and gives buttons for settings/about), include a new button for "Troubleshooting". (perhaps we add a new config option to plugins, like has_troubleshooting that could determine if this button is enabled)
  2. When a user clicks that button, it calls the troubleshoot function of the plugin. This troubleshoot function can do whatever the developer needs (run checks, validate configs, etc) and output the results to a log file (I like the secondary log file for this)
  3. After the troubleshooting is completed, we prompt the user to save the log somewhere

I think the only thing missing from your implementation is the ability to call the troubleshoot function from StreamController somewhere. I think this would be better than putting inside a specific action as we may want to troubleshoot some part of the plugin that is preventing actions from loading.

@G4PLS
Copy link
Member Author

G4PLS commented Jun 20, 2025

I want to replace the Plugin Logger with this, its in my opinion a better way and it provides a dedicated "space" for every Plugin to use.
This logger will still write to the main log and the CLI but has a separate log file for the Plugin to easily get everything thats going on with the Plugin without having to read through sometimes bigger log files with lots of unneeded entries.

Adding the button to the settings that starts a troubleshoot/diagnostic sounds like a good idea!

Under Settings -> Plugins -> Your Plugin -> About -> Troubleshooting -> Debugging Info we already have the section to show the log, just like StreamController does it and I would just use that.

I would create 2 methods:
log() which will replace the new troubleshoot() method. This can then be used to just log things into that Plugin log.
I will create a new troubleshoot() method that can be called to implement custom diagnostic behaviour, I would do that In a way where I then call a diagnostic on all Actions to get as much data as needed by using signals.

@G4PLS
Copy link
Member Author

G4PLS commented Jun 20, 2025

@ImDevinC could you take a look again? Added everything you wanted/needed

@G4PLS
Copy link
Member Author

G4PLS commented Jun 20, 2025

This change now results in the following (Its a long line):

2025-06-20 15:19:52.578 | com_gapls_AudioControl | actions.AudioCore:troubleshoot:190 - Troubleshooting for action: Mute on  : {'selected_device': <Device pulse_name=Browser pulse_index=34 device_name=Browser>, 'device_filter': <SimpleComboRowItem display=Sink value=sink filter=Sink>, 'info_content': <SimpleComboRowItem display=Volume value=volume filter=Volume>, 'show_info_content': True, 'device_name': '', 'show_device_name': True, 'use_standard': False, 'loaded_devices': [<Device pulse_name=System pulse_index=31 device_name=System>, <Device pulse_name=Game pulse_index=32 device_name=Game>, <Device pulse_name=Voice Chat pulse_index=33 device_name=Voice Chat>, <Device pulse_name=Browser pulse_index=34 device_name=Browser>, <Device pulse_name=alsa_output.pci-0000_18_00.6.analog-stereo pulse_index=75 device_name=ALC897 Analog>, <Device pulse_name=alsa_output.usb-Focusrite_Scarlett_Solo_USB_Y756R404B041C6-00.HiFi__Line1__sink pulse_index=79 device_name=Scarlett Solo USB>], 'icon_keys': [<Icons.MUTED: 'mute'>, <Icons.UNMUTED: 'audio'>], 'current_icon_name': <Icons.UNMUTED: 'audio'>}

The code for this is very simple:

async def troubleshoot(self, *args, **kwargs):
    self.log(f"Troubleshooting for action: {self.__class__.__name__} on ",
             selected_device=self.selected_device,
             device_filter=self.device_filter,
             info_content=self.info_content,
             show_info_content=self.show_info_content,
             device_name=self.device_nick,
             show_device_name=self.show_device_name,
             use_standard=self.use_standard_device,
             loaded_devices=self.loaded_devices,
             icon_keys=self.icon_keys,
             current_icon_name=self._icon_name)

@ImDevinC
Copy link
Contributor

This looks great, thanks for putting it together so quickly!

@G4PLS G4PLS marked this pull request as ready for review June 20, 2025 14:46
@G4PLS
Copy link
Member Author

G4PLS commented Jun 20, 2025

Alright opened it for merge! Now we just have to wait and see what @Core447 thinks

@G4PLS G4PLS mentioned this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants