You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For convenience, a logger is configured with the same name as the last part of the Action's UUID, so you can simply call logging.getLogger(<name>) with the appropriate name to get the already-configured logger that writes to a rotating file. The log file is located in the Stream Deck user log directory.
71
+
72
+
When creating actions in your plugin, you can configure logging using the logger name that matches the last part of your Action's UUID. For example, consider the following code:
Here, the logger name "myaction" matches the last part of the UUID passed in to instantiate the Action ("com.strohganoff.mytestplugin.myaction").
84
+
85
+
#### Configuring your own Loggers
86
+
87
+
Loggers can also be easily configured using provided utility functions, allowing for flexibility. If custom logging configurations are prefered over the automatic method shown above, you can use the following functions:
88
+
89
+
`configure_streamdeck_logger`: Configures a logger for the Stream Deck plugin with a rotating file handler that writes logs to a centralized location.
90
+
91
+
`configure_local_logger`: Configures a logger for a Stream Deck plugin that writes logs to a local data directory, allowing for plugin-specific logging.
92
+
93
+
These functions can be used to set up the logging behavior you desire, depending on whether you want the logs to be centralized or specific to each plugin.
94
+
95
+
For example:
96
+
```python
97
+
import logging
98
+
from streamdeck.utils.logging import configure_streamdeck_logger
Using the above code, you can ensure that logs from your action are properly collected and managed, helping you debug and monitor the behavior of your Stream Deck plugins.
106
+
107
+
67
108
### Running the Plugin
68
109
69
110
Once the plugin's actions and their handlers have been defined, very little else is needed to get this code running. With this library installed, the streamdeck CLI command will handle the setup, loading of action scripts, and running of the plugin automatically, making it much easier to manage.
@@ -117,21 +158,22 @@ Below is a complete example that creates a plugin with a single action. The acti
117
158
118
159
```python
119
160
# main.py
120
-
161
+
import logging
121
162
from streamdeck import Action, PluginManager, events
"""This module provides utility functions to get various directory paths related to Elgato Stream Deck plugins and components.
2
+
3
+
The functions defined here help locate user-specific log directories, local data directories for plugins, and application data directories for Elgato Stream Deck components and plugins.
4
+
These paths are useful for accessing log files, unpacked plugin code, and other application data for Stream Deck and its plugins.
5
+
6
+
Note:
7
+
These functions have been tested on macOS only so far, with plans to test on Windows in the future.
8
+
"""
1
9
from __future__ importannotations
2
10
3
11
fromtypingimportTYPE_CHECKING
@@ -11,28 +19,76 @@
11
19
12
20
13
21
defstreamdeck_log_dir() ->Path:
22
+
"""Get the path to the user-specific log directory for Elgato Stream Deck.
23
+
24
+
The result of this function is the user log directory path that all plugins as well as internal StreamDeck components write to.
0 commit comments